Fix for paths that include spaces
Noticed issues while trying to cut a video file that had a space in its name. Looked at the code and noticed that ffmpeg was being called without taking care of paths that could perhaps contain spaces.
common on Linux to use it this way : "path with spaces"
common on Linux to use it this way : "path with spaces"
Yeah, that's what I tried. Still broke since the string was passed to ffmpeg without those quotations again internally.
i think you use that in iPython ,if you just run the code from terminal there is no problem any way with iPyhton just add +"+ path +"+ to the command line.
If I run python.exe jumpcutter.py --input_file "C:\Some Path\ Some File.mp4" --output_file "some other file.mp4" it will fail because it can't find the input file C:\Some because that's all that gets passed to ffmpeg in the end, because no quotation marks were added to that command.
The original code is this:
ffmpeg -i "+INPUT_FILE+" -qscale:v "+str(FRAME_QUALITY)+" "+TEMP_FOLDER+"/frame%06d.jpg -hide_banner
so if you insert the correctly quoted arguments it turns into this incorrect form:
ffmpeg -i C:\Some Path\ Some File.mp4 -qscale:v "+str(FRAME_QUALITY)+" "+TEMP_FOLDER+"/frame%06d.jpg -hide_banner
Obviously without correct quotations.
test it on windows, same problem :+1:
replace all INPUT_FILE in commands to '"'+INPUT_FILE+'"'
same for OUTPUT_FILE
this will correct it
I think it would actually be better to pass the arguments as a list as it will make the code cleaner (in my opinion) and wouldn't break if the filename had a ".
For example:
command = ["ffmpeg", "-i", INPUT_FILE, "-qscale:v", str(FRAME_QUALITY), TEMP_FOLDER+"/frame%06d.jpg", "-hide_banner"]
rc = subprocess.run(command)
if rc.returncode != 0:
print(rc)
exit(rc.returncode)
Would replace the lines
command = "ffmpeg -i "+INPUT_FILE+" -qscale:v "+str(FRAME_QUALITY)+" "+TEMP_FOLDER+"/frame%06d.jpg -hide_banner"
subprocess.call(command, shell=True)
Nice, I didn't know about that way of calling processes. Learned something new and changed the code to include those changes. It's way cleaner that way for sure.