[Ffmpeg-devel] [PATCH] a fix in ffmpeg.c

Limin Wang lance.lmwang
Fri Jan 19 04:16:52 CET 2007


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi Michael,

The real cause is video_sync_method is enable default, so if the h264
video pts isn't set with real value, ffmpeg.c:709 will get vdelta < -1.1,
and will cause some frames dropped. How about fixing it in utils.c?
Please review it.


Index: libavformat/utils.c
===================================================================
- --- libavformat/utils.c	(revision 7576)
+++ libavformat/utils.c	(working copy)
@@ -1985,6 +1985,11 @@
                     st->r_frame_rate.den = st->time_base.num;
                 }
             }
+            
+            /* update h264 video pts info with real rate */
+            if(st->codec->codec_id == CODEC_ID_H264 ) {
+                av_set_pts_info(st, 64, st->r_frame_rate.num, st->r_frame_rate.den);
+            }
         }
     }
 


Thanks,
Limin

* Michael Niedermayer <michaelni at gmx.at> [2007-01-18 15:01:18 +0100]:

> Hi
> 
> On Thu, Jan 18, 2007 at 03:34:52PM +0800, Limin Wang wrote:
> > Hi developer,
> > 
> > When I decode a h264 file by using ffmpeg, it can't decode all frame as my
> > expect(300frame in total, it decode 180 frame only).
> > 
> > lmwang at laptop:~/yuvad/open/h264/ffmpeg$ ./ffmpeg -f h264 -i
> > /tmp/akiyo_cif.h264 /tmp/akiyo_cif.yuv
> > FFmpeg version SVN-r7430, Copyright (c) 2000-2006 Fabrice Bellard, et al.
> >   configuration:  --enable-gpl --enable-x264
> >   libavutil version: 49.1.0
> >   libavcodec version: 51.28.0
> >   libavformat version: 51.7.0
> >   built on Jan 18 2007 15:28:56, gcc: 4.1.2 20061115 (prerelease) (Debian
> >   4.1.1-21)
> > Input #0, h264, from '/tmp/akiyo_cif.h264':
> >   Duration: N/A, bitrate: N/A
> >   Stream #0.0: Video: h264, yuv420p, 352x288, 15.00 fps(r)
> > File '/tmp/akiyo_cif.yuv' already exists. Overwrite ? [y/N] y
> > Output #0, rawvideo, to '/tmp/akiyo_cif.yuv':
> >   Stream #0.0: Video: rawvideo, yuv420p, 352x288, q=2-31, 200 kb/s, 15.00
> >   fps(c)
> > Stream mapping:
> >   Stream #0.0 -> #0.0
> > Press [q] to stop encoding
> > frame=  180 q=0.0 Lsize=   26730kB time=12.0 bitrate=18247.7kbits/s
> > video:26730kB audio:0kB global headers:0kB muxing overhead 0.000000%
> > lmwang at laptop:~/yuvad/open/h264/ffmpeg$   
> > 
> > 
> > After investigated , I found out it's caused by pts is set by default
> > fps(25). Below is my fix, please review it.
> > 
> > Thanks,
> > Limin
> > 
> > 
> > Index: ffmpeg.c
> > ===================================================================
> > --- ffmpeg.c	(revision 7430)
> > +++ ffmpeg.c	(working copy)
> > @@ -2667,6 +2667,9 @@
> >              frame_rate      = rfps;
> >              frame_rate_base = rfps_base;
> >  
> > +            /* need update stream pts info also */
> > +            av_set_pts_info(ic->streams[i], 64, frame_rate_base, frame_rate );
> 
> rejected
> the user application cannot just mess with the internal input timebase
> 
> [...]
> -- 
> Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
> 
> Democracy is the form of government in which you can choose your dictator



> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at mplayerhq.hu
> http://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-devel
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iQEVAwUBRbA4JEztbf7dKiuoAQKargf9E+u9TBqaYVfR6Oyaqbd/JKT2yqLRac80
R1XsDGiLlx4Q6AYYj2v/26g/jjrcJg/F/1Oq7jJ6mYgBES1PJABPRHQ1qISz6PHv
fS892Jt+TYResgk2nNt4VxwwpdQVKyRJYvWk+C064LXdnOsyyNnA0gO7rnK6Rnab
X0hLUJbDlWU2t5XGudPA6XKmgE+fPr5Qvsu7zouUXru3enYMPQoneuwgxd12UFQX
hJkFZJ/cCma4mQt4MNhuxoRfPF7cO3Ntgnlhp6ov3PKofFRgv9fRbU9ljiuVkRcZ
M9BrJKv1QuBWxu7NCXa1d7kHZVc9w2tbBP9W9NcRYuZM0/mXOtMZYw==
=Awcr
-----END PGP SIGNATURE-----




More information about the ffmpeg-devel mailing list