[Libav-user] MPEG2 decoding pixelation problem (but not in ffplay)
Michael Goffioul
michael.goffioul at gmail.com
Tue Jun 6 23:56:10 EEST 2017
Hi Jaka,
Thanks for your answer. Even though I'm segmenting the data on 0x00 0x00
0x01 0x00, I'm still feeding the entire data between those boundaries to
the decoder. So I'm not skipping any data from the stream. Referencing my
sample code: p1 points to the current picture start code, p2 points to the
next picture start code, feed data between p1 and p2, p1 = p2, restart.
Is there a particular way to segment the data that is expected by the
mpeg2video decoder?
Michael.
On Tue, Jun 6, 2017 at 4:42 PM, Jaka Bac <jakabac at gmail.com> wrote:
> Hi Michael,
>
> You are parsing the mpeg2 stream by yourself looking for the 0x00 0x00
> 0x01 0x00 startcode which means that you will only feed the mpeg2 encoded
> pictures to the decoder.
> This way your program will skip over the sequence headers which may
> include a lot of important information for the mpeg2 decoder (for example
> custom intra and non intra quantiser matrices, picture dimensions, aspect
> ratio,...)
>
> The ffmpeg mpeg2video codec will try its best to decode the pictures, but
> with the missing info it may not be fully successful.
> Your PussInBoots file for example, includes custom quantiser matrices
> which are probably slightly different from the default ones (I did not look
> in detail).
>
> My suggestion would be to use libavformat to read the source files. This
> way you would get correctly parsed AVPacket(s).
>
> If you for some reason can't use libavformat, you could at least
> use av_parser_parse2 function to parse the stream for you. (See example
> here: https://www.ffmpeg.org/doxygen/trunk/decode_video_8c-example.html)
>
> Hope that helps,
> Jaka
>
> On 4 June 2017 at 05:12, Michael Goffioul <michael.goffioul at gmail.com>
> wrote:
>
>> Hi,
>>
>> I'm trying to use ffmpeg to decode a MPEG2 stream and I'm running into
>> pixelation problem with some streams (not all of them). The fact is that
>> the problematic streams play fine in ffplay (or vlc), so I figured the
>> problem must be in the way I setup the decoder or feed data to it.
>>
>> I've written a very simple code to illustrate the problem I'm having,
>> it's available here:
>> https://drive.google.com/open?id=0BwljeX6541LuTjlLRmN2bG52M3M
>>
>> It doesn't do anything fancy: just initialize the mpeg2video codec, feed
>> the data (segmented on the picture start code boundary), drain frames,
>> convert to RGB and save as PNG. It accepts 2 arguments: the elementary
>> MPEG2 stream filename and the number of frames to extract.
>>
>> I'm using this sample clip as test case, it's the elementary video stream
>> extracted from a MPEG/TS clip (next link):
>> https://drive.google.com/open?id=0BwljeX6541LuUFFHSElwaUFGYkE
>> https://drive.google.com/open?id=0BwljeX6541LuamdieXZzamNkNFE
>>
>> The pixelation problem is illustrated in this extracted frame:
>> https://drive.google.com/open?id=0BwljeX6541LubmhkS2VWekc5S00
>>
>> By comparison, playing the sample clip (elementary stream) with ffplay
>> gives this:
>> https://drive.google.com/open?id=0BwljeX6541LuQ0hHQmVZMlAxMmc
>>
>> Clearly I must be doing something wrong. Does anybody have a hint or
>> suggestion?
>>
>> Thanks,
>> Michael.
>>
>>
>> _______________________________________________
>> Libav-user mailing list
>> Libav-user at ffmpeg.org
>> http://ffmpeg.org/mailman/listinfo/libav-user
>>
>>
>
> _______________________________________________
> Libav-user mailing list
> Libav-user at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/libav-user
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20170606/39194a56/attachment.html>
More information about the Libav-user
mailing list