Skip to content

Instantly share code, notes, and snippets.

@ryanfb
Last active July 17, 2023 10:41
Show Gist options
  • Save ryanfb/12ed696675db85dba40fc85eaed47f13 to your computer and use it in GitHub Desktop.
Save ryanfb/12ed696675db85dba40fc85eaed47f13 to your computer and use it in GitHub Desktop.
Short shell script for concatenating video files with ffmpeg's "concat" demuxer, using command line arguments.
#!/bin/bash
# Usage:
# ./ffmpegconcat.sh input1.mp4 input2.mp4 input3.mp4 output.mp4
# See: https://trac.ffmpeg.org/wiki/Concatenate
for input in "${@:1:$#-1}"; do echo "file '$input'"; done > filelist.txt
ffmpeg -f concat -safe 0 -i filelist.txt -c copy "${@: -1}"
echo "Concatenated:" && cat filelist.txt && rm -f filelist.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment