Skip to content

Instantly share code, notes, and snippets.

@mavhc
Created February 21, 2017 10:53
Show Gist options
  • Save mavhc/41615833d063894f89de7979f15f4177 to your computer and use it in GitHub Desktop.
Save mavhc/41615833d063894f89de7979f15f4177 to your computer and use it in GitHub Desktop.
Join mp4 files with ffmpeg
# join.py
# CC-0
# usage: python3 join.py filename
# all files that start with filename in the current dir will be found, sorted, and joined together with ffmpeg
# mp4 assumed
import os, glob, sys, subprocess
name = sys.argv[1]
print(name)
fileList = glob.glob(name+"*")
fileList.sort()
writeFile = open("tmpffmpeg.tmp","w")
for item in fileList:
writeFile.write("file '%s'\n" % item)
writeFile.close()
return_code = subprocess.call(["ffmpeg -f concat -safe 0 -i tmpffmpeg.tmp -c copy "+name+".mp4"],shell=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment