I tried to run the following code, but it didn't work.

ffmpeg -i input.mp4 -filter_complex [0:v]drawbox=x=100:y=100:w=100:h=100:color='r=66-ceil(48*Y/H):g=74-ceil(59*Y/H):b=199-ceil(72*Y/H)':t=fill -c:a copy output.mp4

Please teach me how to overlay a rectangular shape with a vertical gradient onto a video, with a constant duration.
I mean that I want to place an image similar to the one shown below over a video.
enter image description here

1 Answer 1


geq, overlay

ffmpeg -i input.mp4 -lavfi "
" -y out.mp4

drawtext, geq, overlay

ffmpeg -i "in 1.mp4" -lavfi "
drawtext=text='Some text'
" -c:a copy out.mp4 -y
  • Thank you! It works! Apr 17, 2023 at 7:07
  • Actually, I want to use the box above as a background for the text. Is it possible to resize the box to fit the width of the text? Apr 20, 2023 at 8:28
  • added drawtext. not tested as well Apr 20, 2023 at 10:03
  • Thank you very much! You have just made it possible for me to achieve exactly what I wanted to do. Apr 20, 2023 at 10:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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