2

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.

3
  • Use the scale filter after drawing the box. See ffmpeg.org/ffmpeg-filters.html#scale-1 – Gyan May 15 '20 at 9:40
  • 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 – The Coding Monk May 15 '20 at 23:48
  • Ok, first upgrade ffmpeg to a current git version from 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. – Gyan May 16 '20 at 6:36
1

Thanks to @Gyan 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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.