0

I have a variable that takes its content from a file (I can't change the content of the file):

echo $variable
It's my variable

I want to print that string on a video with ffmpeg:

ffmpeg -nostdin -i input.mp4 -vf drawtext="text='$variable': fontcolor=white:box=1:boxcolor=black@0.8: x=h/70: y=h/5*4.2" -codec:a copy output.mp4

when I do that, the quote inside $variable is not printed. I have read here that I need to escape the quote multiple times, some say 5 times, some say more.

So I have tried to use

variable=${variable//\'/'\\\\\'\'}

to add between 1 and 10 backslashes, but it never worked: either nothing is printed, or \ are printed:

It\s my variable

Can someone tell me what is the correct syntax, or the correct number of backslashes I should add?

Community
  • 1
  • 1
Sulli
  • 763
  • 1
  • 11
  • 33

0 Answers0