ffmpeg -i input.mp4 -vf "scale=(iw*sar)*min(1280/(iw*sar)\,720/ih):ih*min(1280/(iw*sar)\,720/ih), pad=1280:720:(1280-iw*min(1280/iw\,720/ih))/2:(720-ih*min(1280/iw\,720/ih))/2" output.mp4
Let me break down this command for you:
ffmpeg -i input.mp4
This is the standard input method for ffmpeg. Replace "input.mp4" with the name of your input file.
-vf
Specifies that some video filters follow in the command. The video filters that are specified are applied sequentially to each frame.
scale=(iw*sar)*min(1280/(iw*sar)\,720/ih):ih*min(1280/(iw*sar)\,720/ih)
The first filter is the scale filter. The scale filter is powerful because it can perform value substitution and math. In this case, the math computes the new scaled width and height. It will scale the input image to fit the width and/or height of the desired output format without distorting the image. You don't need to make any modifications to the scale parameters because it will automatically substitute the actual values for "iw", "sar" and "ih". In your case, since your input video is 4x3, we know that the math will work out to scale to a height of 720 but a width that is less than 1280. More info: https://ffmpeg.org/ffmpeg-filters.html#scale-1
pad=1280:720:(1280-iw*min(1280/iw\,720/ih))/2:(720-ih*min(1280/iw\,720/ih))/2
The second filter is the pad filter. It has the same math/substitution features as the scale feature. So it will figure out the exact numbers for you. You don't need to change anything to make it work. The parameters tell the pad filter to make the output 720x1280 and to place the input image in the center of the frame. The pad filter will fill the output image with black anywhere that the input image doesn't cover. In the case of your input, we know that the scale filter scaled the height to 720, but the width is short of 1280. So black bars will be added to the sides to make up the difference. More info: https://ffmpeg.org/ffmpeg-filters.html#pad
output.mp4
This specifies the output file where ffmpeg will place the results. You may need to add all kinds of parameters for format, bitrate, etc. to meet your exact needs.
1Why do you want to upscale? – llogan – 2015-03-18T20:41:33.963
1I have my reasons to do so :) – Levan – 2015-03-18T23:30:59.917