Play an FLV file inside an offline Qt App.
-
Greetings Qt insiders,
I have a tricky request. I have an FLV video and I'd like to play this in my Qt application.
What's the simplest way ?
- Convert it to AVI and then get Phonon to do the job ?
- Use FFMpeg + QImage ?
- An offline QtWebkit trick ?
Thanks for your insights.
B.A.
-
AFAIK, FLV is just a container, like AVI or MKV. This means that it should be possible to play it using Phonon if you have all necessary codecs installed (both for the container and for the stream inside it). No need to convert. But I'm not an expert in this field so it's just an assumption.
-
Afaik VLC media player is build using Qt. And VLC can play FLV files. so you could have a look at their code... Perhaps it helps.
-
-
using ffmpeg + qimage, you'll have to deal yourself with framerate forn display, which is not a single bit easy. More over, you'll have to deal with audio nad worst, audio/video synchronisation. Time to start for a few months of development
-
offline qtWebkit trick : I don't see how webkit would be playing it... From what I know, the actual player is flash, not webkit, so it means it would be an offline flash player trick (no expert here however).
-
using phonon, if your backend is able to play it correctly, it should work. On windows (based on directshow), it would mean you have
** correct source (most probably asynch reader, part of standard directshow)
** splitter : to decapsulate flv into audio / video
** audio/video decoder : you can quite safely relyon ffdshow for this one
To check it, start graphedit and try to play your file here : if it doesn't work, phonon won't be able to do it for you
Sorry, i don't know on other targets.
-
-
Thanks Guys.
The phonon backend is tempting, but installing all the goodies to make this work is a problem.
I think FFMpeg could be the best solution.
I've googled this : http://code.google.com/p/qtffmpegwrapper/
That's a good starting point but it does not seem to handle sound.
So now my question is more about sound. Do you think extracting video's sound and playing it through QAudioOutput is doable ? Is this such a huge task ? Should I implement OpenAL ?
B.A.
-
Can't say anything regarding the extraction, but you may face the problem of synchronization between video and audio.
-
Usually, to display video, the audio clock generates flow for audio and video.
If you go that way, you'll have to somehow be able to grab actual timestamping / clocking of your audio graph and then use that to synchronize your video playback : this isn't easy at all .
If you have no experience in video playback, it's fairly easy to get sunken into nightmare of audio clicks, unsynchronized playback, lags, frozen threads (video playback is usually massively multithreaded).
Having a look at QtMultimedia (I think it's in mobility now) might be a good idea as API are lower level than phonon, thus allowing potentially to grab / push data more easily.
My advice on this subject of video playback : don't underestimate the work to make such things work, at least, it's heavy, more often, it's just huge if you expect good quality (e.g. dropping frames if rendering graph / CPU not quick enough to ensure correct A/V synchro linked to QoS)
-
You may wish to take a look at "vlc-qt":http://sourceforge.net/p/vlc-qt/home/. That way vlc does all the heavy lifting for you.
-
Looks like this might help: http://www.videolan.org/press/lgpl-libvlc.html
-
This post is deleted!