[FFmpeg-devel] [PATCH] Enable parser in FLV demuxer for H264 codec

Alex Sukhanov alx.sukhanov at gmail.com
Fri Dec 13 04:37:08 CET 2013


On Thu, Dec 12, 2013 at 6:09 PM, Michael Niedermayer <michaelni at gmx.at>wrote:

> On Thu, Dec 12, 2013 at 03:10:10PM -0800, Alex Sukhanov wrote:
> > ---
> >  libavformat/flvdec.c | 1 +
> >  1 file changed, 1 insertion(+)
> >
> > diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c
> > index 1024001..4401652 100644
> > --- a/libavformat/flvdec.c
> > +++ b/libavformat/flvdec.c
> > @@ -256,6 +256,7 @@ static int flv_set_video_codec(AVFormatContext *s,
> AVStream *vstream,
> >          return 1;     // 1 byte body size adjustment for
> flv_read_packet()
> >      case FLV_CODECID_H264:
> >          vcodec->codec_id = AV_CODEC_ID_H264;
> > +        vstream->need_parsing = AVSTREAM_PARSE_HEADERS;
> >          return 3;     // not 4, reading packet type will consume one
> byte
> >      case FLV_CODECID_MPEG4:
> >          vcodec->codec_id = AV_CODEC_ID_MPEG4;
>
> breaks
> ffmpeg -i Enigma_Principles_of_Lust.flv test.flv
>
> before the patch:
> frame= 6300 fps=1441 q=31.0 Lsize=    7266kB time=00:03:30.65 bitrate=
> 282.6kbits/s
> after the patch
> frame= 4531 fps=1180 q=9.8 Lsize=    6987kB time=00:03:30.65 bitrate=
> 271.7kbits/s dup=0 drop=1769
>
> [....]
>
> --
> Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> The misfortune of the wise is better than the prosperity of the fool.
> -- Epicurus
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
>

Hi Michael,

I tested ffmpeg with and without my patch on following video:

Input #0, flv, from '/home/asukhanov/Work/clips/flv/gangman.flv':
  Metadata:
    encoder         : Google
  Duration: 00:04:12.31, start: 0.000000, bitrate: 887 kb/s
    Stream #0:0: Video: h264 (Main), yuv420p, 640x360, 24.42 fps, 23.98
tbr, 1k tbn, 47.95 tbc
    Stream #0:1: Audio: aac, 44100 Hz, stereo, fltp, 128 kb/s

Which is just a first video I grabbed:
http://www.youtube.com/watch?v=9bZkp7q19f0

My results are:

before:
*frame= 6046 fps=418 q=31.0 Lsize=   18328kB time=00:04:12.31 bitrate=
595.1kbits/s    *
video:14139kB audio:3943kB subtitle:0 global headers:0kB muxing overhead
1.358910%

after:
*frame= 6046 fps=416 q=31.0 Lsize=   18328kB time=00:04:12.31 bitrate=
595.1kbits/s  *
video:14139kB audio:3943kB subtitle:0 global headers:0kB muxing overhead
1.358910%

Configuration:
./configure --enable-gpl --enable-libass --enable-libfaac
--enable-libfdk-aac --enable-libmp3lame   --enable-libopencore-amrnb
--enable-libopencore-amrwb --enable-librtmp --enable-libtheora
--enable-libvorbis --enable-x11grab --enable-libx264 --enable-nonfree
--enable-version3


May I ask you to share your FLV file with me, or verify that you ran the
same command line - probably it was not the same in your case, because
quantizer is different in your case: 31 vs 9 That could affect FPS much
more seriously than parsing headers in Demuxer.

Thank you


More information about the ffmpeg-devel mailing list