Use ffmpeg to resize image

后端 未结 4 2005
挽巷
挽巷 2021-01-30 21:17

Is it possible to resize an image using FFMPEG?

I have this so far:

ffmpeg. -i 1.jpg -vf scale=360:240 > 2.jpg

I get the error messa

4条回答
  •  遇见更好的自我
    2021-01-30 21:19

    To reduce image scale to the bounding box of width:320px and height:240px.

    ffmpeg -i src_image_path -vf 'scale=if(gte(a\,320/240)\,min(320\,iw)\,-2):if(gte(a\,320/240)\,-2\,min(240\,ih))' dst_image_path

    a: aspect ratio
    iw: in width
    ih: in height
    

    If the src image size is in the bounding box do no resize on it. If image has a big aspect ration than 320/240 and width is bigger then 320, resize width to 320 and keep the aspect ration. If image has a small aspect ration than 320/240 and height is bigger then 240, resize height to 240 and keep the aspect ration.

提交回复
热议问题