[FFmpeg-user] Unsynced audio while recording from several sources

Valeriy Shevchuk shevchuk.valery at gmail.com
Tue Apr 4 19:34:01 EEST 2017


Hello, everyone.
I'm trying to use FFmpeg to record video and 3 audio sources and use it to
generate 3 different video files - each file should contain the same video
stream but the different audio stream. The problem is that I got audio sync
issues. The first audio stream is synced perfectly, but the second one has
1 sec lag, and the third one has like 2 sec lag.

I've made a few tests so far and it seems that root cause of the issue is
initialization time of video/audio devices. So, one device is already
recording something but the second is still being opened and so on. I've
tried to change input devices order and after that audio streams still have
the same issue BUT if before 2nd and 3rd audio streams were some time ahead
of video, after reordering they became to lag after the audio (audio for
the same event appears with some delay). So this test confirms my version
about device initialization times.

But the question still, why the first audio stream is synchronized
properly, while other 2 are not. and also, how could I overcome this
issues? Any workarounds and ideas are highly appreciated.

Here is FFmpeg command I'm using and it's output.

ffmpeg.exe -f dshow -video_size 1920x1080 -i video="Logitech HD Webcam
> C615"  -f dshow -i audio="Microphone (HD Webcam C615)" -f dshow -i
> audio="Microphone Array (Realtek High Definition Audio)"
> -filter_complex "[1:a]volume=1[a1];[2:a]volume=1[a2]" -vf
> scale=h=1080:force_original_aspect_ratio=decrease -vcodec libx264
> -pix_fmt yuv420p -crf 23 -preset ultrafast -acodec aac -vbr 5 -threads 0
> -map v:0 -map [a1] -map [a2] -f tee
> "[select=\'v,a:0\']C:/Users/vshevchu/Desktop/123/111/111_jjj1.avi|
> [select=\'v,a:1\']C:/Users/vshevchu/Desktop/123/111/111_jjj2.avi"


Here is the output:
https://pastebin.com/A3FL05My

PS. Actually, the issue is exactly the same when I'm not using "tee" muxer
but writing all the audio streams to one container. So, "tee" isn't a
suspect.


More information about the ffmpeg-user mailing list