[Interest] Screen Capture as format YUV
Ola Røer Thorsen
ola at silentwings.no
Thu Nov 8 10:14:21 CET 2018
There is some code in the QMultimedia source that does convert from YUV to
RGB while rendering to the screen, I'd recommend you take a look there for
inspiration. I think it's the qsgvideonode_yuv.cpp file.
I've done similar things (I do rgb->yuv instead). Basically you upload your
YUV image to textures (use one for Y, another 1 or 2 for UV, depending on
the YUV format used). Render a textured quad to an FBO with an RGB texture,
using a shader that converts YUV to RGB. Read that FBO texture back to CPU
memory either with glReadPixels directly (slow!) or using pixel buffer
objects (PBO, much more efficient). With regards to performance, in my
experience on iMX6 (embedded linux, eglfs), a 720p stream will run at 1-2Hz
using glReadPixels, and at least 30Hz using glReadPixels on PBOs.
Things you need to read up on: OpenGL "render to texture", framebuffer
objects (FBO), pixel buffer objects (PBO), shaders. You can use Qt OpenGL
classes (such as QOpenGLContext, QOpenGLFramebufferObject and
QOpenGLShaderProgram) for pretty much everything except the PBOs, there you
need the native OpenGL API.
Cheers,
Ola
Den ons. 7. nov. 2018 kl. 17:55 skrev Jason H <jhihn at gmx.com>:
> I would be very interested in such a solution as well, but I don't know
> anything about "fragment shaders". If you know of any resources, I'm all
> ears!
>
>
>
> *Sent:* Wednesday, November 07, 2018 at 11:46 AM
> *From:* "Sean Harmer" <sh at theharmers.co.uk>
> *To:* interest at qt-project.org
> *Subject:* Re: [Interest] Screen Capture as format YUV
>
> That would also be horribly slow for large frames. I'd suggest using a
> fragment shader to perform the conversion then glReadPixels to get it back
> to the CPU (or even better pass the texture id to gstreamer if it can work
> with them and avoid the round trip).
>
> Cheers,
>
> Sean
>
> On 07/11/2018 16:23, Jason H wrote:
>
> No. Video formats are not supported for paint operations. You'll have to
> convert.
> You can use a Runnable and do it on another core, though that adds
> asyncronicities...
>
>
> *Sent:* Wednesday, November 07, 2018 at 4:25 AM
> *From:* "Emre Cetin" <hsnemrecetin at gmail.com> <hsnemrecetin at gmail.com>
> *To:* interest at qt-project.org
> *Subject:* [Interest] Screen Capture as format YUV
> Hi everyone,
>
> I have a project related to image processing on QT and GStream. I have
> created a program with QWidget, and I got a screenshot of this program with
> QPixmap. However, I need to convert these frames into a YUV format and
> send them to GStream because I am going to merge these frames another video
> frames with GStream.
>
> Is there any way I can get QWidget frames in YUV format? Without
> conversion. I am working on QT 5.5. Any advice ?
>
> Thanks,
> Emre Cetin
> _______________________________________________ Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
>
>
> _______________________________________________
> Interest mailing listInterest at qt-project.orghttp://lists.qt-project.org/mailman/listinfo/interest
>
>
> _______________________________________________ Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20181108/b1e7e20c/attachment.html>
More information about the Interest
mailing list