Created
March 25, 2021 06:07
-
-
Save dacioromero/91ad8c53af19050cef7ed83bf9e0c625 to your computer and use it in GitHub Desktop.
Script to stitch together GoPro recordings with FFmpeg
This file contains hidden or 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
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