2

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?

  • drawbox doesn't support time reference. What are you trying to do? – Gyan Feb 21 '18 at 17:37
  • 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 Feb 22 '18 at 14:03
1

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.

  • 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 Feb 23 '18 at 10:49

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.