Answers.Body: <p>Thanks to @Gyan comments I've been able to come up with this solution, in case somebody else is interested:</p>
  
  <pre><code>color=c=red:size=1920x1080,
  scale=eval=frame:w='if(gte(t*20,600),600,t*20)':h=20[cl];
  [input][cl]overlay=x=0:y=0[finalOutput]
  </code></pre>
  
  <p>Just note that it is important that you download a current git version of ffmpeg because, from what I understood, previous ones do not support the 't' variable in the scale filter.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-03-22T18:36:41.950Z
Answers.Text: What would it take for a mere mortal to learn the syntax involved in this drawing technique? could you possibly point me in the right direction? Is there similar syntax for circles and for anti-aliased shapes?
Answers.UserDisplayName: matanox
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-03-24T09:25:47.397Z
Answers.Text: Unfortunately ffmpeg syntax is quite convoluted, this question is from 1 year ago and I already forgot almost everything so can't answer your question directly. What can I say is that it requires a lot of trial and error and a lot of reading of this page here: https://ffmpeg.org/ffmpeg-filters.html
Answers.UserDisplayName: Ailef
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-05-21T08:38:01.060Z
Answers.LastActivityDate: 2020-05-21T08:38:01.060Z
Answers.UserDisplayName: Ailef
Body: <p>I need to draw a box that grows in size horizontally over a video (scaling its width as time goes by)</p>
  
  <p>Since drawbox does not support the 't' (as in time) variable, I'm at a loss here. I've seen some solutions using overlay, but they are fixed width and are rather used to move the box around.</p>
  
  <p>What's the workaround here?</p>
  
  <p><strong>EDIT</strong>
  This is where I got trying to use drawbox and scale:</p>
  
  <pre><code>ffmpeg -y -i c81e728d9d4c2f636f067f89cc14862c.mp4\
    -filter_complex "\
  [0:v]drawbox=0:0:20:20,scale=eval=frame:w='if(gte(t*20,600),600,t*20)':h=20[vb];
   [0:v][vb]overlay=x=80:y=350" a.mp4
  </code></pre>
  
  <p>With this I get an error of:</p>
  
  <pre><code>[Parsed_scale_1 @ 0x5596b5c61e40] Error when evaluating the expression 'if(gte(t*20,600),600,t*20)'.
  Maybe the expression for out_w:'if(gte(t*20,600),600,t*20)' or for out_h:'20' is self-referencing.
  </code></pre>
  
  <p>Now, if I set the width to a fixed value, it runs, but then there's the problem that the overlay contains the whole video itself as it is the input of the drawbox filter. I'm not sure how to draw the box and scale it separately from the source video.</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-05-15T09:40:50.570Z
Comments.Text: Use the scale filter after drawing the box. See https://ffmpeg.org/ffmpeg-filters.html#scale-1
Comments.UserDisplayName: Gyan
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-05-15T23:48:19.180Z
Comments.Text: Hi, thanks for the hints. I'm still unable to make it work, I'm quite a noob with ffmpeg still. I've updated my answer, it would be awesome if you could take a look at it! Thanks again
Comments.UserDisplayName: Ailef
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-05-16T06:36:59.810Z
Comments.Text: Ok, first upgrade ffmpeg to a current git version from https://johnvansickle.com/ffmpeg/. Then use the color filter to generate a stream with the initial size that you want. Then use scale to resize it. Finally overlay.
Comments.UserDisplayName: Gyan
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-03-22T18:35:21.690Z
Comments.Text: Is it only me or, is the reference documentation for drawing in ffmpeg very well hidden out there?
Comments.UserDisplayName: matanox
Tags: <ffmpeg>
Title: ffmpeg - Draw a box and scale its size with time
UserDisplayName: Ailef
ThreadText: # ffmpeg - Draw a box and scale its size with time
  
  (Asked by: username_0 on 2020-05-15)
  
  I need to draw a box that grows in size horizontally over a video (scaling its width as time goes by)
  
  Since drawbox does not support the 't' (as in time) variable, I'm at a loss here. I've seen some solutions using overlay, but they are fixed width and are rather used to move the box around.
  
  What's the workaround here?
  
  **EDIT**
  This is where I got trying to use drawbox and scale:
  
  ```
  ffmpeg -y -i c81e728d9d4c2f636f067f89cc14862c.mp4\
    -filter_complex "\
  [0:v]drawbox=0:0:20:20,scale=eval=frame:w='if(gte(t*20,600),600,t*20)':h=20[vb];
   [0:v][vb]overlay=x=80:y=350" a.mp4
  
  ```
  
  With this I get an error of:
  
  ```
  [Parsed_scale_1 @ 0x5596b5c61e40] Error when evaluating the expression 'if(gte(t*20,600),600,t*20)'.
  Maybe the expression for out_w:'if(gte(t*20,600),600,t*20)' or for out_h:'20' is self-referencing.
  
  ```
  
  Now, if I set the width to a fixed value, it runs, but then there's the problem that the overlay contains the whole video itself as it is the input of the drawbox filter. I'm not sure how to draw the box and scale it separately from the source video.
  
  **Tags:** ffmpeg
  
  > **Comments:**
  > **username_1**: Use the scale filter after drawing the box. See https://ffmpeg.org/ffmpeg-filters.html#scale-1  
  > **username_0**: Hi, thanks for the hints. I'm still unable to make it work, I'm quite a noob with ffmpeg still. I've updated my answer, it would be awesome if you could take a look at it! Thanks again  
  > **username_1**: Ok, first upgrade ffmpeg to a current git version from https://johnvansickle.com/ffmpeg/. Then use the color filter to generate a stream with the initial size that you want. Then use scale to resize it. Finally overlay.  
  > **username_2**: Is it only me or, is the reference documentation for drawing in ffmpeg very well hidden out there?  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2020-05-21. Score: 1 | Accepted answer
  
  Thanks to @username_1 comments I've been able to come up with this solution, in case somebody else is interested:
  
  ```
  color=c=red:size=1920x1080,
  scale=eval=frame:w='if(gte(t*20,600),600,t*20)':h=20[cl];
  [input][cl]overlay=x=0:y=0[finalOutput]
  
  ```
  
  Just note that it is important that you download a current git version of ffmpeg because, from what I understood, previous ones do not support the 't' variable in the scale filter.
  
  > **Comments:**
  > **username_2**: What would it take for a mere mortal to learn the syntax involved in this drawing technique? could you possibly point me in the right direction? Is there similar syntax for circles and for anti-aliased shapes?  
  > **username_0**: Unfortunately ffmpeg syntax is quite convoluted, this question is from 1 year ago and I already forgot almost everything so can't answer your question directly. What can I say is that it requires a lot of trial and error and a lot of reading of this page here: https://ffmpeg.org/ffmpeg-filters.html  
  
  ---
  
  