Skip to content

Instantly share code, notes, and snippets.

@natcl
Last active December 18, 2015 10:39
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 natcl/5769795 to your computer and use it in GitHub Desktop.
Save natcl/5769795 to your computer and use it in GitHub Desktop.
ffmpeg batch convert script in python
import os
import sys
path = sys.argv[1]
input_format = ['.' + x for x in sys.argv[2].split()]
output_format = '.' + sys.argv[3]
args = sys.argv[4]
files = [os.path.join(path,f) for f in os.listdir(path) if os.path.splitext(f.lower())[1] in input_format]
print files
print input_format
print output_format
print args
for f in files:
os.system('ffmpeg %s -i "%s" "%s%s"' % (args, f, f, output_format))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment