How to render custom video data in Qt ?

梦想与她 提交于 2019-12-24 09:21:03

问题


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:

  1. Create a custom QWidget subclass
  2. Override the paintEvent() method
  3. 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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!