[FFmpeg-user] Unable to sync audio and video

Livio Tenze ltenze at gmail.com
Mon Feb 15 18:43:02 EET 2021


Dear group,

I am trying to write a code to encode (in realtime) a stream with audio and
video in Linux environment.
-The video source is read with av_read_frame and the /dev/videoX is opened.
The pts values with respect to the first packed seem to be reasonable.
-The audio source comes from alsa: here I see really strange behaviour. The
pts value of the second packet with respect to the first pts packet seems
to be "delayed" from 0.4s to 1.8s. I don't understand this behaviour: I
checked the time from start to the second packet and the elapsed time
cannot be justified (ms and not s).
-Finally, when I write audio and video in the output MP4 stream (I use
libx264 and libfdk_aac for video and audio respectively) the audio stream
is delayed.

I don't know what to check. Please give me suggestions to solve this issue.
What can I check?

Thanks in advance and best regards.
Livius


More information about the ffmpeg-user mailing list