[FFmpeg-user] audio video sync and drift

John Smith localdevjs at gmail.com
Sat May 5 19:37:49 EEST 2018

> > So is there anything I can do or change, to get this to work? Is there no
> > way to record audio and video from different sources, and just use "wall
> > time" or "time elapsed since executing ffmpeg" to sync up the audio /
> > video?
> You can try to use wallclock time for the network input, v4l
> already uses wallclock timestamps.
Thanks Carl; I switched my project to use pulse audio everywhere (instead
of alsa) and now it appears that the audio from pulse and video from v4l
stays in sync. I didn't force pulse to use wallclock, I just told it to use
pulse for audio and now it seems to stay in sync. So I'm not 100% sure what
"wallclock" is compared to "non wallclock"; but in this case v4l and pulse
are in sync now.

However, I would really like to know if there is anything I can do to make
"tcp" stay in sync as well? So here was the old command (pre switchover to

ffmpeg -y -f video4linux2 -pix_fmt yuv420p -framerate 25 -i /dev/video1 \
    -f s16le -ar 44100 -ac 2 -i tcp://localhost:55555 \
    -ar 44100 -af "aresample=async=1000" -c:v libx264 -vf
"fps=25,format=yuv420p" -g 60 -crf 23 -preset superfast /data/
13202a7ec918dd43e280a9aeb7063f01.mp4 \
    -ar 44100 /data/13202a7ec918dd43e280a9aeb7063f01.mp3

I don't see anything on the ffmpeg website that shows how to use "s16le" /
"tcp" (I must have found that example on the net long time ago), and
certainly nothing that would suggest how to make it use wallclock time?

Kind of lost here. I _can_ use pulse, but the problem with that is that I
lose my ability to mix audio in my project, since now the recording and
streaming only comes from one source in pulse audio; with tcp, I can load
up 5 audio sources into my project, mix them as needed, then send the final
output to tcp where ffmpeg is listening and recording audio.

Thanks for your help!

More information about the ffmpeg-user mailing list