[Libav-user] Some encoding A/V synchronization questions
ulfalizer at gmail.com
Thu Nov 14 04:40:01 CET 2013
I'm adding a movie recording feature to an emulator using libav. I've
got video (x264), audio (Android VisualON AAC), and muxing (mp4)
working, but since I make no special efforts to keep audio and video
synchronized, they desynchronize after a few minutes. My questions are
1. I believe I will need to derive PTS values for the audio and video
streams, diff them, and compensate by e.g. changing the audio
resampling rate when they drift apart. For audio, the PTS values from
the AVStream seem reliable, but not for video (they seem to lag
behind, perhaps due to buffering (?)). Is it safe to simply use the
PTS values I write into the AVFrame for video frames? Is there some
other field I could use?
2. Why does ffmpeg.c assign DTS values to PTS values in some locations, e.g.
ist->next_pts = ist->pts = av_rescale_q(pkt->dts, ist->st->time_base,
3. Is there some simpler solution specific to x264/AAC/mp4?
More information about the Libav-user