<p>I'll assume the window area is 1004x512. You can adjust the command below after getting the exact values.</p>

<pre><code>ffmpeg -i video -i frame -filter_complex
       "[0]scale=1004x512:force_original_aspect_ratio=decrease,
           pad=1024:1024:10+(1004-iw)/2:10+(512-ih)/2[vid];
        [vid][1]overlay"  output
</code></pre>

<p>The <code>10</code> in the pad expressions represent the border thickness.</p>

CC BY-SA 4.0
2018-10-02T05:18:41.023Z
2018-10-02T05:18:41.023Z
Gyan
<p><a href="https://i.sstatic.net/Bxni0.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/Bxni0.png" alt="The image to be overlaid"></a></p>

<p>I have an image which is a frame of 1024×1024 resolution which is half empty or transparent... I have various number of videos of different resolutions and I want to scale them to the empty space width and height(might be 1024×512) by keeping the aspect ratio of the video unchanged and I want to add padding for the empty space.</p>

<p>Whenever I'm trying to overlay the image over the video, the output video is in the resolution same as the input video's because of which half of the frame (input image) is getting cut in the output video.</p>

<p>I need help... I want the output video to have the resolution of the input image not of the input video's. It should more or less look like PIP. Can I do that on FFmpeg??</p>

CC BY-SA 4.0
2018-09-30T15:23:41.903Z
What is the size of the window area?
Gyan
CC BY-SA 4.0
2018-10-01T16:13:18.167Z
I'm not sure actually ... But consider it around width~1024 and height=512..So almost 1024*512. Like height is half the image size and width is almost the same.
Sandeep Yadav
<ffmpeg><video-editor><editing><android>
Overlay an Image onto a resized video. FFMPEG
Sandeep Yadav
# Overlay an Image onto a resized video. FFMPEG

(Asked by: username_0 on 2018-09-30)

[![The image to be overlaid](https://i.sstatic.net/Bxni0.png)](https://i.sstatic.net/Bxni0.png)

I have an image which is a frame of 1024×1024 resolution which is half empty or transparent... I have various number of videos of different resolutions and I want to scale them to the empty space width and height(might be 1024×512) by keeping the aspect ratio of the video unchanged and I want to add padding for the empty space.

Whenever I'm trying to overlay the image over the video, the output video is in the resolution same as the input video's because of which half of the frame (input image) is getting cut in the output video.

I need help... I want the output video to have the resolution of the input image not of the input video's. It should more or less look like PIP. Can I do that on FFmpeg??

**Tags:** ffmpeg, video-editor, editing, android

> **Comments:**
> **username_1**: What is the size of the window area?  
> **username_0**: I'm not sure actually ... But consider it around width~1024 and height=512..So almost 1024*512. Like height is half the image size and width is almost the same.  

---

## 1 answers

### Answer by username_1 on 2018-10-02. Score: 1

I'll assume the window area is 1004x512. You can adjust the command below after getting the exact values.
ffmpeg -i video -i frame -filter_complex
       "[0]scale=1004x512:force_original_aspect_ratio=decrease,
           pad=1024:1024:10+(1004-iw)/2:10+(512-ih)/2[vid];
        [vid][1]overlay"  output

The 10 in the pad expressions represent the border thickness.


---

