ffmpeg single quote in drawtext

dotsam picture dotsam · May 23, 2012 · Viewed 8.9k times · Source

I haven't been able to get ffmpeg's drawtext video filter to draw apostrophes/single quotes when they are in drawtext's "text=" parameter, even when I escape them. Double quotes work fine, and apostrophes in text loaded from a file (e.g. textfile="example.txt") work fine. Is this a bug?

e.g.

ffmpeg -i test.mpg -vf drawtext="apostrophes don't print" ...
ffmpeg -i test.mpg -vf drawtext="even when they\'re escaped" ...

Answer

blahdiblah picture blahdiblah · May 24, 2012

Special character escapes are like violence: if they're not solving your problem, you're not using enough.

ffmpeg -i test.mpg -vf drawtext=text="It\\\\\'s so easy"

Produces a textual overlay that includes an apostrophe. The text is being parsed a couple times, so you not only have to escape the quote, you also have to escape the slash escaping the quote. Twice.

Your alternative of using a textfile might be a better method in this situation.