Dan Sheffner Tech Info

Stitch MP4 files together

Recenty I bought a go pro hero 8. I have always been somewhat interested in photography and video production. Most of these devices produce seperate files even though its one continuous recording. What is even more frustrating is the time lapse feature is able to shove it all into 1 file. Why can’t the video files be 1 file? Go pro is also experiementing with 12GB files instead of 4GB files. Big deal considering file formats for 4K video is just going up and up.

Here is a quick way to stitch mp4 files off an SD card. The other thing I bought was a decently fast USB read sticks. (400 MB/s) This way when the stitching is done I can take the USB stick and quickly copy to my editing computer. These are the ones I bought here.

The program I use to do the stitching is ffmpeg

brew install ffmpeg

Then I wrote this small python script to make output.mp4 on the USB stick:

#!/usr/bin/env python3

import glob
import subprocess
from datetime import datetime
startTime = datetime.now()

dir1 = "/Volumes/msdos/DCIM/100GOPRO/*.MP4"
dir2 = "/Volumes/ARCANITE/"

with open("./processGoPro.txt", "w") as f:
    for each in glob.glob(dir1):
    f.write("file '" + each + "'\n")

command1 = "ffmpeg -f concat -safe 0 -i processGoPro.txt -c copy " + dir2 + "output.mp4"
subprocess.call(command1, shell=True)

print(datetime.now() - startTime)
print ("processGoPro.py completed")

You can change dir1 and dir2 if you have different paths. This will grab ALL MP4 files in the directory. You can adjust the glob mask if you want to change which files you pull.