Solved Qt Multimedia : How to convert/re-encode a video file
-
I would like to be able, using Qt Multimedia, to convert a video or audio file to another container/codec format, meaning re-encode the file.
Could someone please indicate whether this can be accomplished, and if yes, how ?
A link to an example will be wonderful.As a related question, I suppose that for listing the video & audio codecs that are available for encoding, one would use the functions QMediaRecorder::supportedAudioCodecs and QMediaRecorder::supportedVideoCodecs. Is that correct ?
-
Hi,
To convert files, I'd recommend calling the
ffmpeg
executable from your Qt application with QProcess. You can also use the libs from ffmpeg and write the code based on it within your application.Hope it helps.
-
I have seen this advice before, but was hoping that something has improved since then.
Does that mean that you don't recommend using Qt Multimedia ?I would have expected Qt to incorporate GStreamer as its video interface.
Is Qt hit also by the dreaded "Not invented here" syndrome? -
I mean that QtMultimedia is not the right tool to do video conversion.
On Linux Qt uses gstreamer as backend.
But again, converting video files from different formats in different formats is currently not something you should try to do with QtMultimedia. It uses what the OS provides and depending on your target (I'm guessing Linux) you won't have all the codecs you may need/want. Using FFMPEG, you have the Swiss Army Knife of video converter. Or if you are used to gstreamer, there also the QtGStreamer module that might be of interest.
-
This should work also on Windows, where GStreamer is available and working.
The hint of QtGStreamer was useful, but the problem is that it is not part of the Qt release, so at least for Windows I'll have to compile it and fix myself all problems. -
It's not an official Qt module, it's provided by the gstreamer project. So depending on your target OS, you'll to build it anyway.
-
Thanks - I am now convinced that doing video conversions using Qt is a bad idea, unless one has lots of spare time on his hands.
-
Like I wrote before, doing video conversion is not an easy task and is currently outside of QtMultimedia's functionality and one of the best tool available for that is ffmpeg.
Note that you can very well mix other libraries like ffmpeg or gstreamer with Qt without any problem.