User:Jan Honvehlmann/ffmpeg-concat.sh
Jump to navigation
Jump to search
ffmpeg_concat() {
timestamp=$(date "+%Y%m%d%H%M%S")
# Unlike in JavaScript, no spaces may surround the "=" equals sign to set a variable.
# generate file list
for path in $@; do
echo "file '$path' " >>ffmpeg_concat.$timestamp.txt
# ffmpeg only supports apostrophes, no quotation marks.
done
# ask user for output file extension to specify which container format should be used by FFmpeg
printf "Output file extension: "
read output_extension
# put it together
ffmpeg -f concat -safe 0 -i ffmpeg_concat.$timestamp.txt -c copy ffmpeg_concat.$timestamp.$output_extension
# -safe 0 allows concatinating files outside the current working directory
# -c copy passes through the existing video and audio streams without re-encoding it and only multiplexes it, making the process take only a fraction of the time since disk reading/writing speeds are the only limitation.
}