Skip to content

Instantly share code, notes, and snippets.

@monty5811
Created October 3, 2014 16:06
Show Gist options
  • Save monty5811/ce8115bdee150664f7df to your computer and use it in GitHub Desktop.
Save monty5811/ce8115bdee150664f7df to your computer and use it in GitHub Desktop.
Handbrake batch convert
import os
import subprocess
handbrakePath = ""
tmpFolder = ""
outputFolder = ""
if os.path.isdir(outputFolder):
pass
else:
os.mkdir(outputFolder)
if os.path.isdir(tmpFolder):
pass
else:
os.mkdir(tmpFolder)
for mkv in [x for x in os.listdir(os.getcwd()) if x.endswith('.mkv')]:
# call handbrake to run conversion
subprocess.call([os.path.join(handbrakePath, "HandBrakeCLI"),
"--preset", "High Profile",
"-i", mkv,
"-o", os.path.join(outputFolder, mkv)])
# move file to tmp folder
os.rename(os.path.join(os.getcwd(), mkv),
os.path.join(os.getcwd(), tmpFolder, mkv))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment