[FFmpeg-devel] Translating 1080i HD, from h264 to mpeg2-hd is buggy.

wallak at free.fr wallak
Sat Oct 3 16:57:51 CEST 2009


Thanks for the advices. I've tried the patch below, with ffmpeg release 20151
available this week . It works properly on my configuration. The low_delay is
not fixed here. But this patch may be a first step, and it is required, if we
want a proper behavior.

--- ffmpeg-r20151/libavformat/utils.c   2009-10-01 23:12:42.000000000 +0200
+++ ffmpeg-r20151/libavformat/utils.c   2009-10-01 22:34:54.000000000 +0200
@@ -770,7 +770,7 @@
     int num, den, presentation_delayed, delay, i;
     int64_t offset;

-    if (pc && pc->pict_type == FF_B_TYPE)
+    if (st->codec->codec_id != CODEC_ID_H264 && pc && pc->pict_type ==
FF_B_TYPE)
         st->codec->has_b_frames = 1;

     /* do we have a video B-frame ? */



Best Regards,
Wallak.

Quoting Michael Niedermayer <michaelni at gmx.at>:

> On Fri, Oct 02, 2009 at 12:34:37AM +0200, wallak at free.fr wrote:
> >
> > I've tried to encode some HD streams to 1080i MPEG2-HD, with the following
> > command, but that failed with bad video artifacts, using the last ffmpeg
> git
> > release:
> >
> > ffmpeg -i h264hd-test.ts -r 25 -vsync 2 -top 1 -fflags genpts -packetsize
> 2048
> > -g 15 -qmin 1 -qmax 31 \
> > -vcodec mpeg2video -vb 20000kb -minrate 800kb -maxrate 25000kb -bufsize
> > $[(512)*8]kb -flags +ildct+ilme -bf 2    -acodec mp2  -ab 192kb -ar 48000
> -ac 2
> > \
> > -f mpegts -y output--mpeg2hd.ts
> >
> > After some tests, I found that, the conversion failed to work after the
> release
> > 19147 . When I apply the 19146 to 19147 release patch back,  I get a
> compliant
> > MPEG2-HD output.
>
> 19147 contains 2 bugs
> first, its wrong for h.264, h264 allows b frames without requireing a >=1
> sized buffer, silly but it cant be helped, a != H264 check is needed in there
> second, low_delay must be set to 0 when has_b_frames is set to 1 otherwise
> variables are inconsistent
> i dont know if these are the only 2 issues but as the condition would no
> longer trigger for h264 they should fix this bug
>
> patches fixing above are welcome
>
> [...]
> --
> Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> Its not that you shouldnt use gotos but rather that you should write
> readable code and code with gotos often but not always is less readable
>





More information about the ffmpeg-devel mailing list