Skip to content

Instantly share code, notes, and snippets.

@morrisonbrett
Last active Aug 24, 2022
Embed
What would you like to do?
Bash alias for combining MP4 files into one file
#!/bin/bash
#
# Brett Morrison, June 2022
#
# Below is a script for concatenating multiple mp4 files into one mp4 file.
# This is useful for GoPro camera output. The workflow is:
# 1. Copy files from the GoPro microSD card onto a drive
# 2. Open up a command prompt and CD into the directory you put the MP4 files
# 3. Run the command, catmp4 with the output file name as the one and only parameter
#
# Example:
# $ catmp4 2022-06-23_CAMERA-A.mp4
#
# To "install" this command
# 1. Install ffmpeg and make sure it's in your path.
# 2. Put this script, catmp4.sh somewhere and make sure it's executable and in your path.
#
rm -f input.txt
for file in `ls -tr *.MP4`
do
echo file $file >> input.txt
ffprobe.exe -i $file -print_format json -show_chapters -v quiet | grep start_time >> chapters.txt
done
rm -f $1
ffmpeg.exe -f concat -i input.txt -map_metadata 0 -map_chapters 0 -codec copy $1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment