Sideway
output.to from Sideway
Draft for Information Only

Content

Image Resizing
 Switch: -filter; -vf; -filter_complex
  Syntax
  Switch option: -filter scale; -vf scale; -filter_complex scale
   Syntax
   Arguments
   Optional Sub-Options
    Sub-option: width, w; height, h
    Sub-option: eval
    Sub-option: interl
    Sub-option: flags
    Sub-options: param0; param1
    Sub-option: size, s
    Sub-options: in_color_matrix; out_color_matrix
    Sub-options: in_range; out_range
    Sub-options: force_original_aspect_ratio
    Sub-options: force_divisible_by
   Defined Constants for w and h
   Remarks
   Code Examples
 Switch -s
  Syntax
  Arguments
  Remarks
  Code Examples
 Source and Reference

Image Resizing

Digital graphic pictures on a media of output are presented by mapping the pixel elements of graphic image to the tiny pixel blocks of the media of output. Since the construction and size of the pixel block depends on the media of output used, the mapping process is usually done by ethe media of output. For both the media of output and digital graphic image, the more pixels mean the higher resolution and the better image quality. However, the higher the image resolution, the bigger the image size required.
In general, there are types of digital graphic pictures, namely raster graphics and vector graphics. Raster graphics is a bitmap image that made out of a matrix of small dots, called pixels. Examples of bitmap image file formats are JPEG, GIF, and PNG. A vector graphics is computer graphic image that is made up of polygons and other shapes constructed by connecting lines and curve on specified 2D coordinate points. Example of vector graphic image format is SVG. The property of computer graphics used by vector graphics enables the computer graphic image to be scaled up or down without losing resolution, while this is impossible to be done on bitmap image.
Since the media of output usually support rasterised bitmap image only, a computer graphic image is always rasterised into a grid of pixels before being outputted onto the media of output. However, a higher image quality can still be obtained from computer graphics image than bitmap image during resizing.
During scaling a digital graphic image, apart from the size of image, some other factors that affecting the image quality must also be considered. For examples
  • the scaling algorithm
  • the pixel format
  • the color range
  • the dithering algorithm.
  • the alpha blending
  • the interlacing mode
  • the color space type
  • the YCbCr sample range
  • the aspect ratio
Resizing of an image includes The resizing of an image in FFmpeg can be done by specifying the corresponding switches accordingly. The switches used for resizing an image are -filter scale, -vf scale, and -filter_complex scale through filter switch, or -s through option switch.

Switch: -filter; -vf; -filter_complex

Simple filtergraphs are those that have exactly one input and output, both of the same type. Simple filtergraphs are configured with the per-stream -filter option (with -vf and -af aliases for video and audio respectively).
Complex filtergraphs are those which cannot be described as simply a linear processing chain applied to one stream. This is the case, for example, when the graph has more than one input and/or output, or when output stream type is different from input. Complex filtergraphs are configured with the -filter_complex option. Note that this option is global, since a complex filtergraph, by its nature, cannot be unambiguously associated with a single stream or file. The -lavfi option is equivalent to -filter_complex.

Syntax

-filter[:stream_specifier] switch_option
-vf switch_option
-filter_complex switch_options

Switch option: -filter scale; -vf scale; -filter_complex scale

to scale or resize the input video

Syntax

-filter[:stream_specifier] scale=options
-vf scale=options
-filter_complex scale=options

Arguments

:Separator stream_specifierOptional. If qscale is used without a stream_specifier then qscale applies only to the video stream. vto specify a video stream ato specify an audio stream sto specify a subtitle stream scaleswitch-option: to scale or resize the input video. =operator optionsoptional sub-options for scaling manipulation

Optional Sub-Options

Sub-option: width, w; height, h
to set the width and height of output video accordingly.
Syntax
[width=]integer
[w=]integer
[height=]integer
[h=]integer
    
Arguments
=operator integerto specify the width and height dimkension.
Remarks
Default value is the input dimension.
If the width, w value is 0, the input width is used for the output.
If the height, h value is 0, the input height is used for the output.
if either width, w value or height, h is -n with n>=1, the scale filter will be use a value that maintains the aspect ratio of the input image, calculated from the other specified dimensio. After that it will, however, make sure that the calculated dimension is divisible by n and adjust the value if necessary.
if both values are -n with n>=1, the behavior will be identical to both values set to 0.
Some defined constants are also accepted.
'width=' and 'w=' can be omitted if the value is the first parameter. 'height=' and 'h=' can be omitted if the value is the second parameter .
Sub-option: eval
to specify when to evaluate width and height expression.
Syntax
eval=method
Arguments
=operator methodto specify the value of defined evaluation method.
Value
initOnly evaluate expressions once during the filter initialization or when a command is processed. frameEvaluate expressions for each incoming frame.
Remarks
Default value is 'init'.
Sub-option: interl
to set the interlacing mode..
Syntax
interl=mode
Arguments
=operator modeto specify the value of defined mode.
Value
1Force interlaced aware scaling. 0Do not apply interlaced scaling. -1Select interlaced aware scaling depending on whether the source frames are flagged as interlaced or not.
Remarks
Default value is ‘0’.
Sub-option: flags
to set libswscale scaling flags.
Syntax
flag=method
Arguments
=operator methodto specify the value of defined mothod.
Value
fast_bilinearSelect fast bilinear scaling algorithm. bilinearSelect bilinear scaling algorithm. bicubicSelect bicubic scaling algorithm. experimentalSelect experimental scaling algorithm. neighborSelect nearest neighbor rescaling algorithm. areaSelect averaging area rescaling algorithm. bicublinSelect bicubic scaling algorithm. gaussSelect Gaussian rescaling algorithm. sincSelect sinc rescaling algorithm. lanczosSelect Lanczos rescaling algorithm. The default width (alpha) is 3 and can be changed by setting param0. splineSelect natural bicubic spline rescaling algorithm. print_infoEnable printing/debug logging. accurate_rndEnable accurate rounding. full_chroma_intEnable full chroma interpolation. full_chroma_inpSelect full chroma input. bitexactEnable bitexact output.
Remarks
If not explicitly specified the filter applies the default flags.
Sub-options: param0; param1
to set the additional libswscale input parameters required for specifying scaling algorithms.
Syntax
param0=value
param1=value
Arguments
=operator valueto specify the value of the corresponding parameter
Remarks
If not explicitly specified the filter applies empty parameters.
Sub-option: size, s
to set the video size.
Syntax
size=value
Arguments
=operator valuea string of the form widthxheight, or the name of a size abbreviation.
Values
widthxheightThe format is 'wxh' or 'w:h' where 'x' and ':' are the separator, 'w' is the width and 'h' is the height. Unit is in pixel. Default is same as source. ntsc720x480 pal720x576 qntsc352x240 qpal352x288 sntsc640x480 spal768x576 film352x240 ntsc-film352x240 sqcif128x96 qcif176x144 cif352x288 4cif704x576 16cif1408x1152 qqvga160x120 qvga320x240 vga640x480 svga800x600 xga1024x768 uxga1600x1200 qxga2048x1536 sxga1280x1024 qsxga2560x2048 hsxga5120x4096 wvga852x480 wxga1366x768 wsxga1600x1024 wuxga1920x1200 woxga2560x1600 wqsxga3200x2048 wquxga3840x2400 whsxga6400x4096 whuxga7680x4800 cga320x200 ega640x350 hd480852x480 hd7201280x720 hd10801920x1080 2k2048x1080 2kflat1998x1080 2kscope2048x858 4k4096x2160 4kflat3996x2160 4kscope4096x1716 nhd640x360 hqvga240x160 wqvga400x240 fwqvga432x240 hvga480x320 qhd960x540 2kdci2048x1080 4kdci4096x2160 uhd21603840x2160 uhd43207680x4320
Sub-options: in_color_matrix; out_color_matrix
to set the in or output YCbCr color space type.
Syntax
in_color_matrix=value
out_color_matrix=value
Arguments
=operator valueto specify the defined YCbCr color space type
Values
autoChoose automatically. bt709Format conforming to International Telecommunication Union (ITU) Recommendation BT.709 fccSet color space conforming to the United States Federal Communications Commission (FCC) Code of Federal Regulations (CFR) Title 47 (2003) 73.682 (a). bt601Set color space conforming to ITU Radiocommunication Sector (ITU-R) Recommendation BT.601 bt470Set color space conforming to ITU-R Rec. BT.470-6 (1998) Systems B, B1, and G smpte170mSet color space conforming to Society of Motion Picture and Television Engineers (SMPTE) ST 170:2004 smpte240mSet color space conforming to SMPTE ST 240:1999. bt2020Set color space conforming to ITU-R BT.2020 non-constant luminance system.
Remarks
This allows the autodetected value to be overridden as well as allows forcing a specific value used for the output and encoder. If not specified, the color space type depends on the pixel format.
Sub-options: in_range; out_range
Set in or output YCbCr sample range.
Syntax
in_range=value
out_range=value
Arguments
=operator valueto specify the defined in or output YCbCr sample range.
Value
auto/unknownChoose automatically. jpeg/full/pcSet full range (0-255 in case of 8-bit luma). mpeg/limited/tvSet "MPEG" range (16-235 in case of 8-bit luma).
Remarks
This allows the autodetected value to be overridden as well as allows forcing a specific value used for the output and encoder. If not specified, the range depends on the pixel format.
Sub-options: force_original_aspect_ratio
Enable decreasing or increasing output video width or height if necessary to keep the original aspect ratio.
Syntax
force_original_aspect_ratio=value
Arguments
=operator valueto specify the defined force_original_aspect_ratio.
Value
disableScale the video as specified and disable this feature. decreaseThe output video dimensions will automatically be decreased if needed. increaseThe output video dimensions will automatically be increased if needed.
Remarks
One useful instance of this option is that when you know a specific device’s maximum allowed resolution, you can use this to limit the output video to that, while retaining the aspect ratio. For example, device A allows 1280x720 playback, and your video is 1920x800. Using this option (set it to decrease) and specifying 1280x720 to the command line makes the output 1280x533. Please note that this is a different thing than specifying -1 for w or h, you still need to specify the output resolution for this option to work.
Sub-options: force_divisible_by
Ensures that both the output dimensions, width and height, are divisible by the given integer when used together with force_original_aspect_ratio. This works similar to using -n in the w and h options.
Syntax
force_divisible_by=value
Arguments
=operator valueto enable the force_divisible_by flag.
Remarks
This option respects the value set for force_original_aspect_ratio, increasing or decreasing the resolution accordingly. The video’s aspect ratio may be slightly modified. This option can be handy if you need to have a video fit within or exceed a defined resolution using force_original_aspect_ratio but also have encoder restrictions on width or height divisibility.

Defined Constants for w and h

The values of the w and h options are expressions are in_w; in_hThe correspond input width and height iw; ihThe correspond input width and height that are same as in_w; in_h accordingly out_w; out_h<The corresponding output (scaled) width and height ow; ohThe correspond input width and height that are same as out_w; out_h accordingly aThe same as iw and ih accordingly sarinput sample aspec ratio darThe input display aspect ratio. Calculated from (iw/ih)*sar. hsub; vsubhorizontal and vertical input chroma subsample values. For example, pixel format 'yuv422p' implies hsub is 2 and vsub is 1. ohsub; ovsubhorizontal and vertical output chroma subsample values. For example, pixel format 'yuv422p' implies hsub is 2 and vsub is 1.

Remarks

Scale (resize) the input video, using the libswscale library. The scale filter forces the output display aspect ratio to be the same of the input, by changing the output sample aspect ratio. If the input image format is different from the format requested by the next filter, the scale filter will convert the input to the requested format.

Code Examples

Resize PNG Picture by '-filter scale=size'
Example to resize a png picture by -filter scale=size.
ffmpeg -hide_banner -i in\dt16001024.png -filter scale=400x256 out\resize400256_01a.png
Command result image
Resize PNG Picture by '-vf scale=size'
Example to resize a png picture by '-vf scale=size'.
ffmpeg -hide_banner -i in\dt16001024.png -vf scale=400x256 out\resize400256_02a.png
Command result image
Resize PNG Picture by '-filter_complex scale=size'
Example to resize a png picture by -filter_complex scale=size.
ffmpeg -hide_banner -i in\dt16001024.png -filter_complex scale=400:256 out\resize400256_03a.png
Command result image

Switch -s

to set frame size

Syntax

-s[:stream_specifier] size

Arguments

:Separator stream_specifierOptional. If qscale is used without a stream_specifier then qscale applies only to the video stream. vto specify a video stream ato specify an audio stream sto specify a subtitle stream sizeThe format is 'wxh' or 'w:h' where 'x' and ':' are the separator, 'w' is the width and 'h' is the height. Unit is in pixel. Default value for output is same as source.

Remarks

As an input option, this is a shortcut for the video_size private option, recognized by some demuxers for which the frame size is either not stored in the file or is configurable – e.g. raw video or video grabbers.
As an output option, the scale video filter is inserted to the end of the corresponding filtergraph. But better use the scale filter directly to insert it at the beginning or some other place.

Code Examples

Resize PNG Picture by '-s size'
Example to resize a png picture by -s size.
ffmpeg -hide_banner -i in\dt16001024.png -s 400x256 out\resize400256_04a.png
Command result image
Resize PNG Picture by '-s size'
Example to resize a png picture by -s size.
ffmpeg -hide_banner -i in\dt16001024.png -s 400:256 out\resize400256_05a.png
Command result image

Source and Reference

https://ffmpeg.org/ffmpeg.html
https://ffmpeg.org/ffmpeg-all.html#scale-1
http://ffmpeg.org/ffmpeg-filters.html
https://ffmpeg.org/ffmpeg-scaler.html
https://trac.ffmpeg.org/wiki/Scaling
https://trac.ffmpeg.org/wiki/FilteringGuide

©sideway

ID: 200102002 Last Updated: 1/20/2020 Revision: 0


Latest Updated LinksValid XHTML 1.0 Transitional Valid CSS!Nu Html Checker Firefox53 Chromena IExplorerna
IMAGE

Home 5

Business

Management

HBR 3

Information

Recreation

Hobbies 8

Culture

Chinese 1097

English 339

Reference 79

Computer

Hardware 249

Software

Application 213

Digitization 32

Latex 52

Manim 205

KB 1

Numeric 19

Programming

Web 289

Unicode 504

HTML 66

CSS 65

SVG 46

ASP.NET 270

OS 429

DeskTop 7

Python 72

Knowledge

Mathematics

Formulas 8

Algebra 84

Number Theory 206

Trigonometry 31

Geometry 34

Coordinate Geometry 2

Calculus 67

Complex Analysis 21

Engineering

Tables 8

Mechanical

Mechanics 1

Rigid Bodies

Statics 92

Dynamics 37

Fluid 5

Fluid Kinematics 5

Control

Process Control 1

Acoustics 19

FiniteElement 2

Natural Sciences

Matter 1

Electric 27

Biology 1

Geography 1


Copyright © 2000-2024 Sideway . All rights reserved Disclaimers last modified on 06 September 2019