Problem
ffmpeg-python
's .compile()
method to generate FFmpeg commands doesn't quote or escape filenames with spaces, so it will generate commands like so:
>>> ' '.join(output.compile())
ffmpeg -fflags +genpts -i /tmp/video with spaces in name.mkv \
-acodec copy -movflags faststart -scodec copy -threads 12 -vcodec libx264 -vlevel 4.1 \
/tmp/video with spaces in name [out].mkv -y
(Note that I edited escaped new lines into this example's output for readability, they don't exist in .compile()
's output before or after merging this pull request.)
Running that compiled command fails:
/tmp/video: No such file or directory
Solution
This pull request quotes filenames using shlex.quote()
by wrapping filenames parsed by .compile()
's helper functions.
As a result, the following command can run correctly because filenames with spaces were quoted:
>>> ' '.join(output.compile())
ffmpeg -fflags +genpts -i '/tmp/video with spaces in name.mkv' \
-acodec copy -movflags faststart -scodec copy -threads 12 -vcodec libx264 -vlevel 4.1 \
'/tmp/video with spaces in name [out].mkv' -y
(Again, escaped new lines were just added to this example for readability, this pull request does not add them to output.)