I'm trying to write a program in python3 that uses handbrakecli on my ubuntu machine to recode some video.
I'm missing something stupid but I cannot for the life of me figure this out, and I've been at it for countless hours.
and no matter how I rearrange the " I get one of two errors, either handbrake says file not found or it cannot find my preset.
This exact command works perfectly from the command line.
Steps to reproduce the problem (If Applicable):
Here's the code:
Code: Select all
def convertvideo(input_file):
hb_args = (" -i " + input_file + " -o " + handbraketempspace + " --preset-import-file "+handbrake_json_file_location + " -Z " + handbrake_profile_name)
print (hb_args) # for debug only
subprocess.Popen(handbrake + hb_args)
return()
1.3.0
Operating system and version (e.g., Ubuntu 16.04 LTS, macOS 10.13 High Sierra, Windows 10 Creators Update):
Ubuntu 18.04 LTS
HandBrake Activity Log ***required*** (see How-to get an activity log)
Here's the specific error:
Code: Select all
Traceback (most recent call last):
File "SubProcessing.py", line 161, in <module>
finalvideo = convertvideo(sys.argv[2])
File "SubProcessing.py", line 82, in convertvideo
subprocess.Popen(handbrake + hb_args)
File "/usr/lib/python3.8/subprocess.py", line 854, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "/usr/lib/python3.8/subprocess.py", line 1702, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: "/usr/bin/HandBrakeCLI -i /root/Alone-S02E01-Once_More_Unto_the_Breach_HDTV-720p.mkv -o /root/tmp/tempvideo.mkv --preset-import-file /mnt/media/PlexTestFiles/handbrake_presets.json -Z 'h.265_Hardware'"