Search code examples
ffmpegandroid-ffmpegpyffmpeg

FFMPEG change videos size


How do i change a video that is 1920x1080 to 1080x1920, and then "shrink" it so that it fills only half of the 1080x1920 screen size? here is what i mean:

1920x1080 original

needs to be changed to

1080x1920 that covers 50% of screen space only


Solution

  • Use the scale filter, then the pad filter. The following command first scales the video from width x height to height x (width/2), then adds padding at the bottom, preserving the width and duplicating the height. The setsar filter changes the aspect ration for the output video. iw and ih stand for input width and height.

    ffmpeg -i input.mp4 -vf "scale=ih:iw/2,setsar=1,pad=0:ih*2" output.mp4