Quantcast
Channel: Active questions tagged windows - Super User
Viewing all articles
Browse latest Browse all 9217

ffmpeg: How to escape file path for burned-in text-based subtitles?

$
0
0

I'm trying to burn text-based subtitles into a video using ffmpeg, via the command line option -vf followed by subtitles=(filename):si=(subtitle index). I need this to work for both Windows and macOS.

On Windows, I've only been able to get this to work if filename is a file in the current working directory with no special characters like spaces or apostrophes. Unless filename is that simple, I get the error:

"Unable to parse option value mangled filename as image size"

I've had better luck with macOS, but still can't get around filename containing an apostrophe. For example:

ffmpeg -y -i "Doesn't work.mkv" -vf "subtitles='Doesn'\''t work.mkv':si=0" -c:v vp9 -row-mt 1 -crf 24 -c:a:0 libvorbis foo.webm

...or...

ffmpeg -y -i "Doesn't work.mkv" -vf "subtitles='Doesn'\\\''t work.mkv':si=0" -c:v vp9 -row-mt 1 -crf 24 -c:a:0 libvorbis foo.webm

...both result in the error:

Unable to open Doesnt work.mkv

I've tried to follow advice from these two Stack Overflow threads:

https://stackoverflow.com/questions/71597897/unable-to-parse-option-value-xxx-srt-as-image-size-in-ffmpeghttps://stackoverflow.com/questions/45916331/escape-special-characters-in-ffmpeg-subtitle-filename

...and general documentation on escaping for ffmpeg, but none of that helps. You can see in the second Stack Overflow thread above someone gave up, saying "The only solution I found was using a file without special characters local to your working directory".

That was back in 2017. The first thread is more recent (2022), but the advice given there simply isn't working for me.

Anyone know a better solution for this? I'm beginning to wonder if the only solution is the ridiculous extra step of extracting any text-based subtitles I need into a new, simply-named file in the current working directory.

(Image-based subtitles are much easier to handle, by the way.)


Viewing all articles
Browse latest Browse all 9217

Trending Articles