Skip to content

Instantly share code, notes, and snippets.

@djds23
Created April 17, 2015 12:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save djds23/84750c10da2fb9fddf98 to your computer and use it in GitHub Desktop.
Save djds23/84750c10da2fb9fddf98 to your computer and use it in GitHub Desktop.
concat all videos in a directory alphabetically
import os
import subprocess
FILES = os.listdir('.') # ~/path/to/vids
TEMPLATE_PREFIX = 'file '
OUTPUT_LIST = []
for file_name in sorted(FILES):
full_file_path = os.path.abspath(file_name)
OUTPUT_LIST.append(TEMPLATE_PREFIX + full_file_path)
with open('list.txt', 'rb') as f:
for line in OUTPUT_LIST:
f.write(line+'\n')
command = 'ffmpeg -f concat -i list.txt -c copy output'.split()
subprocess.call(command)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment