Hi,
Thank you for your reply.

Yes, I agree with what you said. But I do not know how to compute the dts 
exactly.  I just let the muxer add that for me. But I do not know if muxer did 
that.

I tried just now that starting the audio transcoding when the first video 
transcoding was succeeded. Then the audio was earlier than video. So, 
obviously, the failed video transcoding (50 frames) influenced the 
synchronising. The video and audio almost synchronous when I started to 
transcode the audio after the 9th video frame transcoding failed. So do you 
have any idea about this?

I have another question about the frame rate. I configured video encoder's 
AVCodecContext->time_base->den= 25. I think the final video frame rate should 
be 25frames per second. But when I check that using VLC, it was 50. I do not 
know why.


Best regards,

Li


________________________________________
From: [email protected] [[email protected]] On Behalf 
Of Kalileo [[email protected]]
Sent: Monday, March 26, 2012 1:01 PM
To: This list is about using libavcodec, libavformat, libavutil,        
libavdevice and libavfilter.
Subject: Re: [Libav-user] unsynchronous for H.264+AAC:

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: [email protected] [[email protected]] On Behalf 
> Of Li Zhang [[email protected]]
> Sent: Friday, March 23, 2012 5:44 PM
> To: [email protected]
> 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
_______________________________________________
Libav-user mailing list
[email protected]
http://ffmpeg.org/mailman/listinfo/libav-user
_______________________________________________
Libav-user mailing list
[email protected]
http://ffmpeg.org/mailman/listinfo/libav-user

Reply via email to