[FFmpeg-devel] [PATCH] Fix stream copy

Michael Niedermayer michaelni
Mon Aug 13 13:27:30 CEST 2007


On Sun, Aug 12, 2007 at 08:35:16PM -0300, Ramiro Polla wrote:
> Hello,
> I see that FLV cut bug is still there. Now I can send a diff.
> copy.diff is what I believe is the correct fix. r_frame_rate has already 
> been calculated as the best frame rate, so there's no reason to try and 
> find it again in ffmpeg.c.

sounds all great, but isnt
yes r_frame_rate is our best guess on the real fundamental 1/timebase or
but that isnt exactly what we want here
heres some examples
1. lets assume theres a 2 hour video using timestamps in 1/1000 sec units
   the first hour has 25 fps, the second hour has 30fps
   r_frame_rate will be set to 25 fps, as thats the best guess from the
   little bit of the video lavf can look at
   normally ffmpeg would simply drop frames to convert the 30fps part to
   25fps but with stream copy it cant it fails fatally
2. lets assume again that we have a 2 hour video using timestamps in 1/1000
   sec units, now though the whole video is in 25 fps, well actually our
   guess was a little off, for some reason the file is actually 25.001 fps
   with normal encoding no problem a frame gets droped 3 times an hour
   but with stream copy again it fails fatally as we cannot drop frames
   (actually lavf will drop these 3 frames due to invalid timestamps and
   cause terrible artifacts in the following frames ...)

so please dont hack the timebase! it is and should be the input timebase
fix the code which fails dont feed to code with a wrong timebase because
it for some reason doesnt work with the correct one

> Index: ffmpeg.c
> ===================================================================
> --- ffmpeg.c	(revision 10080)
> +++ ffmpeg.c	(working copy)
> @@ -1862,7 +1862,7 @@
>              os = output_files[ost->file_index];
>              ist = ist_table[ost->source_index];
>              if(ost->st->codec->codec_type == CODEC_TYPE_VIDEO)
> -                opts = ost->sync_opts * av_q2d(ost->st->codec->time_base);
> +                opts = ost->st->pts.val * av_q2d(ost->st->time_base);

i dont know what you are trying to do but st->pts.val is deprecated so

Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

When the tyrant has disposed of foreign enemies by conquest or treaty, and
there is nothing more to fear from them, then he is always stirring up
some war or other, in order that the people may require a leader. -- Plato
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20070813/7dfffbcd/attachment.pgp>

More information about the ffmpeg-devel mailing list