Forked from OrganicIrradiation/hb_batchconvertvideos.py
Created
April 23, 2017 15:55
-
-
Save bitsandbooks/2dea23eb020e9a017ae1dfa382dffda6 to your computer and use it in GitHub Desktop.
hb_batchconvertvideos
This file contains 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 os | |
import time | |
import subprocess | |
import sys | |
fileList = [] | |
rootdir = raw_input("Root Dir: ") | |
for root, subFolders, files in os.walk(rootdir): | |
for file in files: | |
theFile = os.path.join(root,file) | |
fileName, fileExtension = os.path.splitext(theFile) | |
if fileExtension.lower() in ('.avi', '.divx', '.flv', '.m4v', '.mkv', '.mov', '.mpg', '.mpeg', '.wmv'): | |
print 'Adding',theFile | |
fileList.append(theFile) | |
runstr = '"C:Program FilesHandbrakeHandBrakeCLI.exe" -i "{0}" -o "{1}" --preset="Normal" --two-pass --turbo' | |
print '=======--------=======' | |
while fileList: | |
inFile = fileList.pop() | |
fileName, fileExtension = os.path.splitext(inFile) | |
outFile = fileName+'.mp4' | |
print 'Processing',inFile | |
returncode = subprocess.call(runstr.format(inFile,outFile)) | |
time.sleep(5) | |
print 'Removing',inFile | |
os.remove(inFile) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment