[Ffmpeg-devel] [Ffmpeg-devel-old] Re: avi out is buggy

Michel Bardiaux mbardiaux
Mon May 9 15:27:08 CEST 2005

Wolfram Gloger wrote:
> Hi,
>>Since the posted commands produce a desynched avi from a file that is 
>>said to play correctly in mplayer, one could deduce that the streams in 
>>it are not inherently synchronized, but the synchro is maintained by the 
>>timestamps themselves; in other words, as Michael wrote, at places there 
>>are too many or not enough audio samples. Obviously that cant be done if 
> Indeed.
>>But if the audio is decoded then re-encoded, then ffmpeg 
>>*should* be able to produce well-synchronized raw elementary streams at 
>>the intermediate stage (after decoding, before encoding) or else the A/V 
>>synch code is buggy.
> Yes, and this does in fact work with "-async 1" (or perhaps higher,
> "-async 50".  I have used this successfully.

Unfortunately, -async is completely undocumented...

>>What it does exactly is not 100% clear from the 
>>source, ffmpeg.c does not seem to make up its mind clearly whether 
>>timestamps or rate-times-count hold the truth. That is, the intermediate 
>>stage itself is not a well-specified format, the input and output 
>>formats contaminate it.
> I do not see what you mean here -- the "intermediate stage" is raw
> data frames (16bit per channel for audio, AFAICS), but for
> synchronization purposes _only_ the timestamps hold the truth (also
> Regards,
> Wolfram.
Ah, but *which* timestamps? The intermediate stage should have its own 
timestamps (maybe it does; ffmpeg.c is 4000+ lines long!) But there is 
currently no option to specify where the intermediate timestamps should 
come from. In an MPEG source (e.g.) they could come from PTS in the 
system stream; for the video stream they could come from the timecode; 
and sometimes (if the timestamps are not reliable maybe because the file 
is a concatenation of files, or if the input is raw) you want to rely on 
frame rate and frame count. What you do will depend on the file, but 
right now there is no way to control effectively what ffmpeg does; 
rather, it tries to 'automagically' do whatever is right, with the 
result that it is never 100% right, and sometimes horribly wrong.

Michel Bardiaux
Peaktime Belgium S.A.  Bd. du Souverain, 191  B-1160 Bruxelles
Tel : +32 2 790.29.41

More information about the ffmpeg-devel mailing list