Qt World Summit: Submit your Presentation

Getting QImages into QMediaRecoder to create video files (e.g. avi, mp4, or animated gif)?

  • Relative to this topic, "Video file generation from Qt application, other than FFmpeg" (thread: https://forum.qt.io/topic/63105/video-file-generation-from-qt-application-other-than-ffmpeg) there's been suggestions in related Qt forums, possibly referring to the Qt5 QMediaRecorder class, that video file generation can be done in "just" Qt. (I'm not sure how authoritative such suggestions are).

    In the Qt5 documentation, there is just a little information about using QCamera in conjunction with QMediaRecorder to create video files ("record video to disk") ...


    However, I'm not seeing any way to get QImages or QPixmaps into either of these classes (QCamera or QMediaRecorder), nor their base classes. So I don't see how these can be used to generate video files from synthetic (program-created) images. (Ultimately, they would come from "rendering" our QWidgets to QPixmaps or QImages).

    Also, there doesn't seem to be any information about whether anything special has to be done with respect to video codecs for creating video files (e.g. avi, mp4, or animated gif). I'd like to give it a try, but that's not doable (nor meaningful) if we can't get QImages and QPixmaps into these things.

  • Unfortunately, Qt commercial license support folks are confirming that, currently (as of Qt 5.6), there is no way to get a sequence of programmatically generated QImages (e.g. renders from an application QWidget) into the QMediaRecorder class. ("There is no API for that").

    Related -- they also could not offer any information about a Google WebM / VP8 solution. That really looks like a promising approach, though the integration is technically challenging. As far as I can tell, that really is the only virtually bullet-proof legal approach to generating synthetic videos (i.e. animations generated programmatically, saved as video files). http://www.webmproject.org/about/

  • You might want to check the libqtavi library: https://iondev.ro/qtavi/

    It enables Qt based applications to easily save video files in the AVI container format and is available under two licenses: open-source (GPL v. 3.0) and commercial.