[FFmpeg-user] Stuck on adelay/amix sync problem..

Mark Corner mcorner at gmail.com
Tue Dec 19 04:31:18 EET 2017


I am having trouble with amix producing different results with different
input orders and only one input to amix staying in sync with the video.

I am starting with three video and three audio files, vp8 and opus
encoded.  There is a video and audio that go together and are about  32
minutes long.  Then there are two pairs of audio and video, each about 16
minutes long.

First I combine the three videos using an overlay:
ffmpeg -y -itsoffset 0 -i
/tmp/RM359a097bf459c327e34954525862d2b7/RTd9075ac090a32a21e71269e6b08f4053-reproces
sed.mkv -itsoffset 2.364 -i
/tmp/RM359a097bf459c327e34954525862d2b7/RT21a59c19d91a7644b8c76d3fd12c3b32-reproc
essed.mkv -itsoffset 983.503 -i
/tmp/RM359a097bf459c327e34954525862d2b7/RT4d34aa2bae28a73f8079a6e1b65b3aa4-re
processed.mkv  -filter_complex
"[0]pad=iw*2:ih[t0];[t0][1]overlay=W/2:0[t1];[t1][2]overlay=0:0[t2]" -map
[t2]
 -an -c:v libvpx -crf 23 -b:v 1M -cpu-used 3 -threads 8
/tmp/RM359a097bf459c327e34954525862d2b7/output_video.
webm

That works fine.

Then I combine the audio (this is where the problem is):
ffmpeg -y -i
/tmp/RM359a097bf459c327e34954525862d2b7/RT2568dcb62e48c44c4ac61094c4377553
-i /tmp/RM359a097bf45
9c327e34954525862d2b7/RTb5d9c3c0a59e98061159ddb310587b71 -i
/tmp/RM359a097bf459c327e34954525862d2b7/RT955f8ed
764b5fda55a4dcd23cfed673d  -filter_complex
"[0]adelay=25|25[t0];[1]adelay=2363|2363[t1];[2]adelay=983525|9835
25[t2];[t2][t1][t0]amix=inputs=3" -strict -2 -c:a libopus
/tmp/RM359a097bf459c327e34954525862d2b7/output_audi
o.mka

And then merge the audio and video together:
ffmpeg -y -i /tmp/RM359a097bf459c327e34954525862d2b7/output_audio.mka -i
/tmp/RM359a097bf459c327e34954525862d2b7/output_video.webm -c:v copy -c:a
copy /tmp/RM359a097bf459c327e34954525862d2b7/full.webm

The problem is that the audio and video are only in sync for what ever is
first in the amix filter….  So in the above example, the t2 audio input
will be in sync, but not the t1 or t0.  If I change the order to something
like [t1][t2][t0], then the t1 audio is in sync, but none of the others.
In fact the length of the output_audio.mka will differ based on the order
of inputs to amix….  As far as I understand, the order to amix shouldn’t
matter at all.

Thanks for any advice you can offer.


More information about the ffmpeg-user mailing list