[Libav-user] Visual corruption when decoding H264

Matthew Einhorn moiein2000 at gmail.com
Sun Jun 19 19:59:12 CEST 2011


On Sun, Jun 19, 2011 at 11:00 AM, Lovelett, Ryan A.
<RYAN.A.LOVELETT at saic.com> wrote:
>
>
>
> > I forgot to mention that I am using FFMPEG through OpenCV. Since an earlier
>
> > version of FFMPEG was giving problems while decoding H.264 based RTSP
>
> > stream, I updated to the latest FFMPEG version (recompiled it by self) and
>
> > it worked fine. Not sure if this serves your purpose.
>
> >
>
> > --
>
> > Regards,
>
> > Saurabh Gandhi
>
> >
>
> >
>
> >
>
> >
>
> >
>
> > On Thu, Jun 2, 2011 at 4:47 AM, STenyaK <stenyak at gmail.com> wrote:
>
> >
>
> >> Thanks for the reply.
>
> >>
>
> >> Apart from updating to latest ffmpeg version, did you do anything else
>
> >> for it to work? I'm still experiencing the same visual glitches.
>
> >>
>
> >> On Mon, May 30, 2011 at 11:53, Saurabh Gandhi <saurabhg84 at gmail.com>
>
> >> wrote:
>
> >> > Are you using the latest version of FFMPEG. We had similar issues here
>
> >> which
>
> >> > got resolved by updating to the latest version
>
> >> >
>
> >> > --
>
> >> > Regards,
>
> >> > Saurabh Gandhi
>
> >> >
>
> >> >
>
> >> >
>
> >> >
>
> >> > On Mon, May 30, 2011 at 2:30 AM, STenyaK <stenyak at gmail.com> wrote:
>
> >> >>
>
> >> >> Hello,
>
> >> >> I'm having troubles trying to decode H264 by feeding
>
> >> >> avcodec_decode_video with data coming from an RTP stream. I'm going to
>
> >> >> describe the visual result, maybe it can help find out where the
>
> >> >> problem lies:
>
> >> >>
>
> >> >> The image is perfect in the first frame of the stream. From that point
>
> >> >> on, it looks as if only p-frames got decoded: the image begins to get
>
> >> >> progressively more blurred with each frame whenever something in the
>
> >> >> image changes or moves position.
>
> >> >> Every 10-20 seconds of stream, the image starts a quick reconstruction
>
> >> >> process. the image gets corrected (visual trails removed) in a sweep
>
> >> >> from left to right that takes about half a second or two.
>
> >> >>
>
> >> >> Reading the same RTP stream with other software (also based on ffmpeg)
>
> >> >> works correctly, with no visual corruption at all, so I must be
>
> >> >> missing something.
>
> >> >>
>
> >> >> Does anyone have any idea what the problem could stem from? Any
>
> >> >> pointers are appreciated.
>
> >> >>
>
> >> >> Thanks in advance.
>
> >> >>
>
> >> >> --
>
> >> >> Saludos,
>
> >> >>      Bruno González
>
> >> >>
>
> >> >> _______________________________________________
>
> >> >> Jabber: stenyak AT gmail.com
>
> >> >> http://www.stenyak.com
>
> >> >> _______________________________________________
>
> >> >> 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
>
> >> >
>
> >> >
>
> >>
>
> >>
>
> >>
>
> >> --
>
> >> Saludos,
>
> >>      Bruno González
>
> >>
>
> >> _______________________________________________
>
> >> Jabber: stenyak AT gmail.com
>
> >> http://www.stenyak.com
>
> >> _______________________________________________
>
> >> 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
>
> >
>
> >
>
> Hi,
> I'm having the exact same issue as you when decoding x264 with the avcodec_decode_video2 function. I only get 1/3 of the frames, the video degrades progressively around the areas where motion occurs
>
>
>
> and then suddenly fixes itself and then slowly degrades again and so on.
> I was using the Jun 3 windows dlls built here:http://ffmpeg.zeranoe.com/builds/. I also posted this problem on the Zeranoe forum: http://ffmpeg.zeranoe.com/forum/viewtopic.php?f=15&t=54
>
>
>
> but it's pretty quiet over there. I have posted there some of the code I'm using to show the problem. In particular, from the log that gets logged when the code runs (posted over there)
> you'd see that the pts of the last packet is 1/3 of the duration. I thought that I was missing some operation after calling avcodec_decode_video2, but I guess the problem is something else.
>
> Thanks,
> Matt E
> Btw, sorry if the formatting comes out wrong because this is my first time posting to a mailing list.
>
> ________________________________
>
>
>
> Matt,
>
> My guess is that the frames that are working are the movie’s I frames, the ones that are degraded are the P frames. Or at least that is the case in my scenario. The codec that mine is having an issue with: CODEC_ID_H264 (H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10). Using build ffmpeg-git-39dbe9b from Zeranoe’s builds.
>
>
>
> I am having the same issue, only with seeking. That is to say, if I continuously decode ‘av_read_frame’ from start to finish the video decodes just fine. If I seek to a frame, and then decode the video quality degrades frame by frame.
>
>
>
> Suggestions welcome.
>
>
>
> _______________________________________________
> Libav-user mailing list
> Libav-user at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/libav-user
>

Ryan,
I tested it and I seem to get all three types of frames, i.e. I, P and
B (see below). However, I'd still think that these issues are all
related.


I updated my files to the the latest Zeranoe build (git-39dbe9b-win32)
and I also tested it on a ffmpeg libx264 encoded video
(git-39dbe9b-win32). It looks like the symptoms vary with the file I
test it on. When testing on a externally compressed file I get about
1/3 frames for h264 stored in avi container and about 1/2 frames when
stored in mp4 container just as described above. However, when testing
on the ffmpeg compressed file I get about 1/2 frames for both
containers, the pixelation goes away, i.e. the picture is always
sharp, but, I'm getting only half the frames.

A bit more info (for ffmpeg compressed file):
- In ffprobe fps is listed as 30 (and is correct), while I get 60
(i.e. time_base.num = 333333 and time_base.den = 20000000). For the
externally compressed file the frame rate is correct (i.e.
time_base.num = 100 and time_base.den = 2997).
- Reading the frame pict_type after passing into
avcodec_decode_video2, I see that the frames I'm getting are all three
types - i.e. I, P and B but it's overwhelmingly P. For the externally
compressed file it's about a even split between P and B.
- The duration of the video as given is 31499969 (is correct), but for
the mp4 container format the dts and pts of the last packet is
313666353 and 6187576 respectively, while for the avi it's 943 and
6201380, respectively (945 is the number of frames in the original
uncompressed video).
- Files play fine in ffplay.

I have a fuller log and example videos if that's helpful to anyone.

Thanks,
Matt E


More information about the Libav-user mailing list