Draft for Information Only
ContentImage Resizing
Image ResizingDigital 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
Switch: -filter; -vf; -filter_complexSimple 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 scaleto scale or resize the input videoSyntax-filter[:stream_specifier] scale=options -vf scale=options -filter_complex scale=options Arguments:Separator stream_specifierOptional. Ifscaleswitch-option: to scale or resize the input video. =operator optionsoptional sub-options for scaling manipulation Optional Sub-OptionsSub-option: width, w; height, hto 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.RemarksDefault 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: evalto specify when to evaluateSyntaxeval=method Arguments=operator methodto specify the value of defined evaluation method.ValueinitOnly evaluate expressions once during the filter initialization or when a command is processed. frameEvaluate expressions for each incoming frame.RemarksDefault value is 'init'.Sub-option: interlto set the interlacing mode..Syntaxinterl=mode Arguments=operator modeto specify the value of defined mode.Value1Force interlaced aware scaling. 0Do not apply interlaced scaling. -1Select interlaced aware scaling depending on whether the source frames are flagged as interlaced or not.RemarksDefault value is ‘0’.Sub-option: flagsto set libswscale scaling flags.Syntaxflag=method Arguments=operator methodto specify the value of defined mothod.Valuefast_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.RemarksIf not explicitly specified the filter applies the default flags.Sub-options: param0; param1to set the additional libswscale input parameters required for specifying scaling algorithms.Syntaxparam0=value param1=value Arguments=operator valueto specify the value of the corresponding parameterRemarksIf not explicitly specified the filter applies empty parameters.Sub-option: size, sto set the video size.Syntaxsize=value Arguments=operator valuea string of the form widthxheight, or the name of a size abbreviation.ValueswidthxheightThe 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 uhd43207680x4320Sub-options: in_color_matrix; out_color_matrixto set the in or output YCbCr color space type.Syntaxin_color_matrix=value out_color_matrix=value Arguments=operator valueto specify the defined YCbCr color space typeValuesautoChoose 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.RemarksThis 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_rangeSet in or output YCbCr sample range.Syntaxin_range=value out_range=value Arguments=operator valueto specify the defined in or output YCbCr sample range.Valueauto/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).RemarksThis 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_ratioEnable decreasing or increasing output video width or height if necessary to keep the original aspect ratio.Syntaxforce_original_aspect_ratio=value Arguments=operator valueto specify the defined force_original_aspect_ratio.ValuedisableScale 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.RemarksOne 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_byEnsures 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.Syntaxforce_divisible_by=value Arguments=operator valueto enable the force_divisible_by flag.RemarksThis 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 hThe 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.RemarksScale (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 ExamplesResize PNG Picture by '-filter scale=size'Example to resize a png picture byffmpeg -hide_banner -i in\dt16001024.png -filter scale=400x256 out\resize400256_01a.pngCommand result ![]() 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.pngCommand result ![]() Resize PNG Picture by '-filter_complex scale=size'Example to resize a png picture byffmpeg -hide_banner -i in\dt16001024.png -filter_complex scale=400:256 out\resize400256_03a.pngCommand result ![]() Switch -sto set frame sizeSyntax-s[:stream_specifier] size Arguments:Separator stream_specifierOptional. IfRemarksAs 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 ExamplesResize PNG Picture by '-s size'Example to resize a png picture byffmpeg -hide_banner -i in\dt16001024.png -s 400x256 out\resize400256_04a.pngCommand result ![]() Resize PNG Picture by '-s size'Example to resize a png picture byffmpeg -hide_banner -i in\dt16001024.png -s 400:256 out\resize400256_05a.pngCommand result ![]() Source and Referencehttps://ffmpeg.org/ffmpeg.htmlhttps://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 Links
![]() ![]() ![]() ![]() ![]() |
![]() Home 5 Business Management HBR 3 Information Recreation Hobbies 8 Culture Chinese 1097 English 339 Travel 18 Reference 79 Computer Hardware 254 Software Application 213 Digitization 37 Latex 52 Manim 205 KB 1 Numeric 19 Programming Web 289 Unicode 504 HTML 66 CSS 65 SVG 46 ASP.NET 270 OS 431 DeskTop 7 Python 72 Knowledge Mathematics Formulas 8 Set 1 Logic 1 Algebra 84 Number Theory 206 Trigonometry 31 Geometry 34 Calculus 67 Engineering Tables 8 Mechanical Rigid Bodies Statics 92 Dynamics 37 Fluid 5 Control Acoustics 19 Natural Sciences Matter 1 Electric 27 Biology 1 |
Copyright © 2000-2025 Sideway . All rights reserved Disclaimers last modified on 06 September 2019