<p>You would use the template below,</p>

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

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

CC BY-SA 3.0
2016-06-08T17:03:47.577Z
so that means i'd have to provide the scale width and height too right? it won't be done automatically
Gambit2007
CC BY-SA 3.0
2016-06-08T17:09:43.527Z
Yeah, but your desired scenario also requires four numbers. The last two happen to be different.
Gyan
CC BY-SA 3.0
2016-06-08T17:12:46.400Z
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
CC BY-SA 3.0
2016-06-08T17:21:16.300Z
No. It's the same thing though. Think of W as `x2-x1` and H as `y2-y1`
Gyan
CC BY-SA 3.0
2016-06-08T17:23:56.363Z
Haha you're right sorry.. thanks!! You save me every time when it comes to ffmpeg ;)
Gambit2007
CC BY-SA 3.0
2016-06-08T16:52:03.927Z
2016-06-08T16:52:03.927Z
Gyan
<p>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. </p>

<p>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)</p>

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

<p>But is there a way of doing it with 2 points like i explained?</p>

<p>Thanks!</p>

<ffmpeg>
ffmpeg - map a video to a placeholder? (rectangle/square)
Gambit2007
# ffmpeg - map a video to a placeholder? (rectangle/square)

(Asked by: username_0 on 2016-06-08)

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?

Thanks!

**Tags:** ffmpeg


---

## 1 answers

### Answer by username_1 on 2016-06-08. Score: 0 | Accepted answer

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)

> **Comments:**
> **username_0**: so that means i'd have to provide the scale width and height too right? it won't be done automatically  
> **username_1**: Yeah, but your desired scenario also requires four numbers. The last two happen to be different.  
> **username_0**: 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?  
> **username_1**: No. It's the same thing though. Think of W as `x2-x1` and H as `y2-y1`  
> **username_0**: Haha you're right sorry.. thanks!! You save me every time when it comes to ffmpeg ;)  

---

