Search code examples
ffmpegffmpeg-php

How can I upscale videos with FFmpeg to a fixed resolution?


Resolution of an example video: 640x788

Desired resolution of the new video: 1920x1080

The aspect ratio of the video should be kept (the area left & right should be filled black).

My current call looks like this: ffmpeg -i input.mp4 -s 1920x1080 -r 60 -aspect 1:1 -strict experimental output.mp4. The problem here is that the video is sometimes made narrower / wider (aspect ratio is not kept).

Since I am no FFmpeg expert I hope for help here (maybe there is a padding property?)


Solution

  • You would use the scale and pad filters to accomplish this.

    ffmpeg -i input.mp4 -vf scale=1920:1080:force_original_aspect_ratio=decrease,pad=1920:1080:-1:-1,setsar=1 -r 60 output.mp4
    

    Use ffmpeg v4.1 or newer for this - the -strict option hasn't been needed for typical MP4 output since 2015 so your ffmpeg build may be very old.