[FFmpeg-user] Concatenating video cuts - audio gets out of sync...

Bo Berglund bo.berglund at gmail.com
Wed Dec 15 14:30:19 EET 2021


I am using this script on Ubuntu 20.04.3 server which I wrote to paste together
clips from a video into one single video.
It takes the output video file as the first argument and all following are the
clip files. Script has error checking for user input but I remoed these here for
clarity:

----------------
#!/bin/bash
JOINFILE="joinfile.txt"
NUMARGS=$#

TARGETFILE="$1"

if [ $NUMARGS > 1 ]
then
  shift
  echo "file $1" > "$JOINFILE"
  shift
  while [ "$1" != "" ]; do
    echo "file $1" >> "$JOINFILE"
    shift
  done
fi

COMMAND="ffmpeg -f concat -safe 0 -i $JOINFILE -c copy $TARGETFILE"
eval "$COMMAND"
eval "rm $JOINFILE"
exit 0
------------------

This has worked mostly well but now I have a problem when pasting two clips from
a video where the audio gets badly out of sync at the paste point.

Is there some way to modify the ffmpeg command such that the audio is not
affected like this?

Both clips play just fine without any lipsync problem, but the pasted video is
several seconds (or possibly more) off.


-- 
Bo Berglund
Developer in Sweden



More information about the ffmpeg-user mailing list