I need to play a custom AVI file containing a classic video stream, an audio stream , as well as a user data stream .
A user stream contains data that is rendered using some custom widgets; these widgets only need to have each user frame written to the buffer at the right time.
Our application is based on Qt and already uses QMediaPlayer / QVideoWidget to play traditional videos, but an additional user stream complicates the work because AFAIK QMediaPlayer only plays video / audio and ignores everything else.
I would like to avoid reusing all of qt-multimedia , but I'm not sure how to do my best from the available Qt classes.
My ideas so far:
Create your own media player that demultiplexes and decodes video using ffmpeg , implements synchronization, uses QAudioOutput to play audio, creates a QVideoFrame stream to play on video and write user data to some buffer for visualization.
Problem . To avoid writing code for scaling / converting video frames, I would like to reuse QVideoWidget , but it seems to work only with the βrealβ QMediaPlayer .
Demux input file and QMediaPlayer channel with AV streams. Demux type ffmpeg (possibly leaving decoding to the Qt backend), ask QIODevice to extract only the video / audio streams from the input file, and the other to receive the data stream. Play video / audio using QMediaPlayer .
+-------+ | QFile | +---^---+ | inherits | +--------------------+ | MyAviDemuxer | | | | holds a queue of | | demuxed packets | +--------------------+ | | readDataPacket readVideoPacket | | +-------v--------+ +--------v-----------+ +-----------+ | MyCustomReader | | MyVideoAudioStream +--inherits--> QIODevice | +----------------+ +--------+-----------+ +-----------+ | setMedia | +-------v-------+ | QMediaPlayer | +---------------+
Problem : synchronize data stream synchronization with QMediaPlayer , process headers and metadata correctly.
I am a bit prone to option 1, just because it gives me more control, but I wonder if I missed a simpler solution (even for Windows).
c ++ qt ffmpeg qtmultimedia
sababbi May 02 '15 at 17:30 2015-05-02 17:30
source share