Skip to content

Instantly share code, notes, and snippets.

@AdeptSEO
Forked from ryanfb/ffmpegconcat.sh
Created July 17, 2023 10:41
Show Gist options
  • Save AdeptSEO/5c86b412401f4dca64b9c343c2d0c8f1 to your computer and use it in GitHub Desktop.
Save AdeptSEO/5c86b412401f4dca64b9c343c2d0c8f1 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