[Libav-user] unsynchronous for H.264+AAC:

Kalileo kalileo at universalx.net
Mon Mar 26 13:01:36 CEST 2012


On Mar 26, 2012, at 16:11 , Li Zhang wrote:

> 
> 
> Is there anyone can give me some suggestion about the unsynchronous problem?
> 
> Best regards,
> 
> Li
> 
> ________________________________________
> From: libav-user-bounces at ffmpeg.org [libav-user-bounces at ffmpeg.org] On Behalf Of Li Zhang [lizhang at utelisys.com]
> Sent: Friday, March 23, 2012 5:44 PM
> To: libav-user at ffmpeg.org
> Subject: [Libav-user] unsynchronous for H.264+AAC:
> 
> Hi everyone,
> 
> I used ffmpeg to transcode mpeg2 TS to H264+AAC( into TS container) and send them to multicast address. Now I found that the video and audio are unsynchronous. The audio is later about 1 second than video. I have no idea what is the problem.
> 
> During the transcoding, I found video decoding(avcodec_decode_video2) will fail 7 times (which means got_picture_ptr returns 0).
> 
> While for the encoding, video encoding (avcodec_encode_video) will fail 50 times (which means out_size  less than 0) and it throws 50 frames. Actually, these 50 frames include 3 I frames. The 50th packets decoded is a P frame which is the 1st frame for successful encoding. After encoding this frame is I frame.
> 
> The audio encoding (avcodec_encode_audio2) will fail 3 times(which means got_packet is 0).
> 
> I do not know why they will fail. Especially, the I frame were ignored.
> 
> After these failures, the transcoding works normally except the unsynchronous problem.  Can anyone give me some suggestions? Is it possible these failure caused the unsynchronous? If you need more information, please let me know.
> 
> 

Hi Li,

as far as I know the DTS and PTS values of the audio and video frames are used to synchronize. You are not setting these values. For example, right before you write a packet you even use:

output_video_packet.dts = AV_NOPTS_VALUE;
and 
pkt.dts = AV_NOPTS_VALUE;

Therefore IMHO there is nothing left for any player to synchronize.

Then you do not use av_write_frame() but write_packet(), do you have a reason for that?

Regards,
Kalileo


More information about the Libav-user mailing list