<h1>Use the <a href="https://ffmpeg.org/ffmpeg-filters.html#overlay" rel="noreferrer">overlay filter</a></h1>

<p>This will overlay the video on top of the image:</p>

<pre><code>ffmpeg -loop 1 -i image.png -i video.mp4 -filter_complex "overlay=(W-w)/2:shortest=1" output.mp4
</code></pre>

<p>If you need to resize the video then add the <a href="http://ffmpeg.org/ffmpeg-filters.html#scale" rel="noreferrer">scale filter</a>:</p>

<pre><code>ffmpeg -loop 1 -i image.png -i video.mp4 -filter_complex "[1:v]scale=400:-1[fg];[0:v][fg]overlay=(W-w)/2:(H-h)/2:shortest=1" output.mp4
</code></pre>

<h1>You can use pad filter instead of an image</h1>

<p>If you just want to add black padding you don't need an image and can use the <a href="https://ffmpeg.org/ffmpeg-filters.html#pad" rel="noreferrer">pad filter</a>.</p>

<pre><code>ffmpeg -i video.mp4 -filter_complex "pad=1280:0:(ow-iw)/2" output.mp4
</code></pre>

<h1>Using the player to do it instead</h1>

<p>You could add the padding upon playback so you don't even need to re-encode:</p>

<pre><code>ffplay -vf "pad=1280:0:(ow-iw)/2" input.mp4
</code></pre>

CC BY-SA 3.0
2015-11-25T14:11:47.540Z
thanks you sir! It's work :-bd
by the way, Can u give me another favor !?
If my video isn't 400x300, for example 500x350. and I wanna make it fit to 400x300 then do the action 'v mentioned . 
I always use cmd:"ffmpeg -i 1.mp4 -s 400x300 -c:a copy output.mp4"
So how could we convert the video to 400x300 then add image in one command !!
pls help me.  thx so much!!!
OYAKHILOME JOSHUA
CC BY-SA 3.0
2015-11-25T18:33:22.573Z
@OYAKHILOMEJOSHUA I added an example using the scale filter. If the answer is good you can accept it by clicking on the green arrow to the left.
llogan
CC BY-SA 3.0
2015-11-25T19:06:50.073Z
I think you should clarify that your scale will output 400x280 for his hypothetical input of 500x350 instead of 400x300, and thus leave blank space above and below. -1:300 may be a better option, assuming that he doesn't want to distort the image.
Gyan
CC BY-SA 3.0
2015-11-26T09:52:55.933Z
Thanks you so much for supporting me !!!! 
My code skills is too bad T-T
Because i working on asian media business, there are too much suck random resolution (ex: 520x423, 427x340, 608x260, etc) it's make me confused all the time. all i wanna do is :
"with one cmd, we can fit them on constant resolution ex: 600x400, then add the image as we've mentioned"
pls help me @@
OYAKHILOME JOSHUA
CC BY-SA 3.0
2015-11-24T03:32:12.603Z
2015-11-25T18:32:20.300Z
2015-11-25T18:32:20.300Z
llogan
<p>I have one video (400x300) and an image (1280x300).
pls show me how can i put this image behind the video like that:
i've try, but not working T-T</p>

<p><a href="https://i.sstatic.net/w7PB5.png" rel="noreferrer"><img src="https://i.sstatic.net/w7PB5.png" alt="enter image description here"></a></p>

<ffmpeg>
How do i put the image behind video by using FFmpeg?
OYAKHILOME JOSHUA
# How do i put the image behind video by using FFmpeg?

(Asked by: username_0 on 2015-11-23)

I have one video (400x300) and an image (1280x300).
pls show me how can i put this image behind the video like that:
i've try, but not working T-T

[![enter image description here](https://i.sstatic.net/w7PB5.png)](https://i.sstatic.net/w7PB5.png)

**Tags:** ffmpeg


---

## 1 answers

### Answer by username_1 on 2015-11-24. Score: 10 | Accepted answer

Use the overlay filter
This will overlay the video on top of the image:
ffmpeg -loop 1 -i image.png -i video.mp4 -filter_complex "overlay=(W-w)/2:shortest=1" output.mp4

If you need to resize the video then add the scale filter:
ffmpeg -loop 1 -i image.png -i video.mp4 -filter_complex "[1:v]scale=400:-1[fg];[0:v][fg]overlay=(W-w)/2:(H-h)/2:shortest=1" output.mp4

You can use pad filter instead of an image
If you just want to add black padding you don't need an image and can use the pad filter.
ffmpeg -i video.mp4 -filter_complex "pad=1280:0:(ow-iw)/2" output.mp4

Using the player to do it instead
You could add the padding upon playback so you don't even need to re-encode:
ffplay -vf "pad=1280:0:(ow-iw)/2" input.mp4

> **Comments:**
> **username_0**: thanks you sir! It's work :-bd by the way, Can u give me another favor !? If my video isn't 400x300, for example 500x350. and I wanna make it fit to 400x300 then do the action 'v mentioned .  I always use cmd:"ffmpeg -i 1.mp4 -s 400x300 -c:a copy output.mp4" So how could we convert the video to 400x300 then add image in one command !! pls help me.  thx so much!!!  
> **username_1**: @OYAKHILOMEJOSHUA I added an example using the scale filter. If the answer is good you can accept it by clicking on the green arrow to the left.  
> **username_2**: I think you should clarify that your scale will output 400x280 for his hypothetical input of 500x350 instead of 400x300, and thus leave blank space above and below. -1:300 may be a better option, assuming that he doesn't want to distort the image.  
> **username_0**: Thanks you so much for supporting me !!!!  My code skills is too bad T-T Because i working on asian media business, there are too much suck random resolution (ex: 520x423, 427x340, 608x260, etc) it's make me confused all the time. all i wanna do is : "with one cmd, we can fit them on constant resolution ex: 600x400, then add the image as we've mentioned" pls help me @@  

---

