ffmpeg scale & crop video

 

http://stackoverflow.com/questions/31042852/ffmpeg-command-to-crop-and-transpose-video-comes-out-zoomed-in-bad-quality

原问题:

I’m trying to convert an mp4 video with dimensions usually 960x720 into a sqaure 480:480 video but it comes out looking squished usually, the command is

"-y -i %s -vf crop=480:480,transpose=%d -threads 5 -metadata:s:v rotate=0 -c:v libx264 -crf 27 -preset ultrafast -c:a copy -bsf:a aac_adtstoasc %s";

Am I missing something, do I need to down scale first or something?

回答:

ffmpeg -i input.file -s 480x480 -vf crop=480:480,setdar=1:1,setsar=1:1 output.mp4

-s will set scale (video canvas area)

crop=480:480 will crop from centre.. if you need from specific use: crop=480:480:pos-X:pos-Y

setdar will set Display Aspect Ratio

setsar will set Sample Aspect Ratio

Results: (screen grabbed MP4 stills via MPC-Home Cinema)

enter image description here