[FFmpeg-devel] Two problems with MPEG2 decoder

Joseph Artsimovich joseph at mirriad.com
Tue Feb 26 20:18:00 CET 2013


On 26/02/2013 18:40, Michael Niedermayer wrote:
> ...
> fixed
> the is_d10 variable could be renamed now though ...
Thanks.

>> 2. One of the frames fails to decode.
>> The frame in question is frame 16 (counting from 0, ignoring the
>> edit list and 2 initial B-frames that can't be decoded as the stream
>> is open GOP).
>> If you use ffmpeg to convert the file to another format:
>> ffmpeg -i segment.mov -an -vcodec qtrle out.mov
>> You'll get a duplicated frame in positions 16 and 17.
>> Now, it turns out the frame that fails to decode has a redundant
>> (and probably invalid) second picture header in MPEG2 stream. That
>> is, the frame is encoded as a single picture, yet it has 2 picture
>> headers. If I modify the code to ignore the second picture header,
>> like this:
>>          case PICTURE_START_CODE:
>> +            if (picture_start_code_seen) {
>> +               break;
>> +            } else {
>> +               picture_start_code_seen = 1;
>> +            }
>> [in decode_chunks() in mpeg12.c; variable initialization not shown]
>> Then the frame in question decodes fine.
>> The code above is again just a hack, as a frame can be encoded with
>> more than one pictures.
> is it just one frame in the video or does the original full video
> have more with this issue ?
The original file of about 45min had somewhere between 5 and 10 of 
frames like that. Sure, those frames may be technically broken, but I 
believe we should try to handle them anyway, because:
1. Other software does handle them. The original file came from a 
broadcaster, so I expect a wide range of software and hardware being 
able to handle them.
2. Currently the failure to decode such a frame doesn't get reported 
through the API. When I use the CLI ffmpeg executable to convert such a 
file, I get a duplicated frame. When I use FFMpeg's C API (through 
libquicktime in this case), I get a frame shift, which is even worse. If 
for one or another reason it's not possible to decode such a frame, I'd 
like to get an error back, at least.

-- 
Joseph Artsimovich
Senior C++ Applications Developer
MirriAd Ltd



More information about the ffmpeg-devel mailing list