How to create a .mp4 Video from a collection of QOpenGLFramebufferObjects /QImages / Glunit textures
-
I am developing a Qt app for iOS, Android & OSX.
Situation:
I have anstd::vector
of QOpenGLFramebufferObjects. EachQOpenGLFramebufferObject
can of course provide its own QImage or aGLunit
texture by doing a takeTexture. So you can also say that I have a collection ofQImage
s orGLunit
textures.Problem:
I want to create a.mp4
video file out of these QImages/QOpenGLFramebufferObjects which works on iOS, Android & OSX.How should I do this? Any examples doing this with Qt? Which classes in Qt should I be looking into?
I am thinking to use ffmpeg or GStreamer whatever works best in Qt. But I want to know how to pass these QImages or Glunit textures to create the video. Is there Qt support to do this without having to use a 3d party library?
Should I use QVideoEncoderSettings to create the video?
Are there any examples in Qt doing this?
Which classes/components in Qt I should be looking into?Is there something in Qt Multimedia that I can use?
If not then what is the best option wrt to making this work on Android & iOS?PS :
I am using Qt 5.9.1 commercial version on Android & iOS -
Hi,
Something is not clear from your description, do you want your application to record a video file on all three platforms ? Or do you want to generate video files that can be played on all these platforms ?
If the former, what is the source of images ? Are you using widgets or QtQuick ?
-
@SGaist I want to generate video files that can be played on all 3 platforms.
The source
QImage
s are are some areQOpenGLFramebufferObject
s which are populated after some processing using OpenGL.I am using Qt Quick commercial version for Android & iOS. And working on Qt 5.9.1.
Simplistically saying, I just want to create a video file from QImages or Glunit textures whichever option works with Qt.
-
Well, I'm sorry to say that it's still not that clear, so let me rephrase that: will your application create these video files on iOS and Android ? Or are you creating a desktop only application that should create these video files ?
In any case, QOpenGLFramebufferObject has a toImage method that returns a QImage.
-
@SGaist Yes. My application will create these video files on iOS and Android. It is not a desktop only application. It is primarily for iOS & Android. But the application runs on MacOS as well which is my development environment.
Yes.
QOpenGLFramebufferObject
hastoImage method
to return aQImage
. I already know that. But my question starts after this.Rephrasing my question here again:
Consider you have 15QOpenGLFramebufferObject
s in memory. Each one of course can return aQImage
. I wan to create a video (.mp4
) out of these 15QImage
s. How do I do this with Qt.And of course, as I said I am running commercial paid version of Qt based Qt latest 5.9.1 released recently. It is a Qt quick based application.
-
QMediaRecorder would be the starting point.
Note that there's no system encoder for h264, it's a non free-format.
-
@SGaist How can I pass
QImage
s intoQMediaRecorder
& create a video out of it?
Is there a example or some code snippet you could point to?Note that I don't need audio. I just want to programmatically create a video out of multiple
QImage
s. And, this is has nothing to do with the camera . I am not trying to get images from camera.Trying to see the examples of
QMediaRecorder
, all of them hooking on to the camera which I don't need to do with my program . Simply, I have someQImage
s in memory. Want to create a video from say 10QImage
s. -
You need to create a QMediaObject that will provide the images to QMediaRecorder.
-
@SGaist said in How to create a .mp4 Video from a collection of QOpenGLFramebufferObjects /QImages / Glunit textures:
QMediaObject
Is there an example doing something similar? would be really helpful if you could point to an example doing something close
-
AFAIK, no. You will have to take some inspiration from the Qt Multimedia sources.