Changes between Version 2 and Version 3 of Scaling (resizing) with ffmpeg


Ignore:
Timestamp:
Jun 19, 2013, 9:22:55 AM (3 years ago)
Author:
laputa
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Scaling (resizing) with ffmpeg

    v2 v3  
    3131[[Image(input_double_width.png)]] 
    3232 
    33 Sometimes there is a need to scale the input image in such way it fits into a specified rectangle, i.e. if you have a placeholder (empty rectangle) in which you want to scale any given image. This is a little bit tricky, since you need to check if the width of the input image is greater than height, in order to decide which component to specify and to set the other component to -1 (to keep the aspect ratio). For example, if we would like to scale our input image into a rectangle with dimensions of 320x240, we could use something like this: 
     33Sometimes there is a need to scale the input image in such way it fits into a specified rectangle, i.e. if you have a placeholder (empty rectangle) in which you want to scale any given image. This is a little bit tricky, since you need to check the original aspect ratio, in order to decide which component to specify and to set the other component to -1 (to keep the aspect ratio). For example, if we would like to scale our input image into a rectangle with dimensions of 320x240, we could use something like this: 
    3434{{{ 
    35 ffmpeg -i input.jpg -vf scale="'if(gt(iw,ih),320,-1)':'if(gt(iw,ih),-1,240)'" output_320x240_boxed.png 
     35ffmpeg -i input.jpg -vf scale="'if(gt(a,4/3),320,-1)':'if(gt(a,4/3),-1,240)'" output_320x240_boxed.png 
    3636}}} 
    3737