Maintaining Aspect Ratio Using FFmpeg

1

1

Is there any way to tell ffmpeg to preserve the aspect ratio when resizing a video by adding padding in the shorter dimension? I know that I can do it by manually adding the proper amount of padding, but I am converting many videos of arbitrary sizes, and I cannot do each one manually. I read somewhere that the -s option used to do this, but it does not any more. To clarify, I am not looking to fix the height and let the width be whatever it needs to be to preserve the ratio (as I have seen in other questions).

user130039

Posted 2012-05-12T14:37:12.993

Reputation:

By "adding padding", you mean pillar- or letterboxing? – slhck – 2012-05-12T17:53:22.257

@slhck: Yes, I do. – None – 2012-05-12T18:12:21.907

Do you want a fixed width? – llogan – 2012-05-13T03:19:56.410

@LordNeckbeard: I want to fix the width and the height but have it pillar- or letterboxed to preserve the aspect ratio. – None – 2012-05-13T11:36:25.637

Answers

0

Is there any way to preserve the aspect ratio when resizing a video by adding padding in the shorter dimension?

ffmpeg -i 01.jpg -vf scale=-1:360,pad=640:ih:(ow-iw)/2 -qmax 1 360-01.jpg

I havent used this command in a while so YMMV.

FFmpeg slideshow

Steven Penny

Posted 2012-05-12T14:37:12.993

Reputation: 7 294