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

iburman at compuscience.com iburman at compuscience.com
Tue Jun 22 13:14:30 EEST 2021


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.

 

I use the following to concatenate:

Ffmpeg -safe 0 -f concat -i D:\99_FFMpeg\file_list.txt -c copy
concatenated.mp4

 

Why is this happening and how can I fix it?

 

Console output is below:

 

EXE: -safe 0 -f concat -i D:\99_FFMpeg\file_list.txt -c copy
concatenated.mp4

ffmpeg version 2021-03-14-git-1d61a31497-essentials_build-www.gyan.dev
Copyright (c) 2000-2021 the FFmpeg developers

  built with gcc 10.2.0 (Rev6, Built by MSYS2 project)

  configuration: --enable-gpl --enable-version3 --enable-static
--disable-w32threads --disable-autodetect --enable-fontconfig --enable-iconv
--enable-gnutls --enable-libxml2 --enable-gmp --enable-lzma --enable-zlib
--enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth
--enable-sdl2 --enable-libwebp --enable-libx264 --enable-libx265
--enable-libxvid --enable-libaom --enable-libopenjpeg --enable-libvpx
--enable-libass --enable-libfreetype --enable-libfribidi --enable-libvidstab
--enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm
--enable-cuvid --enable-ffnvcodec --enable-nvdec --enable-nvenc
--enable-d3d11va --enable-dxva2 --enable-libmfx --enable-libgme
--enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame
--enable-libtheora --enable-libvo-amrwbenc --enable-libgsm
--enable-libopencore-amrnb --enable-libopus --enable-libspeex
--enable-libvorbis --enable-librubberband

  libavutil      56. 68.100 / 56. 68.100

  libavcodec     58.131.100 / 58.131.100

  libavformat    58. 74.100 / 58. 74.100

  libavdevice    58. 12.100 / 58. 12.100

  libavfilter     7.109.100 /  7.109.100

  libswscale      5.  8.100 /  5.  8.100

  libswresample   3.  8.100 /  3.  8.100

  libpostproc    55.  8.100 / 55.  8.100

[mov,mp4,m4a,3gp,3g2,mj2 @ 0000029fff0972c0] Auto-inserting h264_mp4toannexb
bitstream filter

Input #0, concat, from 'D:\99_FFMpeg\file_list.txt':

  Duration: N/A, start: -0.021333, bitrate: 2623 kb/s

  Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p,
1920x1080 [SAR 1:1 DAR 16:9], 2494 kb/s, 60 fps, 60 tbr, 15360 tbn, 120 tbc

    Metadata:

      handler_name    : VideoHandler

      vendor_id       : [0][0][0][0]

  Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo,
fltp, 129 kb/s

    Metadata:

      handler_name    : SoundHandler

      vendor_id       : [0][0][0][0]

Output #0, mp4, to 'concatenated.mp4':

  Metadata:

    encoder         : Lavf58.74.100

  Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p,
1920x1080 [SAR 1:1 DAR 16:9], q=2-31, 2494 kb/s, 60 fps, 60 tbr, 15360 tbn,
15360 tbc

    Metadata:

      handler_name    : VideoHandler

      vendor_id       : [0][0][0][0]

  Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo,
fltp, 129 kb/s

    Metadata:

      handler_name    : SoundHandler

      vendor_id       : [0][0][0][0]

Stream mapping:

  Stream #0:0 -> #0:0 (copy)

  Stream #0:1 -> #0:1 (copy)

Press [q] to stop, [?] for help

frame=    1 fps=0.0 q=-1.0 size=       0kB time=00:00:00.00 bitrate=N/A
speed=   0x    

[mov,mp4,m4a,3gp,3g2,mj2 @ 0000029fff0ac6c0] Auto-inserting h264_mp4toannexb
bitstream filter

[mov,mp4,m4a,3gp,3g2,mj2 @ 0000029fff098dc0] Auto-inserting h264_mp4toannexb
bitstream filter

frame= 1266 fps=0.0 q=-1.0 Lsize=    6209kB time=00:00:21.11
bitrate=2409.4kbits/s speed= 638x    

video:5906kB audio:268kB subtitle:0kB other streams:0kB global headers:0kB
muxing overhead: 0.566926%

 

 

Thanks

 

 

 

 



More information about the ffmpeg-user mailing list