<p>Since drawbox doesn't support time reference, you need to use a workaround</p>

<pre><code>ffmpeg -y -loop 1 -t 5 -i img001.jpg
  -filter_complex "color=red@0.5:s=Wx100[c];
                   [0][c]overlay='-W+300*t':0"
  -y out.mp4
</code></pre>

<p>A color source is created equal to the final size of the box you wanted to draw i.e. image width (W) x 100. Then it is overlaid on the image and animated so that it starts revealing at the rate of <code>300*t</code>.</p>

CC BY-SA 3.0
2018-02-23T10:49:49.587Z
It Works! I just did this modification to avoid the rectangle to "go away" from the screen heheh
`/usr/bin/ffmpeg -y -loop 1 -t 5 -i source/img001.jpg -filter_complex 
"color=red@0.5:s=1024x100[c];[0][c]overlay='if(lte(-1024+1500*t,0),-1024+1500*t,0)':0" -t 10 out.mp4`
GFCoder977
CC BY-SA 3.0
2018-02-23T05:54:36.047Z
2018-02-23T05:54:36.047Z
Gyan
<p>I'd like to apply a dynamic drawbox before a drawtext, for example, with a fixed Y , X and H but with a dynamic W.</p>

<p>This is a trivial example: </p>

<pre><code>/usr/bin/ffmpeg -y -loop 1 -t 5 -i img001.jpg -vf drawbox=x=0:y=0:w=t*300:h=100:color=red@0.5 -y out.mp4
</code></pre>

<p>I expect to see a rectangle with the base width that increase with the time; it does not work, the box width is alwais fixed.</p>

<p>Is it possible to create a dynamic drawbox? if not, is there an alternative?</p>

CC BY-SA 3.0
2018-02-21T17:37:58.493Z
drawbox doesn't support time reference. What are you trying to do?
Gyan
CC BY-SA 3.0
2018-02-22T14:03:06.547Z
mmm I'd like to draw a rectangular shape, with some opacity,  that comes from one side and fill the entire witdh of the video. Then the text appear over it, from one side for example. A kind of graphic  introduction for the text.
GFCoder977
<ffmpeg>
ffmpeg- dynamic drawbox
GFCoder977
# ffmpeg- dynamic drawbox

(Asked by: username_0 on 2018-02-21)

I'd like to apply a dynamic drawbox before a drawtext, for example, with a fixed Y , X and H but with a dynamic W.
This is a trivial example: 
/usr/bin/ffmpeg -y -loop 1 -t 5 -i img001.jpg -vf drawbox=x=0:y=0:w=t*300:h=100:color=red@0.5 -y out.mp4

I expect to see a rectangle with the base width that increase with the time; it does not work, the box width is alwais fixed.
Is it possible to create a dynamic drawbox? if not, is there an alternative?

**Tags:** ffmpeg

> **Comments:**
> **username_1**: drawbox doesn't support time reference. What are you trying to do?  
> **username_0**: mmm I'd like to draw a rectangular shape, with some opacity,  that comes from one side and fill the entire witdh of the video. Then the text appear over it, from one side for example. A kind of graphic  introduction for the text.  

---

## 1 answers

### Answer by username_1 on 2018-02-23. Score: 3

Since drawbox doesn't support time reference, you need to use a workaround
ffmpeg -y -loop 1 -t 5 -i img001.jpg
  -filter_complex "color=red@0.5:s=Wx100[c];
                   [0][c]overlay='-W+300*t':0"
  -y out.mp4

A color source is created equal to the final size of the box you wanted to draw i.e. image width (W) x 100. Then it is overlaid on the image and animated so that it starts revealing at the rate of 300*t.

> **Comments:**
> **username_0**: It Works! I just did this modification to avoid the rectangle to "go away" from the screen heheh `/usr/bin/ffmpeg -y -loop 1 -t 5 -i source/img001.jpg -filter_complex  "color=red@0.5:s=1024x100[c];[0][c]overlay='if(lte(-1024+1500*t,0),-1024+1500*t,0)':0" -t 10 out.mp4`  

---

