[FFmpeg-user] Subtitle filter and filename with quotes and spaces
stefasab at gmail.com
Tue Jan 21 18:56:36 CET 2014
On date Sunday 2014-01-19 19:34:51 -0500, Ramit Bhalla wrote:
> I'm trying to use the subtitle filter to burn in the subtitles while
> encoding. My filename has a space and a quote in it. I've tried every
> possible combination of escaping, quoting, double quoting etc but I just
> can't get it to work.
> This is what I 'want' to execute:
> ffmpeg.exe -probesize 100M -analyzeduration 300M -threads 0 -drc_scale 0.8
> -y -i "D:\MCEBuddy\MCEBuddy
> 2.x\MCEBuddy.ServiceCMD\bin\x86\Debug\working0\HD Small'.ts" -ss 3 -vf
> 2.x\MCEBuddy.ServiceCMD\bin\x86\Debug\working0\HD Small'.srt" -vcodec
> libx264 -b 1400000 -x264opts
> -sn -acodec libfdk_aac -ab 256k -cutoff 18000 -ac 2 "D:\MCEBuddy\MCEBuddy
> 2.x\MCEBuddy.ServiceCMD\bin\x86\Debug\working0\HD Small'-converted.mp4"
> the SRT filepath is
D:\MCEBuddy\MCEBuddy 2.x\MCEBuddy.ServiceCMD\bin\x86\Debug\working0\HD Small'.srt
So this string contains : which is special according to the filter
description syntax, and the \ and ' special escaping characters.
So, first level escaping:
D\:\\MCEBuddy\\MCEBuddy 2.x\\MCEBuddy.ServiceCMD\\bin\\x86\\Debug\\working0\\HD Small\'.srt
Now you embed the filter description string in the filtergraph
description, so you add another escaping level, and you need to escape
the special \ and ' characters. One way of doing this is as:
subtitles=D\\:\\\\MCEBuddy\\\\MCEBuddy 2.x\\\\MCEBuddy.ServiceCMD\\\\bin\\\\x86\\\\Debug\\\\working0\\\\HD Small\\\'.srt
Alternatively you use quoting:
subtitles='D\:\\MCEBuddy\\MCEBuddy 2.x\\MCEBuddy.ServiceCMD\\bin\\x86\\Debug\\working0\\HD Small'\'.srt
At this point you need a third level escaping which depends on the
shell. With bash you need to escape again the \ and ' characters, so
ffmpeg ... -vf subtitles=D\\\\:\\\\\\\\MCEBuddy\\\\\\\\MCEBuddy 2.x\\\\\\\\MCEBuddy.ServiceCMD\\\\\\\\bin\\\\\\\\x86\\\\\\\\Debug\\\\\\\\working0\\\\\\\\HD Small\\\\\\\'.srt
Alternatively with " quoting (only \ needs to be escaped):
ffmpeg ... -vf "subtitles='D\\:\\\\MCEBuddy\\\\MCEBuddy 2.x\\\\MCEBuddy.ServiceCMD\\\\bin\\\\x86\\\\Debug\\\\working0\\\\HD Small'\\'.srt"
I don't know how escaping works with the Windows shell.
Unfortunately there is no easy way to escape the escaping hell. You
can avoid the shell third level expansion by reading the filtergraph
from a file, or you can try hard to avoid to have special characters
in your input filename, or you can use tools/ffescape with scripts.
> What is the right way to use this with subtitles or is it not possible at
More information about the ffmpeg-user