[FFmpeg-user] Audio out of sync after video concatenation

Michael Koch astroelectronic at t-online.de
Tue Jun 22 13:31:33 EEST 2021


Am 22.06.2021 um 12:14 schrieb iburman at compuscience.com:
> I concatenate 3 videos as below:
>
>   
>
> Video 1 - 13 seconds with audio
>
> Video 2 -  4 seconds without audio (I generated this video using xfade
> transition
>
> Video 3 - 4 seconds with audio
>
>   
>
> If I concatenate video 1 and 3 everything works fine; audio synchronization
> is correct from start to end. However, when I concatenate all 3 of them, the
> audio from video 3 starts playing a little bit before the end of video 2. As
> video 3 is a person talking, you clearly see that the audio doesn't match
> the mouth movements.

When you use the concat demuxer, all input streams must have the same 
size (width * height), same video codec, same framerate, same audio 
codec, same number of audio tracks and the same audio sample rate.

There are two possible solutions:

1. You can add a silent audio track when you generate the second video. 
Just add a second input to your command line, for example:
-f lavfi -i anullsrc=cl=stereo -shortest

2. Or use the "acrossfade" filter when you generate the second video.

Michael



More information about the ffmpeg-user mailing list