1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | #!/bin/bash set -e if [[ $# -lt 3 ]]; then echo "USAGE: $0 INPUT-1 ... INPUT-N OUTPUT" exit 1 fi # Ensure temp file is in the working directory. FILE="$(mktemp -p .)" # Cleanup, even if there's an error. function cleanup { rm $FILE } trap cleanup EXIT # Extract arguments. n=$# OUTPUT=${!n} INPUTS=${@:1:n-1} # Generate the concatenation instruction file. for f in $INPUTS; do echo "file '$f'" >> $FILE done # Gogogogogooooo! ffmpeg -f concat -i $FILE -c copy $OUTPUT |