ffmpeg resize down larger video to fit desired size and add padding

后端 未结 3 1482
一整个雨季
一整个雨季 2020-12-25 13:43

I\'m trying to resize a larger video to fit an area that I have. In order to achieve this I calculate first the dimensions of the resized video so That it fits my area, and

3条回答
  •  猫巷女王i
    2020-12-25 13:50

    Here is a generic filter expression for scaling (maintaining aspect ratio) and padding any source size to any target size:

    -vf "scale=min(iw*TARGET_HEIGHT/ih\,TARGET_WIDTH):min(TARGET_HEIGHT\,ih*TARGET_WIDTH/iw),
         pad=TARGET_WIDTH:TARGET_HEIGHT:(TARGET_WIDTH-iw)/2:(TARGET_HEIGHT-ih)/2"
    

    Replace TARGET_WIDTH and TARGET_HEIGHT with your desired values. I use this to pull a 200x120 padded thumbnail from any video. Props to davin for his nice overview of the math.

提交回复
热议问题