[FFmpeg-devel] [PATCH] fix stream copy

Maksym Veremeyenko verem
Thu Jan 14 08:31:17 CET 2010

Baptiste Coudurier ???????(??):
> On 01/13/2010 07:09 AM, Maksym Veremeyenko wrote:
>> Hi,
>> During cutting some MOV files i found strange behavior with number of
>> frames copied to new file. The problems come from wrong codec->timebase
>> value that is guessed from stream->time_base. For MOV stream->time_base
>> is setted from time_scale that could be 25, 60, 6000, 2997 values - as
>> result stream->time_base will have a values 1/25, 1/600, 1/2997 (i have
>> such sample). That cause codec->timebase been set to that values later:
> This value is a time base like its name indicate, not a frame rate.
> However, the fps value is right if you notice as is the tbr (r_frame_rate).
My patch is looks like a hack but that was attempt to save correct 
values of codec->timebase. For MOV context there is also information 
from stts about durations of frame/chunk in stream->time_base units that 
is not inherited to codec->time_base

May be i am wrong but for AVCodecContext.time_base field it said:
      * - encoding: MUST be set by user.
      * - decoding: Set by libavcodec.
but i did not found that at least DV codec updates codec->time_base on 
decoding process or in a . It seems to me that codec->time_base been 
defaulted to stream->timebase later:

int av_find_stream_info(AVFormatContext *ic)
                 st->codec->time_base= st->time_base;

and later codec->time_base been updated more...

> Did you check the code stopping the copy instead ?
I not sure i clear understand *code stopping the copy*, could you clarify?

Maksym Veremeyenko

More information about the ffmpeg-devel mailing list