Last active
August 24, 2022 18:07
-
-
Save morrisonbrett/47c5d02c265b546706cd58e01cd9b4a4 to your computer and use it in GitHub Desktop.
Bash alias for combining MP4 files into one file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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