Skip to content

Instantly share code, notes, and snippets.

@jazzyjackson
Last active January 20, 2025 02:13
Show Gist options
  • Save jazzyjackson/bf9282df0a40d7ef471e6676f282831e to your computer and use it in GitHub Desktop.
Save jazzyjackson/bf9282df0a40d7ef471e6676f282831e to your computer and use it in GitHub Desktop.
#!/bin/bash
# concatenate videos given start and end filenames
# https://trac.ffmpeg.org/wiki/Concatenate
# expect naming convention from achesco's split-to-scenes.sh:
# https://gist.github.com/achesco/4dc2ebf13378a0a61fc26c7fe01f539e
# leading 4 digits from $1 and $2
begin=${1:0:4}
end=${2:0:4}
# compare tails of 1st and 2nd argument as a sanity check that filenames are homogenous
tail1=${1:4}
tail2=${2:4}
if [ "$tail1" != "$tail2" ]
then
echo 'filenames after leading 4 digits not equal. halting.'
exit 1
fi
printf "file '%04d$tail1'\n" $(eval echo {$begin..$end}) > list.txt
echo "Ready to concatenate the following files:"
cat list.txt
echo ""
read -p "Press any key to continue, or ctrl-C to cancel"
ffmpeg -f concat -i list.txt -c copy $begin-$end$tail1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment