Is it possible to record a dynamic QWidget into a video?

  • Hi,

    I am recently using QOpenGLWidget to draw something in the runtime. I wonder if it is possible to record the whole drawing process into a video. I found a bunch of examples saying Qt5 could support multimedia by using webCam(QCamera). However, it didn't say if this camera can be set the target to QWidget itself. Any idea? Thanks!

    Note: Qt5.6.2 (Could upgrading if needed), Ubuntu16.04

  • The only way I could think of is using QScreen::grabWindow() and QTimer to save my widget's screen shots sequentially. And how could I make this raw image data to a video?

  • Lifetime Qt Champion


    Do you want that integrated in your application or would like to just record what is happening for some other purpose ?

  • for sure it is integrated in my application. Right now I have a solution that using openCV's VideoWriter to grabFrameBuffer() per frame and write it into a VideoWriter. However, this grabFrameBuffer() function seems a pretty heavy task that causing my output video sometimes flickering. I don't quite care about what is rendering currently in my window, I am caring the output video that should seem to be fluent enough.

    My render method is based on QOpenGLWidget. Right now I want to use a FramBufferObject to "steal" content from my paintGL() function call every frame. And using QOpenGLGFrambufferObject::toImage to get an image and write it into a video. However right now I could only "steal" black screen in my window. and my window is rendering nothing for sure. I think there might be a way to hand over all gl's draw calls and save it into my framebufferobject.

  • Lifetime Qt Champion

    You should post the code you are currently using. That will allow other eyes to take a look at it and maybe find what is happening with it.

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.