[FFmpeg-user] Video resizing and cropping using ffmpeg commands in Android

Manjunath Betadur manjunath.v.betdur at gmail.com
Wed Feb 25 08:31:15 CET 2015


I have a 1080p video (1080x1920 pixels, mp4 format) and I want to convert
it to 480x480 pixels video. For this, I want to scale 1080p video to 480p
(width=480, height=any value based on the aspect ratio) and then crop it to
480x480 (cropping the bottom pixels of the frames)

Following are the ffmpeg commands I am using for scaling and cropping an
mp4 video :

For scaling,

ffmpeg -y -i /sdcard/testing1.mp4 -vf "scale=480:-1" -threads 5
-preset ultrafast -strict -2 /sdcard/testing2.mp4

scaling issue : The output is 270x480 (I don't know why it is not fixing
width as 480 pixels)

solution : I used following command,

ffmpeg -y -i /sdcard/testing1.mp4 -vf "scale=480:480" -threads 5
-preset ultrafast -strict -2 /sdcard/testing2.mp4

gave me output as 480x853 which is fine according to my requirements.


For cropping,

ffmpeg -y -i /sdcard/testing1.mp4 -vf "crop=480:480:0:0" -threads 5
-preset ultrafast -strict -2 /sdcard/testing2.mp4

Individually, both will work fine. But, I want to run a single command to
do both scaling & cropping. I tried following command and it doesn't work.

ffmpeg -y -i /sdcard/testing1.mp4 -vf "scale=480:480,
crop=480:480:0:0" -threads 5 -preset ultrafast -strict -2
/sdcard/testing2.mp4

Any suggestion is appreciated.


More information about the ffmpeg-user mailing list