2

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

4

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
| improve this answer | |
  • 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 Nov 25 '15 at 14:11
  • @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 Nov 25 '15 at 18:33
  • 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 Nov 25 '15 at 19:06
  • 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 Nov 26 '15 at 9:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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