I'm writing a video decoder (using FFMPEG/AVCodec) for a custom implementation of an mpeg4 video stream. The peculiarity of this video stream is that it could split into many "son" streams creating many P frames based on the same parent. The video stream I'm trying to decode is actually a sort of "video tree". Something like this:
I <--P <--P <---------------------P <-------------- P <------------ P
\ <--P <--P <--P \ <--P <--P \ <--P <--P
I've already wrote a basic decoder which works fine when I decide to follow one path, the problem is when I try to follow more than one path in the video tree. At this point I need to "fork" my decoder to follow two different video streams. the split could occur not only after a key frame, but even after a P frame, so I need to duplicate the AVCodecContext (I use avcodec_copy_context
) but it seems to create new decoder from a clean status.. it seems to ignore the previous video status, so the decoded P frames are "applied" to an empty video frame.
Probably copying the context using avcodec_copy_context
is not enough... Any suggestion? How can I duplicate the context and the complete status of the decoder?
Or, is there any other way to decode my stream using references?
Thanks!