[FFmpeg-user] Concatenating video cuts - audio gets out of sync...
Michael Koch
astroelectronic at t-online.de
Wed Dec 15 14:45:13 EET 2021
Am 15.12.2021 um 13:30 schrieb Bo Berglund:
> 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?
You could remove -c copy, but that makes the process much slower.
Are you sure that all input videos have the same properties? Same size,
video codec, framerate, audio codec, number of audio tracks, audio
sample rate?
Michael
More information about the ffmpeg-user
mailing list