问题
I have never done a Qt video application - newbie in this area. I have a custom video file format to render using Qt. The video file format is 256-byte header, then pixel data, then 256-byte header, then pixel data and so on. The header consist info like width, height in pixels, bytes per pixels, frame rate etc and the pixel data is in Bayer (GBRG). I may have to process data before display - like convert to RGB (not sure yet). I see there are lot of video related classes like QGL*, QMovie, QVideo* ... don't know where to start ? I have seen mandelbrotwidget example which looks like a good place to start but still need some advice. Also, do I have to write a Qt Image plugin for Bayer pattern?
Thank you.
回答1:
Good advice is to do all by yourself. If you have simple data structure read it by simple C++
-code.
Conversation from Bayer RGB
to RGB
like here you can also make without using any Qt objects.
And now, when you'll got trivial RGB-image (even in your own structure) per frame, you can show it on widgets such as QGL*
-- if you prefer OpenGL
rendering, or Qt's classes such as QPainter
, QImage
...
Some more links: C++ GUI Programming with Qt4, 2nd Edition, Graphics View Framework
回答2:
The best place to start is by learning the basics of custom drawing in Qt. In short, a very simple implementation would require you to:
- Create a custom
QWidget
subclass - Override the
paintEvent()
method - Use a
QPainter
/QImage
to decode your raw video data into image data and draw it on screen
Qt has lots of good sample code to get you started, such as:
http://qt-project.org/doc/qt-4.8/examples-painting.html
Once you have a simple implementation up and running, and a basic grasp of Qt concepts/classes, then you'll be ready to profile, optimize, and make use of more advanced Qt functionality (GL, video) as needed.
来源:https://stackoverflow.com/questions/12918518/how-to-render-custom-video-data-in-qt