Skip to content

Instantly share code, notes, and snippets.

@dacioromero
Created March 25, 2021 06:07
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dacioromero/91ad8c53af19050cef7ed83bf9e0c625 to your computer and use it in GitHub Desktop.
Save dacioromero/91ad8c53af19050cef7ed83bf9e0c625 to your computer and use it in GitHub Desktop.
Script to stitch together GoPro recordings with FFmpeg
import glob
from collections import defaultdict
import subprocess
from os import path
def main(dest = ''):
recordings = defaultdict(list)
for file in glob.glob(f'GH{"[0-9]" * 6}.MP4'):
chapter = file[2:4]
recording = file[4:8]
recordings[recording].append(chapter)
for recording, chapters in recordings.items():
cmd = ['ffmpeg']
for chapter in chapters:
cmd.extend(['-i', f'GH{chapter}{recording}.MP4'])
cmd.extend(['-c', 'copy', '-map_metadata', '0', path.join(dest, f'{recording}.MP4')])
subprocess.run(cmd)
if __name__ == '__main__':
import sys
main(sys.argv[1])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment