Say I have a video of a peculiar resolution such as 1280x718 and I want to change this to 1280x720.
But instead of interpolating 718 pixels vertically to 720, I'd rather just add one line at the top and bottom.
So basically, I'm looking for a way to tell ffmpeg to create an output video of 1280x720, where input video of 1280x718 covers up the center, and all uncovered area is black or whatever.
I guess we could call this the opposite of cropping. I know how to resize a video (with interpolation) but in this case I don't want to rescale or mess with the original content, just add a small border.
Found the answer, posting it here for reference:
ffmpeg -i input.mp4 -vcodec libx264 \
-vf "pad=width=1280:height=720:x=0:y=1:color=black" -acodec copy result.mkv
width
and height
are the intended output resolution, x
and y
are the top left coordinates (within the new output) where to place the input. color
(optional) is the border color, can also use color=0xff00ff
notation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With