Changes between Version 53 and Version 54 of Scaling


Ignore:
Timestamp:
Jun 9, 2024, 6:00:20 AM (2 years ago)
Author:
MasterQuestionable
Comment:

Explanation on fitting. ͏"pad" example.

Legend:

Unmodified
Added
Removed
Modified
  • Scaling

    v53 v54  
    5050== Simple Rescaling ==
    5151
    52 If you need to simply resize your video to a specific size (e.g 320×240), you can use the scale filter in its most basic form:
     52If you need to simply resize your video to a specific size (e.g 320x240), you can use the scale filter in its most basic form:
    5353{{{
    5454ffmpeg -i input.avi -vf scale=320:240 output.avi
    … …  
    7272will set the width of the output image to 320 pixels and will calculate the height of the output image according to the aspect ratio of the input image.
    7373
    74 The resulting image will have a dimension of 320×207 pixels.\\
     74The resulting image will have a dimension of 320x207 pixels.\\
    7575[[Image( "input.jpg", 320px )]]
    7676
    … …  
    7979ffmpeg -i input.jpg -vf scale=320:-2 output_320.png
    8080}}}
    81 The output will now be 320×206 pixels.
     81The output will now be 320x206 pixels.
    8282
    8383
    … …  
    121121
    122122
    123 == Fitting into a Rectangle / Statically-sized Player ==
    124 
    125 Sometimes you need to scale the input image so that it fits into a specified rectangle, e.g. when consolidating material from different sources.
    126 
    127 You can achieve this with the `force_original_aspect_ratio` option. It has two possible values:
    128 * `decrease`: The output video dimensions will automatically be decreased if needed.
    129 * `increase`: The output video dimensions will automatically be increased if needed.
    130 
    131 This allows you to force the image to fit into a 320×240 box, downscaling it with the correct aspect ratio:
    132 {{{
    133 ffmpeg -i input.jpg -vf scale=w=320:h=240:force_original_aspect_ratio=decrease output_320.png
    134 }}}
    135 
    136 This produces our 320×207 image that we had seen [#KeepingtheAspectRatio before].\\
     123== Fitting into a Rectangle / Statically-sized Player == #fit
     124
     125Sometimes you need to scale the input image so that it fits into a specified rectangle, e.g. when consolidating material from different sources.\\
     126͏    Achievable with "force_original_aspect_ratio". Accepts 3 possible values:\\
     127͏    |0| "disable" (default)\\
     128͏    |1| "decrease": auto-decrease output dimensions on need.\\
     129͏    |2| "increase": auto-increase output dimensions on need.
     130
     131This allows you to force the image to fit into a 320x240 box, downscaling it with the correct aspect ratio:
     132{{{#!shell
     133ffmpeg -i "input.jpg" -vf "scale=w=320:h=240:force_original_aspect_ratio=decrease" "output_320.png"
     134}}}
     135
     136This produces our 320x207 image that we had seen [#KeepingtheAspectRatio before].\\
    137137[[Image( "input.jpg", 320px )]]
    138138
    139 You may have additional constraints such as adding black bars (pillar- and letterboxing) to fill up the remaining space when scaling to a certain rectangle. You can additionally add a black border using the `pad` filter:
    140 {{{
    141 ffmpeg -i input.jpg -vf "scale=320:240:force_original_aspect_ratio=decrease,pad=320:240:(ow-iw)/2:(oh-ih)/2" output_320_padding.png
    142 }}}
     139͏    You may have additional constraints such as adding black bars (pillar- and letterboxing) to fill up the remaining space when scaling to a certain rectangle.\\
     140͏    You can additionally add a black border using the [https://ffmpeg.org/ffmpeg-filters.html#pad ͏"pad"] filter:\\
     141͏    `ffmpeg -i "input.jpg" -vf "scale=320:240:force_original_aspect_ratio=1,pad=320:240:(( (ow - iw)/2 )):(( (oh - ih)/2 ))" "output_320_padding.png"`
    143142{{{#!div style="display: inline-block; margin-left: 0; overflow: hidden; width: 320px; height: 240px; padding: 0; background-color: #000"
    144143[[Image( "input.jpg", width="100%" )]]