ffmpeg方形调整大小无法正确调整大小

时间:2019-04-15 20:32:33

标签: ffmpeg

我正在尝试将视频调整为1:1 640x640方形格式。

ffmpeg -i /Users/yagiz/Desktop/video-creator/whats-unfinished.mp4 -y -vcodec libx264 -filter:v scale=w='if(gt(a,1),640,trunc(640*a/2)*2)':h='if(lt(a,1),640,trunc(640/a/2)*2)',pad=w=640:h=640:x='if(gt(a,1),0,(640-iw)/2)':y='if(lt(a,1),0,(640-ih)/2)':color=black /Users/yagiz/Desktop/video-creator/whats.mp4

处理后的视频分辨率为1152×480

但是输出是:638×640

您知道这背后的原因吗?

1 个答案:

答案 0 :(得分:0)

填充后将SAR设置为1。

ffmpeg -i /Users/yagiz/Desktop/video-creator/whats-unfinished.mp4 -y -vcodec libx264 -filter:v scale=w='if(gt(dar,1),640,trunc(640*dar/2)*2)':h='if(gt(dar,1),trunc(640/dar/2)*2,640)',pad=w=640:h=640:x='(ow-iw)/2':y='(oh-ih)/2':color=black,setsar=1 /Users/yagiz/Desktop/video-creator/whats.mp4