Initial commit - working on Windows and OSX
This commit is contained in:
97
ffmpeg-files.py
Normal file
97
ffmpeg-files.py
Normal file
@@ -0,0 +1,97 @@
|
||||
import os
|
||||
import sys
|
||||
|
||||
def clearScreen():
|
||||
os.system('cls' if os.name == 'nt' else 'clear')
|
||||
|
||||
def convertFilesInImport():
|
||||
for filename in os.listdir('input'):
|
||||
#os.path.splitext(filename)[0] gets ride of file extension
|
||||
ffmpegcmd = getFfmpegPath() + " -i " + getInputPath() + filename + " -b " + getBitrateSetting() + " -minrate " + getBitrateSetting() + " -maxrate " + getBitrateSetting() + " -bufsize " + getBitrateSetting() + " -vcodec libx264" + getAudioSetting() + " -y " + getOutputPath() + os.path.splitext(filename)[0] + ".mp4"
|
||||
os.system(ffmpegcmd)
|
||||
|
||||
def getFfmpegPath():
|
||||
if(os.name == "nt"):
|
||||
return "ffmpeg\\windows\\ffmpeg.exe"
|
||||
elif(sys.platform == "darwin"):
|
||||
return "ffmpeg/osx/ffmpeg"
|
||||
else:
|
||||
returnErrorAndExit("Your os is not supported. Try using Windows or OSX")
|
||||
|
||||
def getOutputPath():
|
||||
if(os.name == "nt"):
|
||||
return "output\\"
|
||||
else:
|
||||
return "output/"
|
||||
|
||||
def getInputPath():
|
||||
if(os.name == "nt"):
|
||||
return "input\\"
|
||||
else:
|
||||
return "input/"
|
||||
|
||||
def askForResolution():
|
||||
inputresolution = "0"
|
||||
while(inputresolution != "1" and inputresolution != "2" and inputresolution != "3" and inputresolution != "4" and inputresolution != "5" and inputresolution != "6" and inputresolution != "7" and inputresolution != "8"):
|
||||
clearScreen()
|
||||
print("Tell me about your source video.")
|
||||
print("1. 4k at a slow frame rate (24, 25, 30)")
|
||||
print("2. 1080p at a slow frame rate (24, 25, 30)")
|
||||
print("3. 720p at a slow frame rate (24, 25, 30)")
|
||||
print("4. 480p at a slow frame rate (24, 25, 30)")
|
||||
print("5. 4k at a fast frame rate (48, 50, 60)")
|
||||
print("6. 1080p at a fast frame rate (48, 50, 60)")
|
||||
print("7. 720p at a fast frame rate (48, 50, 60)")
|
||||
print("8. 480p at a fast frame rate (48, 50, 60)")
|
||||
inputresolution = input("Please enter a number from above: ")
|
||||
return inputresolution
|
||||
|
||||
def askForAudioOutput():
|
||||
audioOutput = "0"
|
||||
while(audioOutput != "1" and audioOutput != "2" and audioOutput != "3" and audioOutput != "4"):
|
||||
clearScreen()
|
||||
print("Tell me what you would like your audio to output as.")
|
||||
print("1. For no audio")
|
||||
print("2. For Mono audio")
|
||||
print("3. For Stereo audio")
|
||||
print("4. For 5.1 audio")
|
||||
audioOutput = input("Please enter a number from above: ")
|
||||
return audioOutput
|
||||
|
||||
def getBitrateSetting():
|
||||
if(resolution == "1"):
|
||||
return "44000k"
|
||||
elif(resolution == "2"):
|
||||
return "10000k"
|
||||
elif(resolution == "3"):
|
||||
return "6500k"
|
||||
elif(resolution == "4"):
|
||||
return "2500k"
|
||||
elif(resolution == "5"):
|
||||
return "66000k"
|
||||
elif(resolution == "6"):
|
||||
return "15000k"
|
||||
elif(resolution == "7"):
|
||||
return "9500k"
|
||||
elif(resolution == "8"):
|
||||
return "4000k"
|
||||
|
||||
def getAudioSetting():
|
||||
if(audio == "1"):
|
||||
return " -an"
|
||||
elif(audio == "2"):
|
||||
return " -ab 128k"
|
||||
elif(audio == "3"):
|
||||
return " -ab 384k"
|
||||
elif(audio == "4"):
|
||||
return " -ab 512k"
|
||||
|
||||
|
||||
def returnErrorAndExit(message):
|
||||
input(message)
|
||||
sys.exit()
|
||||
|
||||
#Run Program
|
||||
resolution = askForResolution()
|
||||
audio = askForAudioOutput()
|
||||
convertFilesInImport()
|
||||
Reference in New Issue
Block a user