I have a video that i want to map to a "virtual rectangle". Meaning, i want to create a virtual rectangle by giving it one x,y point for the bottom left corner and one x,y point for the top right corner.

Given those 2 points would create a rectangle, i want to take that video and "map" it to that rectangle. (scale it too if necessary)

From what i know about the 'overlay' filter, you can use only one x,y point to set the position of the video.

But is there a way of doing it with 2 points like i explained?


1 Answer 1


You would use the template below,

ffmpeg -i base.mp4 -i overlay.mp4 -filter_complex "[1]scale=WxH[o];[0][o]overlay=x:y" out.mp4

So, the overlay video is scaled and then placed at (x,y) measured from top-left of base video and the opposite corner is at (x+W, y+H)

  • so that means i'd have to provide the scale width and height too right? it won't be done automatically
    – Gambit2007
    Jun 8, 2016 at 17:03
  • Yeah, but your desired scenario also requires four numbers. The last two happen to be different.
    – Gyan
    Jun 8, 2016 at 17:09
  • So i'd have to provide x1,y1 and W,H and only then i'd be able to get x2,y2? There's no way of inputing x1,y1 and x2,y2 and have the W,H calculated automatically?
    – Gambit2007
    Jun 8, 2016 at 17:12
  • No. It's the same thing though. Think of W as x2-x1 and H as y2-y1
    – Gyan
    Jun 8, 2016 at 17:21
  • Haha you're right sorry.. thanks!! You save me every time when it comes to ffmpeg ;)
    – Gambit2007
    Jun 8, 2016 at 17:23

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.