ffmpeg single quote in drawtext

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.


In case someone needs this for python, this escape function is working for me (based on https://ffmpeg.org/ffmpeg-utils.html#Quoting-and-escaping + multi-escaping advice above):

return "'" + text.replace(":", "\\:").replace("'", "'\\\\\\''") + "'"


I was able to insert Unicode \u2019 into argument string and it worked for single right quote.