Skip to content

Instantly share code, notes, and snippets.

@tolpp
Created November 9, 2019 21:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tolpp/e41763811c37dca58a7d05d00fb23e48 to your computer and use it in GitHub Desktop.
Save tolpp/e41763811c37dca58a7d05d00fb23e48 to your computer and use it in GitHub Desktop.
ffmpeg script for merging multiple files into one mp4 file
#!/bin/bash
input_file_find_pattern="'\./$1.*'"
find_command="find . -regex $input_file_find_pattern"
input_files=()
while IFS= read -r line; do
input_files+=( "$line" )
done < <( eval $find_command )
ffmpeg_merge_command='ffmpeg -loglevel error'
for (( i = 0; i < ${#input_files[@]}; i++ )); do
ffmpeg_merge_command+=" -i '${input_files[$i]}'"
done
ffmpeg_merge_command+=" -strict -2 -codec copy '$1.mp4'"
echo "Running ffmpeg command:"
echo $ffmpeg_merge_command
eval $ffmpeg_merge_command
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment