Running FFmpeg commands from a Python Script

import subprocessffmpeg = "/usr/local/bin/ffmpeg"
def grabUserInput():    def filterInput(message, default):
user_input = input (message)
if user_input == "":
user_input = default
return user_input
print("Hit enter for default values\n") user_input_dict = {} user_input_dict["input_file"] = filterInput("Input File: ", "")
...
return user_input_dict
def buildFFmpegCommand():    final_user_input = grabUserInput()    commands_list = [
ffmpeg,
"-i",
...
final_user_input["output_file"]
]
return commands_list
def runFFmpeg(commands):    if subprocess.run(commands).returncode == 0:
print ("FFmpeg Script Ran Successfully")
else:
print ("There was an error running your FFmpeg script")
runFFmpeg(buildFFmpegCommand())

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Arthur Wilton

Arthur Wilton

41 Followers

Software Developer and Video/Post Production Professional. Recent graduate of Flatiron School.