[FFmpeg-devel] [PATCH] Enable parser in FLV demuxer for H264 codec
Alex Sukhanov
alx.sukhanov at gmail.com
Sun Dec 15 07:22:08 CET 2013
On Sat, Dec 14, 2013 at 8:02 PM, Michael Niedermayer <michaelni at gmx.at>wrote:
> On Sat, Dec 14, 2013 at 06:11:22PM -0800, Alex Sukhanov wrote:
> > On Fri, Dec 13, 2013 at 5:51 PM, Michael Niedermayer <michaelni at gmx.at
> >wrote:
> >
> > > On Fri, Dec 13, 2013 at 10:50:47AM -0800, Alex Sukhanov wrote:
> > > > On Thu, Dec 12, 2013 at 7:37 PM, Alex Sukhanov <
> alx.sukhanov at gmail.com
> > > >wrote:
> > > >
> > > > >
> > > > >
> > > > >
> > > > > 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
> > > > >
> > > >
> > > >
> > > > Hi Michael,
> > > >
> > > > Sorry, yesterday I missed that you sent me your FLV file. Thanks a
> lot
> > > for
> > > > it.
> > > > I tried to play it with ffplay and mplayer and it seems to me source
> file
> > > > is corrupted:
> > > >
> > > > [h264 @ 0x7f2cf01a30a0] AVC: nal size 21839893
> > > > Last message repeated 1 times
> > > > [h264 @ 0x7f2cf01a30a0] no frame!
> > > > [h264 @ 0x7f2cf01a30a0] AVC: nal size 2771 1KB sq= 0B f=0/52
> > > > Last message repeated 1 times
> > > > [h264 @ 0x7f2cf01a30a0] no frame!
> > > > 20.71 A-V: 0.038 fd= 5 aq= 0KB vq= 0KB sq= 0B f=0/55
> > > >
> > > > Both players play first 10 seconds of video and then just stuck.
> > >
> > > its only part of the file, sufficient to reproduce the problem
> > >
> > >
> > > >
> > > > But I also tried to transcode it with and without my patch:
> > > >
> > > > before:
> > > > frame= 350 fps=0.0 q=17.2 Lsize= 590kB time=00:00:11.74 bitrate=
> > > > 411.2kbits/s
> > > > video:485kB audio:92kB subtitle:0 global headers:0kB muxing overhead
> > > > 2.279257%
> > > >
> > > > after:
> > > > frame= 295 fps=0.0 q=18.1 Lsize= 539kB time=00:00:11.70 bitrate=
> > > > 377.3kbits/s dup=0 drop=55
> > > > video:435kB audio:92kB subtitle:0 global headers:0kB muxing overhead
> > > > 2.331014%
> > > >
> > > >
> > > > My opinion is that it's safe to apply this patch. What do you think?
> > >
> > > I think that the patch must not cause regressions before it can be
> > > considered for git master
> > >
> > > [...]
> > >
> > > --
> > > Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
> > >
> > > The bravest are surely those who have the clearest vision
> > > of what is before them, glory and danger alike, and yet
> > > notwithstanding go out to meet it. -- Thucydides
> > >
> > > _______________________________________________
> > > ffmpeg-devel mailing list
> > > ffmpeg-devel at ffmpeg.org
> > > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> > >
> > >
> > Hi Michael,
> >
> >
> > I understand and I agree. Moreover, I tried to transmux your file
> FLV->FLV
> > (-vcodec copy -acodec copy) and with my patch Transmuxing doesn't work:
> >
> > [flv @ 0x2976680] pts (0) < dts (33) in stream 0
> > av_interleaved_write_frame(): Invalid argument
> >
> > Your file is broken itself and some of timestamps are invalid, but let's
> > drop my patch, because influence on regression is too high.
> > Anyway, thanks for your time and quick replies.
>
> issue fixed
>
> [...]
> --
> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> Good people do not need laws to tell them to act responsibly, while bad
> people will find a way around the laws. -- Plato
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
>
Cool, thank you!
More information about the ffmpeg-devel
mailing list