[Libav-user] Fw: strange H264 audio sync behavior

Kalileo kalileo at universalx.net
Sat Jul 19 17:43:39 CEST 2014


On Jul 17, 2014, at 19:36 , Marco Sieber wrote:

> 
>> Are you manipulating the timebase and the DTS / PTS from the input before you give it to the encoding / muxing functions?
>> Are you passing the proposed DTS / PTS from the ffmpeg encoding functions to the muxer, or are you manipulating them in between?
> 
> Yes i adjust the timebase, i had to.. for some clips the timebase looked rly weird .. the Input Stream and InputCodecContex values, like 1/25000 for both stream and codec, i changed it for output 1/25 for codec and stream get changed to 1/90000, it was a trial&error attempt which made it feel better. But the decoding function still gets these 1/25000.

This is unclear to me:  "changed it for output 1/25 for codec and stream get changed to 1/90000"
Are you setting it now to 1/25 or to 1/90000 ?

Why don't you set all to 1/1000, the same value, then it's easy to see if audio and video DTS runs apart after a while.

> 
> But anyway, with the transcode example, there is the same problem and its only what its already does with time_base,pts and dts.
> I would guess that there is 1s up to 2s between audio and video when it starts to get out of sync.
> 
> In my own Transcoder i increment the frame pts with +1, each loop, for video and audio. And then rescaling it with av_rescale_q_rnd after encoding is done, so before i write the frames/packet i scale the pts/dts for that i use codeccontext timebase and stream timebase, tried other things too but didnt change anything. Thats all i do with pts/dts. And the pts/dts incrementation for video and audio doesn't look wrong to me.
> 
> +512 for video (0:00:00.040000) 25fps,90khz 
> +1024 for audio (or sometimes less), 48khz
> 
> And in ffprobe the incremntation is always the same... the only thing i noticed with ffprobe it starts with audio frames and the start time is different from the orginal source (1 audioframe length).
> 
> 
> 

When you check with ffprobe, do audio and video still have about the same (resulting) DTS/PTS after 5 minutes, or at the end of the movie? 

(it might be easier to compare if you use the same timebase for audio and video.)

And if that's ok then make sure there are no different values set for timebase or codec parameters in the single streams and in the container. I think that is what your problem is, why ffplay/VLC stays sync and QT not.


More information about the Libav-user mailing list