Answers.Body: <p>Use the box options i.e. </p>
  
  <pre><code>drawtext=enable='between(t,2.5,6.5)':fontsize=50:fontcolor=White:fontfile='ariblk.ttf':text='textline1':x=min(4*(tw\+10)-(abs(4-2*(t-2.5)))*(tw+10)-tw\,10):y=h-th-130:box=1:boxborderw=12:boxcolor=black@0.45
  </code></pre>
  
  <p>This adds a box with padding of 12 pixels around the text boundary, and the color is black with 45% opacity.</p>
  
  <p>Using <strong>drawbox</strong> (add it before the drawtexts)</p>
  
  <pre><code>drawbox=y=ih-140:h=110:c=black@0.45:t=max:enable='between(t,2.5,6.5)'
  </code></pre>
  
  <hr>
  
  <p>Here's the entire vf expression:</p>
  
  <pre><code>-vf "drawbox=y=ih-140:h=110:c=black@0.45:t=max:enable='between(t,2.5,6.5)',drawtext=enable='between(t,2.5,6.5)':fontsize=50:fontcolor=White:fontfile='ariblk.ttf':text='textline1':x=min(4*(tw\+10)-(abs(4-2*(t-2.5)))*(tw+10)-tw\,10):y=h-th-130, drawtext=enable='between(t,2.5,6.5)':fontsize=50:fontcolor=White:fontfile='ariblk.ttf':text='textline2':x=min(4*(tw\+10)-(abs(4-2*(t-2.5)))*(tw+10)-tw\,10):y=h-th-75, drawtext=enable='between(t,2.5,6.5)':fontsize=50:fontcolor=White:fontfile='ariblk.ttf':text='textline3':x=min(4*(tw\+10)-(abs(4-2*(t-2.5)))*(tw+10)-tw\,10):y=h-th-20" -codec:a copy videoout.mp4
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-01-27T14:41:13.237Z
Answers.Text: Thx Mulvya, but i was thinking about drawbox so the background can be in full width. With 3 lines that have different number of letters it looks ugly this way. I am using y=h-th-130 up to y=h-th-20 for those 3 lines, so the background should be from around 140 to 10, but in full width, as i might add more text or image over it in right corner later. And from the link in question it looks perfect (not the position but background).
Answers.UserDisplayName: Azz Kawa
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-01-27T16:05:23.887Z
Answers.Text: Thx Mulvya !. I am getting error "Unable to parse graph description substring. Might be that i am not separating text and box expressions correctly. Starting like this ffmpeg -i videoin.mp4 -vf drawbox=y=ih-140:h=110:c=black@0.45:t=max:enable='between(t,2.5,6.5)': "[in]drawtext=enable='between(t,2.5,6.5)'....etc...
Answers.UserDisplayName: Azz Kawa
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-01-27T12:27:27.073Z
Answers.LastActivityDate: 2016-01-27T16:10:29.547Z
Answers.LastEditDate: 2016-01-27T16:10:29.547Z
Answers.UserDisplayName: Gyan
Body: <p>How to correctly add expression to transparent background like on this question <a href="https://video.stackexchange.com/questions/15551/ffmpeg-drawtext-filter-create-transparent-background-with-text">ffmpeg drawtext filter - create transparent background with text</a>
  for my case (where there are 3 lines in bottom right corner):</p>
  
  <pre><code>ffmpeg -i videoin.mp4 -vf "[in]drawtext=enable='between(t,2.5,6.5)':fontsize=50:fontcolor=White:fontfile='ariblk.ttf':text='textline1':x=min(4*(tw\+10)-(abs(4-2*(t-2.5)))*(tw+10)-tw\,10):y=h-th-130, drawtext=enable='between(t,2.5,6.5)':fontsize=50:fontcolor=White:fontfile='ariblk.ttf':text='textline2':x=min(4*(tw\+10)-(abs(4-2*(t-2.5)))*(tw+10)-tw\,10):y=h-th-75, drawtext=enable='between(t,2.5,6.5)':fontsize=50:fontcolor=White:fontfile='ariblk.ttf':text='textline3':x=min(4*(tw\+10)-(abs(4-2*(t-2.5)))*(tw+10)-tw\,10):y=h-th-20[out]" -codec:a copy videoout.mp4
  </code></pre>
  
Tags: <ffmpeg>
Title: Add transparent background to ffmpeg with text over it
UserDisplayName: Azz Kawa
ThreadText: # Add transparent background to ffmpeg with text over it
  
  (Asked by: username_0 on 2016-01-27)
  
  How to correctly add expression to transparent background like on this question [ffmpeg drawtext filter - create transparent background with text](https://video.stackexchange.com/questions/15551/ffmpeg-drawtext-filter-create-transparent-background-with-text)
  for my case (where there are 3 lines in bottom right corner):
  
  ```
  ffmpeg -i videoin.mp4 -vf "[in]drawtext=enable='between(t,2.5,6.5)':fontsize=50:fontcolor=White:fontfile='ariblk.ttf':text='textline1':x=min(4*(tw\+10)-(abs(4-2*(t-2.5)))*(tw+10)-tw\,10):y=h-th-130, drawtext=enable='between(t,2.5,6.5)':fontsize=50:fontcolor=White:fontfile='ariblk.ttf':text='textline2':x=min(4*(tw\+10)-(abs(4-2*(t-2.5)))*(tw+10)-tw\,10):y=h-th-75, drawtext=enable='between(t,2.5,6.5)':fontsize=50:fontcolor=White:fontfile='ariblk.ttf':text='textline3':x=min(4*(tw\+10)-(abs(4-2*(t-2.5)))*(tw+10)-tw\,10):y=h-th-20[out]" -codec:a copy videoout.mp4
  
  ```
  
  **Tags:** ffmpeg
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2016-01-27. Score: 3 | Accepted answer
  
  Use the box options i.e.
  
  ```
  drawtext=enable='between(t,2.5,6.5)':fontsize=50:fontcolor=White:fontfile='ariblk.ttf':text='textline1':x=min(4*(tw\+10)-(abs(4-2*(t-2.5)))*(tw+10)-tw\,10):y=h-th-130:box=1:boxborderw=12:boxcolor=black@0.45
  
  ```
  
  This adds a box with padding of 12 pixels around the text boundary, and the color is black with 45% opacity.
  
  Using **drawbox** (add it before the drawtexts)
  
  ```
  drawbox=y=ih-140:h=110:c=black@0.45:t=max:enable='between(t,2.5,6.5)'
  
  ```
  
  ---
  
  Here's the entire vf expression:
  
  ```
  -vf "drawbox=y=ih-140:h=110:c=black@0.45:t=max:enable='between(t,2.5,6.5)',drawtext=enable='between(t,2.5,6.5)':fontsize=50:fontcolor=White:fontfile='ariblk.ttf':text='textline1':x=min(4*(tw\+10)-(abs(4-2*(t-2.5)))*(tw+10)-tw\,10):y=h-th-130, drawtext=enable='between(t,2.5,6.5)':fontsize=50:fontcolor=White:fontfile='ariblk.ttf':text='textline2':x=min(4*(tw\+10)-(abs(4-2*(t-2.5)))*(tw+10)-tw\,10):y=h-th-75, drawtext=enable='between(t,2.5,6.5)':fontsize=50:fontcolor=White:fontfile='ariblk.ttf':text='textline3':x=min(4*(tw\+10)-(abs(4-2*(t-2.5)))*(tw+10)-tw\,10):y=h-th-20" -codec:a copy videoout.mp4
  
  ```
  
  > **Comments:**
  > **username_0**: Thx Mulvya, but i was thinking about drawbox so the background can be in full width. With 3 lines that have different number of letters it looks ugly this way. I am using y=h-th-130 up to y=h-th-20 for those 3 lines, so the background should be from around 140 to 10, but in full width, as i might add more text or image over it in right corner later. And from the link in question it looks perfect (not the position but background).  
  > **username_0**: Thx Mulvya !. I am getting error "Unable to parse graph description substring. Might be that i am not separating text and box expressions correctly. Starting like this ffmpeg -i videoin.mp4 -vf drawbox=y=ih-140:h=110:c=black@0.45:t=max:enable='between(t,2.5,6.5)': "[in]drawtext=enable='between(t,2.5,6.5)'....etc...  
  
  ---
  
  