Reputation: 1
I have an AVFrame from FFMPEG in YUV format. I would like to render it using qt derived class from QOpenGLWidget and QOpenGLFunctions.
I'm a beginner to qt and OpenGL.
Can someone help out with this?
Thanks Aswin
Upvotes: 0
Views: 2424
Reputation: 9986
For these cases, I wrote a demo using a custom QQuickItem. YUV data is uploaded to the GPU and converted with a OpenGL shader. This is the repo with the code: https://github.com/carlonluca/qtyuv.
Upvotes: 0
Reputation: 1653
Well, actually, if you'll need to implement a really fast-rendering player, you'll have to mess with buffer optimizations, off-screen rendering, buffer streaming -- something from those. But as far as you are new with Qt, there are simple, yet working solutions:
QFFmpegGLWidget class in the link above is sufficient for you to get the idea. Converting to RGB is done via fragment shader, good old trick with 3 textures applied with GL_LUMINANCE works there.
I struggled with my own, almost similar solution, nevertheless got picture from camera (rtsp) with wrong, messed colors. So, make sure, you are getting frames in YUV420p. In case other pixel format suits you better, check these chineese resources to get it deeper (google translation makes 'em readable):
Good luck!
Upvotes: 4