OSDN Git Service

Merge commit '34a0ac41a880039c7fb4b3abce10d8e2ce48fac7'
authorMichael Niedermayer <michaelni@gmx.at>
Sun, 3 Nov 2013 10:36:16 +0000 (11:36 +0100)
committerMichael Niedermayer <michaelni@gmx.at>
Sun, 3 Nov 2013 10:54:19 +0000 (11:54 +0100)
* commit '34a0ac41a880039c7fb4b3abce10d8e2ce48fac7':
  vf_aspect: support variables in evaluating the aspect ratios

Conflicts:
Changelog
doc/filters.texi
libavfilter/vf_aspect.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
1  2 
Changelog
doc/filters.texi
libavfilter/vf_aspect.c

diff --cc Changelog
+++ b/Changelog
  Entries are sorted chronologically from oldest to youngest within each release,
  releases are sorted from youngest to oldest.
  
 -version 10:
 -- av_strnstr
 -- support ID3v2 tags in ASF files
 +version <next>
 +
 +- HNM version 4 demuxer and video decoder
 +- Live HDS muxer
++- setsar/setdar filters now support variables in ratio expressions
 +
 +
 +version 2.1:
 +
 +- aecho filter
 +- perspective filter ported from libmpcodecs
 +- ffprobe -show_programs option
 +- compand filter
 +- RTMP seek support
 +- when transcoding with ffmpeg (i.e. not streamcopying), -ss is now accurate
 +  even when used as an input option. Previous behavior can be restored with
 +  the -noaccurate_seek option.
 +- ffmpeg -t option can now be used for inputs, to limit the duration of
 +  data read from an input file
 +- incomplete Voxware MetaSound decoder
 +- read EXIF metadata from JPEG
 +- DVB teletext decoder
 +- phase filter ported from libmpcodecs
 +- w3fdif filter
 +- Opus support in Matroska
 +- FFV1 version 1.3 is stable and no longer experimental
 +- FFV1: YUVA(444,422,420) 9, 10 and 16 bit support
 +- changed DTS stream id in lavf mpeg ps muxer from 0x8a to 0x88, to be
 +  more consistent with other muxers.
 +- adelay filter
 +- pullup filter ported from libmpcodecs
 +- ffprobe -read_intervals option
 +- Lossless and alpha support for WebP decoder
 +- Error Resilient AAC syntax (ER AAC LC) decoding
 +- Low Delay AAC (ER AAC LD) decoding
 +- mux chapters in ASF files
 +- SFTP protocol (via libssh)
 +- libx264: add ability to encode in YUVJ422P and YUVJ444P
 +- Fraps: use BT.709 colorspace by default for yuv, as reference fraps decoder does
 +- make decoding alpha optional for prores, ffv1 and vp6 by setting
 +  the skip_alpha flag.
 +- ladspa wrapper filter
 +- native VP9 decoder
 +- dpx parser
 +- max_error_rate parameter in ffmpeg
 +- PulseAudio output device
 +- ReplayGain scanner
 +- Enhanced Low Delay AAC (ER AAC ELD) decoding (no LD SBR support)
 +- Linux framebuffer output device
 +- HEVC decoder
 +- raw HEVC, HEVC in MOV/MP4, HEVC in Matroska, HEVC in MPEG-TS demuxing
 +- mergeplanes filter
 +
 +
 +version 2.0:
 +
 +- curves filter
  - reference-counting for AVFrame and AVPacket data
 -- avconv now fails when input options are used for output file
 +- ffmpeg now fails when input options are used for output file
    or vice versa
 -- new avconv options -filter_script and -filter_complex_script, which allow a
 +- support for Monkey's Audio versions from 3.93
 +- perms and aperms filters
 +- audio filtering support in ffplay
 +- 10% faster aac encoding on x86 and MIPS
 +- sine audio filter source
 +- WebP demuxing and decoding support
 +- new ffmpeg options -filter_script and -filter_complex_script, which allow a
    filtergraph description to be read from a file
 +- OpenCL support
 +- audio phaser filter
 +- separatefields filter
 +- libquvi demuxer
  - uniform options syntax across all filters
 +- telecine filter
  - new interlace filter
 -- JPEG 2000 decoder
 -- new asetpts filter (same as setpts, but for audio)
 -- new trim and atrim filters
 -- avconv -t and -ss (output-only) options are now sample-accurate when
 +- smptehdbars source
 +- inverse telecine filters (fieldmatch and decimate)
 +- colorbalance filter
 +- colorchannelmixer filter
 +- The matroska demuxer can now output proper verbatim ASS packets. It will
 +  become the default at the next libavformat major bump.
 +- decent native animated GIF encoding
 +- asetrate filter
 +- interleave filter
 +- timeline editing with filters
 +- vidstabdetect and vidstabtransform filters for video stabilization using
 +  the vid.stab library
 +- astats filter
 +- trim and atrim filters
 +- ffmpeg -t and -ss (output-only) options are now sample-accurate when
    transcoding audio
  - Matroska muxer can now put the index at the beginning of the file.
 -- avconv -deinterlace option removed, the yadif filter should be used instead
 +- extractplanes filter
 +- avectorscope filter
 +- ADPCM DTK decoder
 +- ADP demuxer
 +- RSD demuxer
 +- RedSpark demuxer
 +- ADPCM IMA Radical decoder
 +- zmq filters
 +- DCT denoiser filter (dctdnoiz)
 +- Wavelet denoiser filter ported from libmpcodecs as owdenoise (formerly "ow")
  - Apple Intermediate Codec decoder
  - Escape 130 video decoder
 +- FTP protocol support
 +- V4L2 output device
 +- 3D LUT filter (lut3d)
 +- SMPTE 302M audio encoder
  - support for slice multithreading in libavfilter
 +- Hald CLUT support (generation and filtering)
  - VC-1 interlaced B-frame support
  - support for WavPack muxing (raw and in Matroska)
 +- XVideo output device
 +- vignette filter
 +- True Audio (TTA) encoder
  - Go2Webinar decoder
 +- mcdeint filter ported from libmpcodecs
 +- sab filter ported from libmpcodecs
 +- ffprobe -show_chapters option
  - WavPack encoding through libwavpack
 -- Added the -n parameter to avconv
 -- RTMP seek support
 -- when transcoding with avconv (i.e. not streamcopying), -ss is now accurate
 -  even when used as an input option. Previous behavior can be restored with
 -  the -noaccurate_seek option.
 -- avconv -t option can now be used for inputs, to limit the duration of
 -  data read from an input file
 -- incomplete Voxware MetaSound decoder
 -- WebP decoder
 -- Error Resilient AAC syntax (ER AAC LC) decoding
 -- Low Delay AAC (ER AAC LD) decoding
 -- mux chapters in ASF files
 -- Opus in Ogg demuxing
 -- Enhanced Low Delay AAC (ER AAC ELD) decoding (no LD SBR support)
 -- F4V muxer
 -- HNM version 4 demuxer and video decoder
 -- HEVC decoder
 -- raw HEVC, HEVC in MOV/MP4, HEVC in Matroska, HEVC in MPEG-TS demuxing
 -- remove avplay -vismv option, which has not worked for a long time
 -- Live HDS muxer
 -- setsar/setdar filters now support variables in ratio expressions
 +- rotate filter
 +- spp filter ported from libmpcodecs
 +- libgme support
 +- psnr filter
  
  
 -version 9:
 -- av_basename and av_dirname
 -- adobe and limelight publisher authentication in RTMP
 +version 1.2:
 +
  - VDPAU hardware acceleration through normal hwaccel
  - SRTP support
 +- Error diffusion dither in Swscale
 +- Chained Ogg support
 +- Theora Midstream reconfiguration support
 +- EVRC decoder
 +- audio fade filter
 +- filtering audio with unknown channel layout
 +- allpass, bass, bandpass, bandreject, biquad, equalizer, highpass, lowpass
 +  and treble audio filter
 +- improved showspectrum filter, with multichannel support and sox-like colors
 +- histogram filter
 +- tee muxer
 +- il filter ported from libmpcodecs
 +- support ID3v2 tags in ASF files
 +- encrypted TTA stream decoding support
 +- RF64 support in WAV muxer
 +- noise filter ported from libmpcodecs
 +- Subtitles character encoding conversion
 +- blend filter
 +- stereo3d filter ported from libmpcodecs
 +
  
 +version 1.1:
  
 -version 9_beta3:
 -- ashowinfo audio filter
 +- stream disposition information printing in ffprobe
 +- filter for loudness analysis following EBU R128
 +- Opus encoder using libopus
 +- ffprobe -select_streams option
 +- Pinnacle TARGA CineWave YUV16 decoder
 +- TAK demuxer, decoder and parser
 +- DTS-HD demuxer
 +- remove -same_quant, it hasn't worked for years
 +- FFM2 support
 +- X-Face image encoder and decoder
  - 24-bit FLAC encoding
 -- audio volume filter
 -- deprecated the avconv -vol option. the volume filter is to be used instead.
  - multi-channel ALAC encoding up to 7.1
 -- TAK demuxer, parser, and decoder
 -- adaptive frame-level multithreading for H.264
 -
 -
 -version 9_beta2:
  - metadata (INFO tag) support in WAV muxer
 +- subtitles raw text decoder
  - support for building DLLs using MSVC
 -- remove avserver daemon mode
 +- LVF demuxer
 +- ffescape tool
 +- metadata (info chunk) support in CAF muxer
 +- field filter ported from libmpcodecs
 +- AVR demuxer
 +- geq filter ported from libmpcodecs
 +- remove ffserver daemon mode
 +- AST muxer/demuxer
 +- new expansion syntax for drawtext
 +- BRender PIX image decoder
 +- ffprobe -show_entries option
 +- ffprobe -sections option
 +- ADPCM IMA Dialogic decoder
 +- BRSTM demuxer
 +- animated GIF decoder and demuxer
 +- PVF demuxer
 +- subtitles filter
 +- IRCAM muxer/demuxer
 +- Paris Audio File demuxer
 +- Virtual concatenation demuxer
 +- VobSub demuxer
 +- JSON captions for TED talks decoding support
 +- SOX Resampler support in libswresample
 +- aselect filter
 +- SGI RLE 8-bit decoder
 +- Silicon Graphics Motion Video Compressor 1 & 2 decoder
 +- Silicon Graphics Movie demuxer
 +- apad filter
 +- Resolution & pixel format change support with multithreading for H.264
 +- documentation split into per-component manuals
 +- pp (postproc) filter ported from MPlayer
 +- NIST Sphere demuxer
 +- MPL2, VPlayer, MPlayer, AQTitle, PJS and SubViewer v1 subtitles demuxers and decoders
 +- Sony Wave64 muxer
 +- adobe and limelight publisher authentication in RTMP
 +- data: URI scheme
  - support building on the Plan 9 operating system
 -- ffv1: support version 1.3
 +- kerndeint filter ported from MPlayer
 +- histeq filter ported from VirtualDub
 +- Megalux Frame demuxer
 +- 012v decoder
 +- Improved AVC Intra decoding support
  
  
 -version 9_beta1:
 +version 1.0:
  
 -- XWD encoder and decoder
 -- Support for fragmentation in the mov/mp4 muxer
 -- ISMV (Smooth Streaming) muxer
 -- CDXL demuxer and decoder
 -- Apple ProRes encoder
 -- Sun Rasterfile Encoder
 -- remove libpostproc
 -- ID3v2 attached pictures reading and writing
 -- WMA Lossless decoder
 -- XBM encoder
 -- RealAudio Lossless decoder
 -- ZeroCodec decoder
 -- drop support for avconv without libavfilter
 -- add libavresample audio conversion library
 -- audio filters support in libavfilter and avconv
 -- add fps filter
 -- audio split filter
 -- audio mix filter
 -- avprobe output is now standard INI or JSON. The old format can still
 -  be used with -of old.
 +- INI and flat output in ffprobe
 +- Scene detection in libavfilter
  - Indeo Audio decoder
  - channelsplit audio filter
 +- setnsamples audio filter
 +- atempo filter
 +- ffprobe -show_data option
  - RTMPT protocol support
  - iLBC encoding/decoding via libilbc
  - Microsoft Screen 1 decoder
@@@ -5581,3423 -1569,262 +5581,3448 @@@ Refer to the official libopencv documen
  information:
  @url{http://opencv.willowgarage.com/documentation/c/image_filtering.html}
  
 -Follows the list of supported libopencv filters.
 +Follows the list of supported libopencv filters.
 +
 +@anchor{dilate}
 +@subsection dilate
 +
 +Dilate an image by using a specific structuring element.
 +This filter corresponds to the libopencv function @code{cvDilate}.
 +
 +It accepts the parameters: @var{struct_el}|@var{nb_iterations}.
 +
 +@var{struct_el} represents a structuring element, and has the syntax:
 +@var{cols}x@var{rows}+@var{anchor_x}x@var{anchor_y}/@var{shape}
 +
 +@var{cols} and @var{rows} represent the number of columns and rows of
 +the structuring element, @var{anchor_x} and @var{anchor_y} the anchor
 +point, and @var{shape} the shape for the structuring element, and
 +can be one of the values "rect", "cross", "ellipse", "custom".
 +
 +If the value for @var{shape} is "custom", it must be followed by a
 +string of the form "=@var{filename}". The file with name
 +@var{filename} is assumed to represent a binary image, with each
 +printable character corresponding to a bright pixel. When a custom
 +@var{shape} is used, @var{cols} and @var{rows} are ignored, the number
 +or columns and rows of the read file are assumed instead.
 +
 +The default value for @var{struct_el} is "3x3+0x0/rect".
 +
 +@var{nb_iterations} specifies the number of times the transform is
 +applied to the image, and defaults to 1.
 +
 +Follow some example:
 +@example
 +# use the default values
 +ocv=dilate
 +
 +# dilate using a structuring element with a 5x5 cross, iterate two times
 +ocv=filter_name=dilate:filter_params=5x5+2x2/cross|2
 +
 +# read the shape from the file diamond.shape, iterate two times
 +# the file diamond.shape may contain a pattern of characters like this:
 +#   *
 +#  ***
 +# *****
 +#  ***
 +#   *
 +# the specified cols and rows are ignored (but not the anchor point coordinates)
 +ocv=dilate:0x0+2x2/custom=diamond.shape|2
 +@end example
 +
 +@subsection erode
 +
 +Erode an image by using a specific structuring element.
 +This filter corresponds to the libopencv function @code{cvErode}.
 +
 +The filter accepts the parameters: @var{struct_el}:@var{nb_iterations},
 +with the same syntax and semantics as the @ref{dilate} filter.
 +
 +@subsection smooth
 +
 +Smooth the input video.
 +
 +The filter takes the following parameters:
 +@var{type}|@var{param1}|@var{param2}|@var{param3}|@var{param4}.
 +
 +@var{type} is the type of smooth filter to apply, and can be one of
 +the following values: "blur", "blur_no_scale", "median", "gaussian",
 +"bilateral". The default value is "gaussian".
 +
 +@var{param1}, @var{param2}, @var{param3}, and @var{param4} are
 +parameters whose meanings depend on smooth type. @var{param1} and
 +@var{param2} accept integer positive values or 0, @var{param3} and
 +@var{param4} accept float values.
 +
 +The default value for @var{param1} is 3, the default value for the
 +other parameters is 0.
 +
 +These parameters correspond to the parameters assigned to the
 +libopencv function @code{cvSmooth}.
 +
 +@anchor{overlay}
 +@section overlay
 +
 +Overlay one video on top of another.
 +
 +It takes two inputs and one output, the first input is the "main"
 +video on which the second input is overlayed.
 +
 +This filter accepts the following parameters:
 +
 +A description of the accepted options follows.
 +
 +@table @option
 +@item x
 +@item y
 +Set the expression for the x and y coordinates of the overlayed video
 +on the main video. Default value is "0" for both expressions. In case
 +the expression is invalid, it is set to a huge value (meaning that the
 +overlay will not be displayed within the output visible area).
 +
 +@item eval
 +Set when the expressions for @option{x}, and @option{y} are evaluated.
 +
 +It accepts the following values:
 +@table @samp
 +@item init
 +only evaluate expressions once during the filter initialization or
 +when a command is processed
 +
 +@item frame
 +evaluate expressions for each incoming frame
 +@end table
 +
 +Default value is @samp{frame}.
 +
 +@item shortest
 +If set to 1, force the output to terminate when the shortest input
 +terminates. Default value is 0.
 +
 +@item format
 +Set the format for the output video.
 +
 +It accepts the following values:
 +@table @samp
 +@item yuv420
 +force YUV420 output
 +
 +@item yuv444
 +force YUV444 output
 +
 +@item rgb
 +force RGB output
 +@end table
 +
 +Default value is @samp{yuv420}.
 +
 +@item rgb @emph{(deprecated)}
 +If set to 1, force the filter to accept inputs in the RGB
 +color space. Default value is 0. This option is deprecated, use
 +@option{format} instead.
 +
 +@item repeatlast
 +If set to 1, force the filter to draw the last overlay frame over the
 +main input until the end of the stream. A value of 0 disables this
 +behavior. Default value is 1.
 +@end table
 +
 +The @option{x}, and @option{y} expressions can contain the following
 +parameters.
 +
 +@table @option
 +@item main_w, W
 +@item main_h, H
 +main input width and height
 +
 +@item overlay_w, w
 +@item overlay_h, h
 +overlay input width and height
 +
 +@item x
 +@item y
 +the computed values for @var{x} and @var{y}. They are evaluated for
 +each new frame.
 +
 +@item hsub
 +@item vsub
 +horizontal and vertical chroma subsample values of the output
 +format. For example for the pixel format "yuv422p" @var{hsub} is 2 and
 +@var{vsub} is 1.
 +
 +@item n
 +the number of input frame, starting from 0
 +
 +@item pos
 +the position in the file of the input frame, NAN if unknown
 +
 +@item t
 +timestamp expressed in seconds, NAN if the input timestamp is unknown
 +@end table
 +
 +Note that the @var{n}, @var{pos}, @var{t} variables are available only
 +when evaluation is done @emph{per frame}, and will evaluate to NAN
 +when @option{eval} is set to @samp{init}.
 +
 +Be aware that frames are taken from each input video in timestamp
 +order, hence, if their initial timestamps differ, it is a good idea
 +to pass the two inputs through a @var{setpts=PTS-STARTPTS} filter to
 +have them begin in the same zero timestamp, as it does the example for
 +the @var{movie} filter.
 +
 +You can chain together more overlays but you should test the
 +efficiency of such approach.
 +
 +@subsection Commands
 +
 +This filter supports the following commands:
 +@table @option
 +@item x
 +@item y
 +Modify the x and y of the overlay input.
 +The command accepts the same syntax of the corresponding option.
 +
 +If the specified expression is not valid, it is kept at its current
 +value.
 +@end table
 +
 +@subsection Examples
 +
 +@itemize
 +@item
 +Draw the overlay at 10 pixels from the bottom right corner of the main
 +video:
 +@example
 +overlay=main_w-overlay_w-10:main_h-overlay_h-10
 +@end example
 +
 +Using named options the example above becomes:
 +@example
 +overlay=x=main_w-overlay_w-10:y=main_h-overlay_h-10
 +@end example
 +
 +@item
 +Insert a transparent PNG logo in the bottom left corner of the input,
 +using the @command{ffmpeg} tool with the @code{-filter_complex} option:
 +@example
 +ffmpeg -i input -i logo -filter_complex 'overlay=10:main_h-overlay_h-10' output
 +@end example
 +
 +@item
 +Insert 2 different transparent PNG logos (second logo on bottom
 +right corner) using the @command{ffmpeg} tool:
 +@example
 +ffmpeg -i input -i logo1 -i logo2 -filter_complex 'overlay=x=10:y=H-h-10,overlay=x=W-w-10:y=H-h-10' output
 +@end example
 +
 +@item
 +Add a transparent color layer on top of the main video, @code{WxH}
 +must specify the size of the main input to the overlay filter:
 +@example
 +color=color=red@@.3:size=WxH [over]; [in][over] overlay [out]
 +@end example
 +
 +@item
 +Play an original video and a filtered version (here with the deshake
 +filter) side by side using the @command{ffplay} tool:
 +@example
 +ffplay input.avi -vf 'split[a][b]; [a]pad=iw*2:ih[src]; [b]deshake[filt]; [src][filt]overlay=w'
 +@end example
 +
 +The above command is the same as:
 +@example
 +ffplay input.avi -vf 'split[b], pad=iw*2[src], [b]deshake, [src]overlay=w'
 +@end example
 +
 +@item
 +Make a sliding overlay appearing from the left to the right top part of the
 +screen starting since time 2:
 +@example
 +overlay=x='if(gte(t,2), -w+(t-2)*20, NAN)':y=0
 +@end example
 +
 +@item
 +Compose output by putting two input videos side to side:
 +@example
 +ffmpeg -i left.avi -i right.avi -filter_complex "
 +nullsrc=size=200x100 [background];
 +[0:v] setpts=PTS-STARTPTS, scale=100x100 [left];
 +[1:v] setpts=PTS-STARTPTS, scale=100x100 [right];
 +[background][left]       overlay=shortest=1       [background+left];
 +[background+left][right] overlay=shortest=1:x=100 [left+right]
 +"
 +@end example
 +
 +@item
 +Chain several overlays in cascade:
 +@example
 +nullsrc=s=200x200 [bg];
 +testsrc=s=100x100, split=4 [in0][in1][in2][in3];
 +[in0] lutrgb=r=0, [bg]   overlay=0:0     [mid0];
 +[in1] lutrgb=g=0, [mid0] overlay=100:0   [mid1];
 +[in2] lutrgb=b=0, [mid1] overlay=0:100   [mid2];
 +[in3] null,       [mid2] overlay=100:100 [out0]
 +@end example
 +
 +@end itemize
 +
 +@section owdenoise
 +
 +Apply Overcomplete Wavelet denoiser.
 +
 +The filter accepts the following options:
 +
 +@table @option
 +@item depth
 +Set depth.
 +
 +Larger depth values will denoise lower frequency components more, but
 +slow down filtering.
 +
 +Must be an int in the range 8-16, default is @code{8}.
 +
 +@item luma_strength, ls
 +Set luma strength.
 +
 +Must be a double value in the range 0-1000, default is @code{1.0}.
 +
 +@item chroma_strength, cs
 +Set chroma strength.
 +
 +Must be a double value in the range 0-1000, default is @code{1.0}.
 +@end table
 +
 +@section pad
 +
 +Add paddings to the input image, and place the original input at the
 +given coordinates @var{x}, @var{y}.
 +
 +This filter accepts the following parameters:
 +
 +@table @option
 +@item width, w
 +@item height, h
 +Specify an expression for the size of the output image with the
 +paddings added. If the value for @var{width} or @var{height} is 0, the
 +corresponding input size is used for the output.
 +
 +The @var{width} expression can reference the value set by the
 +@var{height} expression, and vice versa.
 +
 +The default value of @var{width} and @var{height} is 0.
 +
 +@item x
 +@item y
 +Specify an expression for the offsets where to place the input image
 +in the padded area with respect to the top/left border of the output
 +image.
 +
 +The @var{x} expression can reference the value set by the @var{y}
 +expression, and vice versa.
 +
 +The default value of @var{x} and @var{y} is 0.
 +
 +@item color
 +Specify the color of the padded area. For the syntax of this option,
 +check the "Color" section in the ffmpeg-utils manual.
 +
 +The default value of @var{color} is "black".
 +@end table
 +
 +The value for the @var{width}, @var{height}, @var{x}, and @var{y}
 +options are expressions containing the following constants:
 +
 +@table @option
 +@item in_w
 +@item in_h
 +the input video width and height
 +
 +@item iw
 +@item ih
 +same as @var{in_w} and @var{in_h}
 +
 +@item out_w
 +@item out_h
 +the output width and height, that is the size of the padded area as
 +specified by the @var{width} and @var{height} expressions
 +
 +@item ow
 +@item oh
 +same as @var{out_w} and @var{out_h}
 +
 +@item x
 +@item y
 +x and y offsets as specified by the @var{x} and @var{y}
 +expressions, or NAN if not yet specified
 +
 +@item a
 +same as @var{iw} / @var{ih}
 +
 +@item sar
 +input sample aspect ratio
 +
 +@item dar
 +input display aspect ratio, it is the same as (@var{iw} / @var{ih}) * @var{sar}
 +
 +@item hsub
 +@item vsub
 +horizontal and vertical chroma subsample values. For example for the
 +pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
 +@end table
 +
 +@subsection Examples
 +
 +@itemize
 +@item
 +Add paddings with color "violet" to the input video. Output video
 +size is 640x480, the top-left corner of the input video is placed at
 +column 0, row 40:
 +@example
 +pad=640:480:0:40:violet
 +@end example
 +
 +The example above is equivalent to the following command:
 +@example
 +pad=width=640:height=480:x=0:y=40:color=violet
 +@end example
 +
 +@item
 +Pad the input to get an output with dimensions increased by 3/2,
 +and put the input video at the center of the padded area:
 +@example
 +pad="3/2*iw:3/2*ih:(ow-iw)/2:(oh-ih)/2"
 +@end example
 +
 +@item
 +Pad the input to get a squared output with size equal to the maximum
 +value between the input width and height, and put the input video at
 +the center of the padded area:
 +@example
 +pad="max(iw\,ih):ow:(ow-iw)/2:(oh-ih)/2"
 +@end example
 +
 +@item
 +Pad the input to get a final w/h ratio of 16:9:
 +@example
 +pad="ih*16/9:ih:(ow-iw)/2:(oh-ih)/2"
 +@end example
 +
 +@item
 +In case of anamorphic video, in order to set the output display aspect
 +correctly, it is necessary to use @var{sar} in the expression,
 +according to the relation:
 +@example
 +(ih * X / ih) * sar = output_dar
 +X = output_dar / sar
 +@end example
 +
 +Thus the previous example needs to be modified to:
 +@example
 +pad="ih*16/9/sar:ih:(ow-iw)/2:(oh-ih)/2"
 +@end example
 +
 +@item
 +Double output size and put the input video in the bottom-right
 +corner of the output padded area:
 +@example
 +pad="2*iw:2*ih:ow-iw:oh-ih"
 +@end example
 +@end itemize
 +
 +@section perspective
 +
 +Correct perspective of video not recorded perpendicular to the screen.
 +
 +A description of the accepted parameters follows.
 +
 +@table @option
 +@item x0
 +@item y0
 +@item x1
 +@item y1
 +@item x2
 +@item y2
 +@item x3
 +@item y3
 +Set coordinates expression for top left, top right, bottom left and bottom right corners.
 +Default values are @code{0:0:W:0:0:H:W:H} with which perspective will remain unchanged.
 +
 +The expressions can use the following variables:
 +
 +@table @option
 +@item W
 +@item H
 +the width and height of video frame.
 +@end table
 +
 +@item interpolation
 +Set interpolation for perspective correction.
 +
 +It accepts the following values:
 +@table @samp
 +@item linear
 +@item cubic
 +@end table
 +
 +Default value is @samp{linear}.
 +@end table
 +
 +@section phase
 +
 +Delay interlaced video by one field time so that the field order changes.
 +
 +The intended use is to fix PAL movies that have been captured with the
 +opposite field order to the film-to-video transfer.
 +
 +A description of the accepted parameters follows.
 +
 +@table @option
 +@item mode
 +Set phase mode.
 +
 +It accepts the following values:
 +@table @samp
 +@item t
 +Capture field order top-first, transfer bottom-first.
 +Filter will delay the bottom field.
 +
 +@item b
 +Capture field order bottom-first, transfer top-first.
 +Filter will delay the top field.
 +
 +@item p
 +Capture and transfer with the same field order. This mode only exists
 +for the documentation of the other options to refer to, but if you
 +actually select it, the filter will faithfully do nothing.
 +
 +@item a
 +Capture field order determined automatically by field flags, transfer
 +opposite.
 +Filter selects among @samp{t} and @samp{b} modes on a frame by frame
 +basis using field flags. If no field information is available,
 +then this works just like @samp{u}.
 +
 +@item u
 +Capture unknown or varying, transfer opposite.
 +Filter selects among @samp{t} and @samp{b} on a frame by frame basis by
 +analyzing the images and selecting the alternative that produces best
 +match between the fields.
 +
 +@item T
 +Capture top-first, transfer unknown or varying.
 +Filter selects among @samp{t} and @samp{p} using image analysis.
 +
 +@item B
 +Capture bottom-first, transfer unknown or varying.
 +Filter selects among @samp{b} and @samp{p} using image analysis.
 +
 +@item A
 +Capture determined by field flags, transfer unknown or varying.
 +Filter selects among @samp{t}, @samp{b} and @samp{p} using field flags and
 +image analysis. If no field information is available, then this works just
 +like @samp{U}. This is the default mode.
 +
 +@item U
 +Both capture and transfer unknown or varying.
 +Filter selects among @samp{t}, @samp{b} and @samp{p} using image analysis only.
 +@end table
 +@end table
 +
 +@section pixdesctest
 +
 +Pixel format descriptor test filter, mainly useful for internal
 +testing. The output video should be equal to the input video.
 +
 +For example:
 +@example
 +format=monow, pixdesctest
 +@end example
 +
 +can be used to test the monowhite pixel format descriptor definition.
 +
 +@section pp
 +
 +Enable the specified chain of postprocessing subfilters using libpostproc. This
 +library should be automatically selected with a GPL build (@code{--enable-gpl}).
 +Subfilters must be separated by '/' and can be disabled by prepending a '-'.
 +Each subfilter and some options have a short and a long name that can be used
 +interchangeably, i.e. dr/dering are the same.
 +
 +The filters accept the following options:
 +
 +@table @option
 +@item subfilters
 +Set postprocessing subfilters string.
 +@end table
 +
 +All subfilters share common options to determine their scope:
 +
 +@table @option
 +@item a/autoq
 +Honor the quality commands for this subfilter.
 +
 +@item c/chrom
 +Do chrominance filtering, too (default).
 +
 +@item y/nochrom
 +Do luminance filtering only (no chrominance).
 +
 +@item n/noluma
 +Do chrominance filtering only (no luminance).
 +@end table
 +
 +These options can be appended after the subfilter name, separated by a '|'.
 +
 +Available subfilters are:
 +
 +@table @option
 +@item hb/hdeblock[|difference[|flatness]]
 +Horizontal deblocking filter
 +@table @option
 +@item difference
 +Difference factor where higher values mean more deblocking (default: @code{32}).
 +@item flatness
 +Flatness threshold where lower values mean more deblocking (default: @code{39}).
 +@end table
 +
 +@item vb/vdeblock[|difference[|flatness]]
 +Vertical deblocking filter
 +@table @option
 +@item difference
 +Difference factor where higher values mean more deblocking (default: @code{32}).
 +@item flatness
 +Flatness threshold where lower values mean more deblocking (default: @code{39}).
 +@end table
 +
 +@item ha/hadeblock[|difference[|flatness]]
 +Accurate horizontal deblocking filter
 +@table @option
 +@item difference
 +Difference factor where higher values mean more deblocking (default: @code{32}).
 +@item flatness
 +Flatness threshold where lower values mean more deblocking (default: @code{39}).
 +@end table
 +
 +@item va/vadeblock[|difference[|flatness]]
 +Accurate vertical deblocking filter
 +@table @option
 +@item difference
 +Difference factor where higher values mean more deblocking (default: @code{32}).
 +@item flatness
 +Flatness threshold where lower values mean more deblocking (default: @code{39}).
 +@end table
 +@end table
 +
 +The horizontal and vertical deblocking filters share the difference and
 +flatness values so you cannot set different horizontal and vertical
 +thresholds.
 +
 +@table @option
 +@item h1/x1hdeblock
 +Experimental horizontal deblocking filter
 +
 +@item v1/x1vdeblock
 +Experimental vertical deblocking filter
 +
 +@item dr/dering
 +Deringing filter
 +
 +@item tn/tmpnoise[|threshold1[|threshold2[|threshold3]]], temporal noise reducer
 +@table @option
 +@item threshold1
 +larger -> stronger filtering
 +@item threshold2
 +larger -> stronger filtering
 +@item threshold3
 +larger -> stronger filtering
 +@end table
 +
 +@item al/autolevels[:f/fullyrange], automatic brightness / contrast correction
 +@table @option
 +@item f/fullyrange
 +Stretch luminance to @code{0-255}.
 +@end table
 +
 +@item lb/linblenddeint
 +Linear blend deinterlacing filter that deinterlaces the given block by
 +filtering all lines with a @code{(1 2 1)} filter.
 +
 +@item li/linipoldeint
 +Linear interpolating deinterlacing filter that deinterlaces the given block by
 +linearly interpolating every second line.
 +
 +@item ci/cubicipoldeint
 +Cubic interpolating deinterlacing filter deinterlaces the given block by
 +cubically interpolating every second line.
 +
 +@item md/mediandeint
 +Median deinterlacing filter that deinterlaces the given block by applying a
 +median filter to every second line.
 +
 +@item fd/ffmpegdeint
 +FFmpeg deinterlacing filter that deinterlaces the given block by filtering every
 +second line with a @code{(-1 4 2 4 -1)} filter.
 +
 +@item l5/lowpass5
 +Vertically applied FIR lowpass deinterlacing filter that deinterlaces the given
 +block by filtering all lines with a @code{(-1 2 6 2 -1)} filter.
 +
 +@item fq/forceQuant[|quantizer]
 +Overrides the quantizer table from the input with the constant quantizer you
 +specify.
 +@table @option
 +@item quantizer
 +Quantizer to use
 +@end table
 +
 +@item de/default
 +Default pp filter combination (@code{hb|a,vb|a,dr|a})
 +
 +@item fa/fast
 +Fast pp filter combination (@code{h1|a,v1|a,dr|a})
 +
 +@item ac
 +High quality pp filter combination (@code{ha|a|128|7,va|a,dr|a})
 +@end table
 +
 +@subsection Examples
 +
 +@itemize
 +@item
 +Apply horizontal and vertical deblocking, deringing and automatic
 +brightness/contrast:
 +@example
 +pp=hb/vb/dr/al
 +@end example
 +
 +@item
 +Apply default filters without brightness/contrast correction:
 +@example
 +pp=de/-al
 +@end example
 +
 +@item
 +Apply default filters and temporal denoiser:
 +@example
 +pp=default/tmpnoise|1|2|3
 +@end example
 +
 +@item
 +Apply deblocking on luminance only, and switch vertical deblocking on or off
 +automatically depending on available CPU time:
 +@example
 +pp=hb|y/vb|a
 +@end example
 +@end itemize
 +
 +@section psnr
 +
 +Obtain the average, maximum and minimum PSNR (Peak Signal to Noise
 +Ratio) between two input videos.
 +
 +This filter takes in input two input videos, the first input is
 +considered the "main" source and is passed unchanged to the
 +output. The second input is used as a "reference" video for computing
 +the PSNR.
 +
 +Both video inputs must have the same resolution and pixel format for
 +this filter to work correctly. Also it assumes that both inputs
 +have the same number of frames, which are compared one by one.
 +
 +The obtained average PSNR is printed through the logging system.
 +
 +The filter stores the accumulated MSE (mean squared error) of each
 +frame, and at the end of the processing it is averaged across all frames
 +equally, and the following formula is applied to obtain the PSNR:
 +
 +@example
 +PSNR = 10*log10(MAX^2/MSE)
 +@end example
 +
 +Where MAX is the average of the maximum values of each component of the
 +image.
 +
 +The description of the accepted parameters follows.
 +
 +@table @option
 +@item stats_file, f
 +If specified the filter will use the named file to save the PSNR of
 +each individual frame.
 +@end table
 +
 +The file printed if @var{stats_file} is selected, contains a sequence of
 +key/value pairs of the form @var{key}:@var{value} for each compared
 +couple of frames.
 +
 +A description of each shown parameter follows:
 +
 +@table @option
 +@item n
 +sequential number of the input frame, starting from 1
 +
 +@item mse_avg
 +Mean Square Error pixel-by-pixel average difference of the compared
 +frames, averaged over all the image components.
 +
 +@item mse_y, mse_u, mse_v, mse_r, mse_g, mse_g, mse_a
 +Mean Square Error pixel-by-pixel average difference of the compared
 +frames for the component specified by the suffix.
 +
 +@item psnr_y, psnr_u, psnr_v, psnr_r, psnr_g, psnr_b, psnr_a
 +Peak Signal to Noise ratio of the compared frames for the component
 +specified by the suffix.
 +@end table
 +
 +For example:
 +@example
 +movie=ref_movie.mpg, setpts=PTS-STARTPTS [main];
 +[main][ref] psnr="stats_file=stats.log" [out]
 +@end example
 +
 +On this example the input file being processed is compared with the
 +reference file @file{ref_movie.mpg}. The PSNR of each individual frame
 +is stored in @file{stats.log}.
 +
 +@section pullup
 +
 +Pulldown reversal (inverse telecine) filter, capable of handling mixed
 +hard-telecine, 24000/1001 fps progressive, and 30000/1001 fps progressive
 +content.
 +
 +The pullup filter is designed to take advantage of future context in making
 +its decisions. This filter is stateless in the sense that it does not lock
 +onto a pattern to follow, but it instead looks forward to the following
 +fields in order to identify matches and rebuild progressive frames.
 +
 +To produce content with an even framerate, insert the fps filter after
 +pullup, use @code{fps=24000/1001} if the input frame rate is 29.97fps,
 +@code{fps=24} for 30fps and the (rare) telecined 25fps input.
 +
 +The filter accepts the following options:
 +
 +@table @option
 +@item jl
 +@item jr
 +@item jt
 +@item jb
 +These options set the amount of "junk" to ignore at the left, right, top, and
 +bottom of the image, respectively. Left and right are in units of 8 pixels,
 +while top and bottom are in units of 2 lines.
 +The default is 8 pixels on each side.
 +
 +@item sb
 +Set the strict breaks. Setting this option to 1 will reduce the chances of
 +filter generating an occasional mismatched frame, but it may also cause an
 +excessive number of frames to be dropped during high motion sequences.
 +Conversely, setting it to -1 will make filter match fields more easily.
 +This may help processing of video where there is slight blurring between
 +the fields, but may also cause there to be interlaced frames in the output.
 +Default value is @code{0}.
 +
 +@item mp
 +Set the metric plane to use. It accepts the following values:
 +@table @samp
 +@item l
 +Use luma plane.
 +
 +@item u
 +Use chroma blue plane.
 +
 +@item v
 +Use chroma red plane.
 +@end table
 +
 +This option may be set to use chroma plane instead of the default luma plane
 +for doing filter's computations. This may improve accuracy on very clean
 +source material, but more likely will decrease accuracy, especially if there
 +is chroma noise (rainbow effect) or any grayscale video.
 +The main purpose of setting @option{mp} to a chroma plane is to reduce CPU
 +load and make pullup usable in realtime on slow machines.
 +@end table
 +
 +For example to inverse telecined NTSC input:
 +@example
 +pullup,fps=24000/1001
 +@end example
 +
 +@section removelogo
 +
 +Suppress a TV station logo, using an image file to determine which
 +pixels comprise the logo. It works by filling in the pixels that
 +comprise the logo with neighboring pixels.
 +
 +The filter accepts the following options:
 +
 +@table @option
 +@item filename, f
 +Set the filter bitmap file, which can be any image format supported by
 +libavformat. The width and height of the image file must match those of the
 +video stream being processed.
 +@end table
 +
 +Pixels in the provided bitmap image with a value of zero are not
 +considered part of the logo, non-zero pixels are considered part of
 +the logo. If you use white (255) for the logo and black (0) for the
 +rest, you will be safe. For making the filter bitmap, it is
 +recommended to take a screen capture of a black frame with the logo
 +visible, and then using a threshold filter followed by the erode
 +filter once or twice.
 +
 +If needed, little splotches can be fixed manually. Remember that if
 +logo pixels are not covered, the filter quality will be much
 +reduced. Marking too many pixels as part of the logo does not hurt as
 +much, but it will increase the amount of blurring needed to cover over
 +the image and will destroy more information than necessary, and extra
 +pixels will slow things down on a large logo.
 +
 +@section rotate
 +
 +Rotate video by an arbitrary angle expressed in radians.
 +
 +The filter accepts the following options:
 +
 +A description of the optional parameters follows.
 +@table @option
 +@item angle, a
 +Set an expression for the angle by which to rotate the input video
 +clockwise, expressed as a number of radians. A negative value will
 +result in a counter-clockwise rotation. By default it is set to "0".
 +
 +This expression is evaluated for each frame.
 +
 +@item out_w, ow
 +Set the output width expression, default value is "iw".
 +This expression is evaluated just once during configuration.
 +
 +@item out_h, oh
 +Set the output height expression, default value is "ih".
 +This expression is evaluated just once during configuration.
 +
 +@item bilinear
 +Enable bilinear interpolation if set to 1, a value of 0 disables
 +it. Default value is 1.
 +
 +@item fillcolor, c
 +Set the color used to fill the output area not covered by the rotated
 +image. For the generalsyntax of this option, check the "Color" section in the
 +ffmpeg-utils manual. If the special value "none" is selected then no
 +background is printed (useful for example if the background is never shown).
 +
 +Default value is "black".
 +@end table
 +
 +The expressions for the angle and the output size can contain the
 +following constants and functions:
 +
 +@table @option
 +@item n
 +sequential number of the input frame, starting from 0. It is always NAN
 +before the first frame is filtered.
 +
 +@item t
 +time in seconds of the input frame, it is set to 0 when the filter is
 +configured. It is always NAN before the first frame is filtered.
 +
 +@item hsub
 +@item vsub
 +horizontal and vertical chroma subsample values. For example for the
 +pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
 +
 +@item in_w, iw
 +@item in_h, ih
 +the input video width and heigth
 +
 +@item out_w, ow
 +@item out_h, oh
 +the output width and heigth, that is the size of the padded area as
 +specified by the @var{width} and @var{height} expressions
 +
 +@item rotw(a)
 +@item roth(a)
 +the minimal width/height required for completely containing the input
 +video rotated by @var{a} radians.
 +
 +These are only available when computing the @option{out_w} and
 +@option{out_h} expressions.
 +@end table
 +
 +@subsection Examples
 +
 +@itemize
 +@item
 +Rotate the input by PI/6 radians clockwise:
 +@example
 +rotate=PI/6
 +@end example
 +
 +@item
 +Rotate the input by PI/6 radians counter-clockwise:
 +@example
 +rotate=-PI/6
 +@end example
 +
 +@item
 +Apply a constant rotation with period T, starting from an angle of PI/3:
 +@example
 +rotate=PI/3+2*PI*t/T
 +@end example
 +
 +@item
 +Make the input video rotation oscillating with a period of T
 +seconds and an amplitude of A radians:
 +@example
 +rotate=A*sin(2*PI/T*t)
 +@end example
 +
 +@item
 +Rotate the video, output size is choosen so that the whole rotating
 +input video is always completely contained in the output:
 +@example
 +rotate='2*PI*t:ow=hypot(iw,ih):oh=ow'
 +@end example
 +
 +@item
 +Rotate the video, reduce the output size so that no background is ever
 +shown:
 +@example
 +rotate=2*PI*t:ow='min(iw,ih)/sqrt(2)':oh=ow:c=none
 +@end example
 +@end itemize
 +
 +@subsection Commands
 +
 +The filter supports the following commands:
 +
 +@table @option
 +@item a, angle
 +Set the angle expression.
 +The command accepts the same syntax of the corresponding option.
 +
 +If the specified expression is not valid, it is kept at its current
 +value.
 +@end table
 +
 +@section sab
 +
 +Apply Shape Adaptive Blur.
 +
 +The filter accepts the following options:
 +
 +@table @option
 +@item luma_radius, lr
 +Set luma blur filter strength, must be a value in range 0.1-4.0, default
 +value is 1.0. A greater value will result in a more blurred image, and
 +in slower processing.
 +
 +@item luma_pre_filter_radius, lpfr
 +Set luma pre-filter radius, must be a value in the 0.1-2.0 range, default
 +value is 1.0.
 +
 +@item luma_strength, ls
 +Set luma maximum difference between pixels to still be considered, must
 +be a value in the 0.1-100.0 range, default value is 1.0.
 +
 +@item chroma_radius, cr
 +Set chroma blur filter strength, must be a value in range 0.1-4.0. A
 +greater value will result in a more blurred image, and in slower
 +processing.
 +
 +@item chroma_pre_filter_radius, cpfr
 +Set chroma pre-filter radius, must be a value in the 0.1-2.0 range.
 +
 +@item chroma_strength, cs
 +Set chroma maximum difference between pixels to still be considered,
 +must be a value in the 0.1-100.0 range.
 +@end table
 +
 +Each chroma option value, if not explicitly specified, is set to the
 +corresponding luma option value.
 +
 +@section scale
 +
 +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.
 +
 +@subsection Options
 +The filter accepts the following options, or any of the options
 +supported by the libswscale scaler.
 +
 +See @ref{scaler_options,,the ffmpeg-scaler manual,ffmpeg-scaler} for
 +the complete list of scaler options.
 +
 +@table @option
 +@item width, w
 +@item height, h
 +Set the output video dimension expression. Default value is the input
 +dimension.
 +
 +If the value is 0, the input width is used for the output.
 +
 +If one of the values is -1, the scale filter will use a value that
 +maintains the aspect ratio of the input image, calculated from the
 +other specified dimension. If both of them are -1, the input size is
 +used
 +
 +See below for the list of accepted constants for use in the dimension
 +expression.
 +
 +@item interl
 +Set the interlacing mode. It accepts the following values:
 +
 +@table @samp
 +@item 1
 +Force interlaced aware scaling.
 +
 +@item 0
 +Do not apply interlaced scaling.
 +
 +@item -1
 +Select interlaced aware scaling depending on whether the source frames
 +are flagged as interlaced or not.
 +@end table
 +
 +Default value is @samp{0}.
 +
 +@item flags
 +Set libswscale scaling flags. See
 +@ref{sws_flags,,the ffmpeg-scaler manual,ffmpeg-scaler} for the
 +complete list of values. If not explictly specified the filter applies
 +the default flags.
 +
 +@item size, s
 +Set the video size. For the syntax of this option, check the "Video size"
 +section in the ffmpeg-utils manual.
 +
 +@item in_color_matrix
 +@item out_color_matrix
 +Set in/output YCbCr color space type.
 +
 +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.
 +
 +Possible values:
 +
 +@table @samp
 +@item auto
 +Choose automatically.
 +
 +@item bt709
 +Format conforming to International Telecommunication Union (ITU)
 +Recommendation BT.709.
 +
 +@item fcc
 +Set color space conforming to the United States Federal Communications
 +Commission (FCC) Code of Federal Regulations (CFR) Title 47 (2003) 73.682 (a).
 +
 +@item bt601
 +Set color space conforming to:
 +
 +@itemize
 +@item
 +ITU Radiocommunication Sector (ITU-R) Recommendation BT.601
 +
 +@item
 +ITU-R Rec. BT.470-6 (1998) Systems B, B1, and G
 +
 +@item
 +Society of Motion Picture and Television Engineers (SMPTE) ST 170:2004
 +
 +@end itemize
 +
 +@item smpte240m
 +Set color space conforming to SMPTE ST 240:1999.
 +@end table
 +
 +@item in_range
 +@item out_range
 +Set in/output YCbCr sample range.
 +
 +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. Possible values:
 +
 +@table @samp
 +@item auto
 +Choose automatically.
 +
 +@item jpeg/full/pc
 +Set full range (0-255 in case of 8-bit luma).
 +
 +@item mpeg/tv
 +Set "MPEG" range (16-235 in case of 8-bit luma).
 +@end table
 +
 +@item force_original_aspect_ratio
 +Enable decreasing or increasing output video width or height if necessary to
 +keep the original aspect ratio. Possible values:
 +
 +@table @samp
 +@item disable
 +Scale the video as specified and disable this feature.
 +
 +@item decrease
 +The output video dimensions will automatically be decreased if needed.
 +
 +@item increase
 +The output video dimensions will automatically be increased if needed.
 +
 +@end table
 +
 +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 @option{w}
 +or @option{h}, you still need to specify the output resolution for this option
 +to work.
 +
 +@end table
 +
 +The values of the @option{w} and @option{h} options are expressions
 +containing the following constants:
 +
 +@table @var
 +@item in_w
 +@item in_h
 +the input width and height
 +
 +@item iw
 +@item ih
 +same as @var{in_w} and @var{in_h}
 +
 +@item out_w
 +@item out_h
 +the output (scaled) width and height
 +
 +@item ow
 +@item oh
 +same as @var{out_w} and @var{out_h}
 +
 +@item a
 +same as @var{iw} / @var{ih}
 +
 +@item sar
 +input sample aspect ratio
 +
 +@item dar
 +input display aspect ratio. Calculated from @code{(iw / ih) * sar}.
 +
 +@item hsub
 +@item vsub
 +horizontal and vertical chroma subsample values. For example for the
 +pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
 +@end table
 +
 +@subsection Examples
 +
 +@itemize
 +@item
 +Scale the input video to a size of 200x100:
 +@example
 +scale=w=200:h=100
 +@end example
 +
 +This is equivalent to:
 +@example
 +scale=200:100
 +@end example
 +
 +or:
 +@example
 +scale=200x100
 +@end example
 +
 +@item
 +Specify a size abbreviation for the output size:
 +@example
 +scale=qcif
 +@end example
 +
 +which can also be written as:
 +@example
 +scale=size=qcif
 +@end example
 +
 +@item
 +Scale the input to 2x:
 +@example
 +scale=w=2*iw:h=2*ih
 +@end example
 +
 +@item
 +The above is the same as:
 +@example
 +scale=2*in_w:2*in_h
 +@end example
 +
 +@item
 +Scale the input to 2x with forced interlaced scaling:
 +@example
 +scale=2*iw:2*ih:interl=1
 +@end example
 +
 +@item
 +Scale the input to half size:
 +@example
 +scale=w=iw/2:h=ih/2
 +@end example
 +
 +@item
 +Increase the width, and set the height to the same size:
 +@example
 +scale=3/2*iw:ow
 +@end example
 +
 +@item
 +Seek for Greek harmony:
 +@example
 +scale=iw:1/PHI*iw
 +scale=ih*PHI:ih
 +@end example
 +
 +@item
 +Increase the height, and set the width to 3/2 of the height:
 +@example
 +scale=w=3/2*oh:h=3/5*ih
 +@end example
 +
 +@item
 +Increase the size, but make the size a multiple of the chroma
 +subsample values:
 +@example
 +scale="trunc(3/2*iw/hsub)*hsub:trunc(3/2*ih/vsub)*vsub"
 +@end example
 +
 +@item
 +Increase the width to a maximum of 500 pixels, keep the same input
 +aspect ratio:
 +@example
 +scale=w='min(500\, iw*3/2):h=-1'
 +@end example
 +@end itemize
 +
 +@section separatefields
 +
 +The @code{separatefields} takes a frame-based video input and splits
 +each frame into its components fields, producing a new half height clip
 +with twice the frame rate and twice the frame count.
 +
 +This filter use field-dominance information in frame to decide which
 +of each pair of fields to place first in the output.
 +If it gets it wrong use @ref{setfield} filter before @code{separatefields} filter.
 +
 +@section setdar, setsar
 +
 +The @code{setdar} filter sets the Display Aspect Ratio for the filter
 +output video.
 +
 +This is done by changing the specified Sample (aka Pixel) Aspect
 +Ratio, according to the following equation:
 +@example
 +@var{DAR} = @var{HORIZONTAL_RESOLUTION} / @var{VERTICAL_RESOLUTION} * @var{SAR}
 +@end example
 +
 +Keep in mind that the @code{setdar} filter does not modify the pixel
 +dimensions of the video frame. Also the display aspect ratio set by
 +this filter may be changed by later filters in the filterchain,
 +e.g. in case of scaling or if another "setdar" or a "setsar" filter is
 +applied.
 +
 +The @code{setsar} filter sets the Sample (aka Pixel) Aspect Ratio for
 +the filter output video.
 +
 +Note that as a consequence of the application of this filter, the
 +output display aspect ratio will change according to the equation
 +above.
 +
 +Keep in mind that the sample aspect ratio set by the @code{setsar}
 +filter may be changed by later filters in the filterchain, e.g. if
 +another "setsar" or a "setdar" filter is applied.
 +
 +The filters accept the following options:
 +
 +@table @option
 +@item r, ratio, dar (@code{setdar} only), sar (@code{setsar} only)
 +Set the aspect ratio used by the filter.
 +
 +The parameter can be a floating point number string, an expression, or
 +a string of the form @var{num}:@var{den}, where @var{num} and
 +@var{den} are the numerator and denominator of the aspect ratio. If
 +the parameter is not specified, it is assumed the value "0".
 +In case the form "@var{num}:@var{den}" is used, the @code{:} character
 +should be escaped.
 +
 +@item max
 +Set the maximum integer value to use for expressing numerator and
 +denominator when reducing the expressed aspect ratio to a rational.
 +Default value is @code{100}.
 +
 +@end table
 +
++The parameter @var{sar} is an expression containing
++the following constants:
++
++@table @option
++@item E, PI, PHI
++the corresponding mathematical approximated values for e
++(euler number), pi (greek PI), phi (golden ratio)
++
++@item w, h
++the input width and height
++
++@item a
++same as @var{w} / @var{h}
++
++@item sar
++input sample aspect ratio
++
++@item dar
++input display aspect ratio, it is the same as (@var{w} / @var{h}) * @var{sar}
++
++@item hsub, vsub
++horizontal and vertical chroma subsample values. For example for the
++pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
++@end table
++
 +@subsection Examples
 +
 +@itemize
 +
 +@item
 +To change the display aspect ratio to 16:9, specify one of the following:
 +@example
 +setdar=dar=1.77777
 +setdar=dar=16/9
 +setdar=dar=1.77777
 +@end example
 +
 +@item
 +To change the sample aspect ratio to 10:11, specify:
 +@example
 +setsar=sar=10/11
 +@end example
 +
 +@item
 +To set a display aspect ratio of 16:9, and specify a maximum integer value of
 +1000 in the aspect ratio reduction, use the command:
 +@example
 +setdar=ratio=16/9:max=1000
 +@end example
 +
 +@end itemize
 +
 +@anchor{setfield}
 +@section setfield
 +
 +Force field for the output video frame.
 +
 +The @code{setfield} filter marks the interlace type field for the
 +output frames. It does not change the input frame, but only sets the
 +corresponding property, which affects how the frame is treated by
 +following filters (e.g. @code{fieldorder} or @code{yadif}).
 +
 +The filter accepts the following options:
 +
 +@table @option
 +
 +@item mode
 +Available values are:
 +
 +@table @samp
 +@item auto
 +Keep the same field property.
 +
 +@item bff
 +Mark the frame as bottom-field-first.
 +
 +@item tff
 +Mark the frame as top-field-first.
 +
 +@item prog
 +Mark the frame as progressive.
 +@end table
 +@end table
 +
 +@section showinfo
 +
 +Show a line containing various information for each input video frame.
 +The input video is not modified.
 +
 +The shown line contains a sequence of key/value pairs of the form
 +@var{key}:@var{value}.
 +
 +A description of each shown parameter follows:
 +
 +@table @option
 +@item n
 +sequential number of the input frame, starting from 0
 +
 +@item pts
 +Presentation TimeStamp of the input frame, expressed as a number of
 +time base units. The time base unit depends on the filter input pad.
 +
 +@item pts_time
 +Presentation TimeStamp of the input frame, expressed as a number of
 +seconds
 +
 +@item pos
 +position of the frame in the input stream, -1 if this information in
 +unavailable and/or meaningless (for example in case of synthetic video)
 +
 +@item fmt
 +pixel format name
 +
 +@item sar
 +sample aspect ratio of the input frame, expressed in the form
 +@var{num}/@var{den}
 +
 +@item s
 +size of the input frame. For the syntax of this option, check the "Video size"
 +section in the ffmpeg-utils manual.
 +
 +@item i
 +interlaced mode ("P" for "progressive", "T" for top field first, "B"
 +for bottom field first)
 +
 +@item iskey
 +1 if the frame is a key frame, 0 otherwise
 +
 +@item type
 +picture type of the input frame ("I" for an I-frame, "P" for a
 +P-frame, "B" for a B-frame, "?" for unknown type).
 +Check also the documentation of the @code{AVPictureType} enum and of
 +the @code{av_get_picture_type_char} function defined in
 +@file{libavutil/avutil.h}.
 +
 +@item checksum
 +Adler-32 checksum (printed in hexadecimal) of all the planes of the input frame
 +
 +@item plane_checksum
 +Adler-32 checksum (printed in hexadecimal) of each plane of the input frame,
 +expressed in the form "[@var{c0} @var{c1} @var{c2} @var{c3}]"
 +@end table
 +
 +@anchor{smartblur}
 +@section smartblur
 +
 +Blur the input video without impacting the outlines.
 +
 +The filter accepts the following options:
 +
 +@table @option
 +@item luma_radius, lr
 +Set the luma radius. The option value must be a float number in
 +the range [0.1,5.0] that specifies the variance of the gaussian filter
 +used to blur the image (slower if larger). Default value is 1.0.
 +
 +@item luma_strength, ls
 +Set the luma strength. The option value must be a float number
 +in the range [-1.0,1.0] that configures the blurring. A value included
 +in [0.0,1.0] will blur the image whereas a value included in
 +[-1.0,0.0] will sharpen the image. Default value is 1.0.
 +
 +@item luma_threshold, lt
 +Set the luma threshold used as a coefficient to determine
 +whether a pixel should be blurred or not. The option value must be an
 +integer in the range [-30,30]. A value of 0 will filter all the image,
 +a value included in [0,30] will filter flat areas and a value included
 +in [-30,0] will filter edges. Default value is 0.
 +
 +@item chroma_radius, cr
 +Set the chroma radius. The option value must be a float number in
 +the range [0.1,5.0] that specifies the variance of the gaussian filter
 +used to blur the image (slower if larger). Default value is 1.0.
 +
 +@item chroma_strength, cs
 +Set the chroma strength. The option value must be a float number
 +in the range [-1.0,1.0] that configures the blurring. A value included
 +in [0.0,1.0] will blur the image whereas a value included in
 +[-1.0,0.0] will sharpen the image. Default value is 1.0.
 +
 +@item chroma_threshold, ct
 +Set the chroma threshold used as a coefficient to determine
 +whether a pixel should be blurred or not. The option value must be an
 +integer in the range [-30,30]. A value of 0 will filter all the image,
 +a value included in [0,30] will filter flat areas and a value included
 +in [-30,0] will filter edges. Default value is 0.
 +@end table
 +
 +If a chroma option is not explicitly set, the corresponding luma value
 +is set.
 +
 +@section stereo3d
 +
 +Convert between different stereoscopic image formats.
 +
 +The filters accept the following options:
 +
 +@table @option
 +@item in
 +Set stereoscopic image format of input.
 +
 +Available values for input image formats are:
 +@table @samp
 +@item sbsl
 +side by side parallel (left eye left, right eye right)
 +
 +@item sbsr
 +side by side crosseye (right eye left, left eye right)
 +
 +@item sbs2l
 +side by side parallel with half width resolution
 +(left eye left, right eye right)
 +
 +@item sbs2r
 +side by side crosseye with half width resolution
 +(right eye left, left eye right)
 +
 +@item abl
 +above-below (left eye above, right eye below)
 +
 +@item abr
 +above-below (right eye above, left eye below)
 +
 +@item ab2l
 +above-below with half height resolution
 +(left eye above, right eye below)
 +
 +@item ab2r
 +above-below with half height resolution
 +(right eye above, left eye below)
 +
 +@item al
 +alternating frames (left eye first, right eye second)
 +
 +@item ar
 +alternating frames (right eye first, left eye second)
 +
 +Default value is @samp{sbsl}.
 +@end table
 +
 +@item out
 +Set stereoscopic image format of output.
 +
 +Available values for output image formats are all the input formats as well as:
 +@table @samp
 +@item arbg
 +anaglyph red/blue gray
 +(red filter on left eye, blue filter on right eye)
 +
 +@item argg
 +anaglyph red/green gray
 +(red filter on left eye, green filter on right eye)
 +
 +@item arcg
 +anaglyph red/cyan gray
 +(red filter on left eye, cyan filter on right eye)
 +
 +@item arch
 +anaglyph red/cyan half colored
 +(red filter on left eye, cyan filter on right eye)
 +
 +@item arcc
 +anaglyph red/cyan color
 +(red filter on left eye, cyan filter on right eye)
 +
 +@item arcd
 +anaglyph red/cyan color optimized with the least squares projection of dubois
 +(red filter on left eye, cyan filter on right eye)
 +
 +@item agmg
 +anaglyph green/magenta gray
 +(green filter on left eye, magenta filter on right eye)
 +
 +@item agmh
 +anaglyph green/magenta half colored
 +(green filter on left eye, magenta filter on right eye)
 +
 +@item agmc
 +anaglyph green/magenta colored
 +(green filter on left eye, magenta filter on right eye)
 +
 +@item agmd
 +anaglyph green/magenta color optimized with the least squares projection of dubois
 +(green filter on left eye, magenta filter on right eye)
 +
 +@item aybg
 +anaglyph yellow/blue gray
 +(yellow filter on left eye, blue filter on right eye)
 +
 +@item aybh
 +anaglyph yellow/blue half colored
 +(yellow filter on left eye, blue filter on right eye)
 +
 +@item aybc
 +anaglyph yellow/blue colored
 +(yellow filter on left eye, blue filter on right eye)
 +
 +@item aybd
 +anaglyph yellow/blue color optimized with the least squares projection of dubois
 +(yellow filter on left eye, blue filter on right eye)
 +
 +@item irl
 +interleaved rows (left eye has top row, right eye starts on next row)
 +
 +@item irr
 +interleaved rows (right eye has top row, left eye starts on next row)
 +
 +@item ml
 +mono output (left eye only)
 +
 +@item mr
 +mono output (right eye only)
 +@end table
 +
 +Default value is @samp{arcd}.
 +@end table
 +
 +@subsection Examples
 +
 +@itemize
 +@item
 +Convert input video from side by side parallel to anaglyph yellow/blue dubois:
 +@example
 +stereo3d=sbsl:aybd
 +@end example
 +
 +@item
 +Convert input video from above bellow (left eye above, right eye below) to side by side crosseye.
 +@example
 +stereo3d=abl:sbsr
 +@end example
 +@end itemize
 +
 +@section spp
 +
 +Apply a simple postprocessing filter that compresses and decompresses the image
 +at several (or - in the case of @option{quality} level @code{6} - all) shifts
 +and average the results.
 +
 +The filter accepts the following options:
 +
 +@table @option
 +@item quality
 +Set quality. This option defines the number of levels for averaging. It accepts
 +an integer in the range 0-6. If set to @code{0}, the filter will have no
 +effect. A value of @code{6} means the higher quality. For each increment of
 +that value the speed drops by a factor of approximately 2.  Default value is
 +@code{3}.
 +
 +@item qp
 +Force a constant quantization parameter. If not set, the filter will use the QP
 +from the video stream (if available).
 +
 +@item mode
 +Set thresholding mode. Available modes are:
 +
 +@table @samp
 +@item hard
 +Set hard thresholding (default).
 +@item soft
 +Set soft thresholding (better de-ringing effect, but likely blurrier).
 +@end table
 +
 +@item use_bframe_qp
 +Enable the use of the QP from the B-Frames if set to @code{1}. Using this
 +option may cause flicker since the B-Frames have often larger QP. Default is
 +@code{0} (not enabled).
 +@end table
 +
 +@anchor{subtitles}
 +@section subtitles
 +
 +Draw subtitles on top of input video using the libass library.
 +
 +To enable compilation of this filter you need to configure FFmpeg with
 +@code{--enable-libass}. This filter also requires a build with libavcodec and
 +libavformat to convert the passed subtitles file to ASS (Advanced Substation
 +Alpha) subtitles format.
 +
 +The filter accepts the following options:
 +
 +@table @option
 +@item filename, f
 +Set the filename of the subtitle file to read. It must be specified.
 +
 +@item original_size
 +Specify the size of the original video, the video for which the ASS file
 +was composed. For the syntax of this option, check the "Video size" section in
 +the ffmpeg-utils manual. Due to a misdesign in ASS aspect ratio arithmetic,
 +this is necessary to correctly scale the fonts if the aspect ratio has been
 +changed.
 +
 +@item charenc
 +Set subtitles input character encoding. @code{subtitles} filter only. Only
 +useful if not UTF-8.
 +@end table
 +
 +If the first key is not specified, it is assumed that the first value
 +specifies the @option{filename}.
 +
 +For example, to render the file @file{sub.srt} on top of the input
 +video, use the command:
 +@example
 +subtitles=sub.srt
 +@end example
 +
 +which is equivalent to:
 +@example
 +subtitles=filename=sub.srt
 +@end example
 +
 +@section super2xsai
 +
 +Scale the input by 2x and smooth using the Super2xSaI (Scale and
 +Interpolate) pixel art scaling algorithm.
 +
 +Useful for enlarging pixel art images without reducing sharpness.
 +
 +@section swapuv
 +Swap U & V plane.
 +
 +@section telecine
 +
 +Apply telecine process to the video.
 +
 +This filter accepts the following options:
 +
 +@table @option
 +@item first_field
 +@table @samp
 +@item top, t
 +top field first
 +@item bottom, b
 +bottom field first
 +The default value is @code{top}.
 +@end table
 +
 +@item pattern
 +A string of numbers representing the pulldown pattern you wish to apply.
 +The default value is @code{23}.
 +@end table
 +
 +@example
 +Some typical patterns:
 +
 +NTSC output (30i):
 +27.5p: 32222
 +24p: 23 (classic)
 +24p: 2332 (preferred)
 +20p: 33
 +18p: 334
 +16p: 3444
 +
 +PAL output (25i):
 +27.5p: 12222
 +24p: 222222222223 ("Euro pulldown")
 +16.67p: 33
 +16p: 33333334
 +@end example
 +
 +@section thumbnail
 +Select the most representative frame in a given sequence of consecutive frames.
 +
 +The filter accepts the following options:
 +
 +@table @option
 +@item n
 +Set the frames batch size to analyze; in a set of @var{n} frames, the filter
 +will pick one of them, and then handle the next batch of @var{n} frames until
 +the end. Default is @code{100}.
 +@end table
 +
 +Since the filter keeps track of the whole frames sequence, a bigger @var{n}
 +value will result in a higher memory usage, so a high value is not recommended.
 +
 +@subsection Examples
 +
 +@itemize
 +@item
 +Extract one picture each 50 frames:
 +@example
 +thumbnail=50
 +@end example
 +
 +@item
 +Complete example of a thumbnail creation with @command{ffmpeg}:
 +@example
 +ffmpeg -i in.avi -vf thumbnail,scale=300:200 -frames:v 1 out.png
 +@end example
 +@end itemize
 +
 +@section tile
 +
 +Tile several successive frames together.
 +
 +The filter accepts the following options:
 +
 +@table @option
 +
 +@item layout
 +Set the grid size (i.e. the number of lines and columns). For the syntax of
 +this option, check the "Video size" section in the ffmpeg-utils manual.
 +
 +@item nb_frames
 +Set the maximum number of frames to render in the given area. It must be less
 +than or equal to @var{w}x@var{h}. The default value is @code{0}, meaning all
 +the area will be used.
 +
 +@item margin
 +Set the outer border margin in pixels.
 +
 +@item padding
 +Set the inner border thickness (i.e. the number of pixels between frames). For
 +more advanced padding options (such as having different values for the edges),
 +refer to the pad video filter.
 +
 +@item color
 +Specify the color of the unused areaFor the syntax of this option, check the
 +"Color" section in the ffmpeg-utils manual. The default value of @var{color}
 +is "black".
 +@end table
 +
 +@subsection Examples
 +
 +@itemize
 +@item
 +Produce 8x8 PNG tiles of all keyframes (@option{-skip_frame nokey}) in a movie:
 +@example
 +ffmpeg -skip_frame nokey -i file.avi -vf 'scale=128:72,tile=8x8' -an -vsync 0 keyframes%03d.png
 +@end example
 +The @option{-vsync 0} is necessary to prevent @command{ffmpeg} from
 +duplicating each output frame to accomodate the originally detected frame
 +rate.
 +
 +@item
 +Display @code{5} pictures in an area of @code{3x2} frames,
 +with @code{7} pixels between them, and @code{2} pixels of initial margin, using
 +mixed flat and named options:
 +@example
 +tile=3x2:nb_frames=5:padding=7:margin=2
 +@end example
 +@end itemize
 +
 +@section tinterlace
 +
 +Perform various types of temporal field interlacing.
 +
 +Frames are counted starting from 1, so the first input frame is
 +considered odd.
 +
 +The filter accepts the following options:
 +
 +@table @option
 +
 +@item mode
 +Specify the mode of the interlacing. This option can also be specified
 +as a value alone. See below for a list of values for this option.
 +
 +Available values are:
 +
 +@table @samp
 +@item merge, 0
 +Move odd frames into the upper field, even into the lower field,
 +generating a double height frame at half frame rate.
 +
 +@item drop_odd, 1
 +Only output even frames, odd frames are dropped, generating a frame with
 +unchanged height at half frame rate.
 +
 +@item drop_even, 2
 +Only output odd frames, even frames are dropped, generating a frame with
 +unchanged height at half frame rate.
 +
 +@item pad, 3
 +Expand each frame to full height, but pad alternate lines with black,
 +generating a frame with double height at the same input frame rate.
 +
 +@item interleave_top, 4
 +Interleave the upper field from odd frames with the lower field from
 +even frames, generating a frame with unchanged height at half frame rate.
 +
 +@item interleave_bottom, 5
 +Interleave the lower field from odd frames with the upper field from
 +even frames, generating a frame with unchanged height at half frame rate.
 +
 +@item interlacex2, 6
 +Double frame rate with unchanged height. Frames are inserted each
 +containing the second temporal field from the previous input frame and
 +the first temporal field from the next input frame. This mode relies on
 +the top_field_first flag. Useful for interlaced video displays with no
 +field synchronisation.
 +@end table
 +
 +Numeric values are deprecated but are accepted for backward
 +compatibility reasons.
 +
 +Default mode is @code{merge}.
 +
 +@item flags
 +Specify flags influencing the filter process.
 +
 +Available value for @var{flags} is:
 +
 +@table @option
 +@item low_pass_filter, vlfp
 +Enable vertical low-pass filtering in the filter.
 +Vertical low-pass filtering is required when creating an interlaced
 +destination from a progressive source which contains high-frequency
 +vertical detail. Filtering will reduce interlace 'twitter' and Moire
 +patterning.
 +
 +Vertical low-pass filtering can only be enabled for @option{mode}
 +@var{interleave_top} and @var{interleave_bottom}.
 +
 +@end table
 +@end table
 +
 +@section transpose
 +
 +Transpose rows with columns in the input video and optionally flip it.
 +
 +This filter accepts the following options:
 +
 +@table @option
 +
 +@item dir
 +Specify the transposition direction.
 +
 +Can assume the following values:
 +@table @samp
 +@item 0, 4, cclock_flip
 +Rotate by 90 degrees counterclockwise and vertically flip (default), that is:
 +@example
 +L.R     L.l
 +. . ->  . .
 +l.r     R.r
 +@end example
 +
 +@item 1, 5, clock
 +Rotate by 90 degrees clockwise, that is:
 +@example
 +L.R     l.L
 +. . ->  . .
 +l.r     r.R
 +@end example
 +
 +@item 2, 6, cclock
 +Rotate by 90 degrees counterclockwise, that is:
 +@example
 +L.R     R.r
 +. . ->  . .
 +l.r     L.l
 +@end example
 +
 +@item 3, 7, clock_flip
 +Rotate by 90 degrees clockwise and vertically flip, that is:
 +@example
 +L.R     r.R
 +. . ->  . .
 +l.r     l.L
 +@end example
 +@end table
 +
 +For values between 4-7, the transposition is only done if the input
 +video geometry is portrait and not landscape. These values are
 +deprecated, the @code{passthrough} option should be used instead.
 +
 +Numerical values are deprecated, and should be dropped in favor of
 +symbolic constants.
 +
 +@item passthrough
 +Do not apply the transposition if the input geometry matches the one
 +specified by the specified value. It accepts the following values:
 +@table @samp
 +@item none
 +Always apply transposition.
 +@item portrait
 +Preserve portrait geometry (when @var{height} >= @var{width}).
 +@item landscape
 +Preserve landscape geometry (when @var{width} >= @var{height}).
 +@end table
 +
 +Default value is @code{none}.
 +@end table
 +
 +For example to rotate by 90 degrees clockwise and preserve portrait
 +layout:
 +@example
 +transpose=dir=1:passthrough=portrait
 +@end example
 +
 +The command above can also be specified as:
 +@example
 +transpose=1:portrait
 +@end example
 +
 +@section trim
 +Trim the input so that the output contains one continuous subpart of the input.
 +
 +This filter accepts the following options:
 +@table @option
 +@item start
 +Specify time of the start of the kept section, i.e. the frame with the
 +timestamp @var{start} will be the first frame in the output.
 +
 +@item end
 +Specify time of the first frame that will be dropped, i.e. the frame
 +immediately preceding the one with the timestamp @var{end} will be the last
 +frame in the output.
 +
 +@item start_pts
 +Same as @var{start}, except this option sets the start timestamp in timebase
 +units instead of seconds.
 +
 +@item end_pts
 +Same as @var{end}, except this option sets the end timestamp in timebase units
 +instead of seconds.
 +
 +@item duration
 +Specify maximum duration of the output.
 +
 +@item start_frame
 +Number of the first frame that should be passed to output.
 +
 +@item end_frame
 +Number of the first frame that should be dropped.
 +@end table
 +
 +@option{start}, @option{end}, @option{duration} are expressed as time
 +duration specifications, check the "Time duration" section in the
 +ffmpeg-utils manual.
 +
 +Note that the first two sets of the start/end options and the @option{duration}
 +option look at the frame timestamp, while the _frame variants simply count the
 +frames that pass through the filter. Also note that this filter does not modify
 +the timestamps. If you wish that the output timestamps start at zero, insert a
 +setpts filter after the trim filter.
 +
 +If multiple start or end options are set, this filter tries to be greedy and
 +keep all the frames that match at least one of the specified constraints. To keep
 +only the part that matches all the constraints at once, chain multiple trim
 +filters.
 +
 +The defaults are such that all the input is kept. So it is possible to set e.g.
 +just the end values to keep everything before the specified time.
 +
 +Examples:
 +@itemize
 +@item
 +drop everything except the second minute of input
 +@example
 +ffmpeg -i INPUT -vf trim=60:120
 +@end example
 +
 +@item
 +keep only the first second
 +@example
 +ffmpeg -i INPUT -vf trim=duration=1
 +@end example
 +
 +@end itemize
 +
 +
 +@section unsharp
 +
 +Sharpen or blur the input video.
 +
 +It accepts the following parameters:
 +
 +@table @option
 +@item luma_msize_x, lx
 +Set the luma matrix horizontal size. It must be an odd integer between
 +3 and 63, default value is 5.
 +
 +@item luma_msize_y, ly
 +Set the luma matrix vertical size. It must be an odd integer between 3
 +and 63, default value is 5.
 +
 +@item luma_amount, la
 +Set the luma effect strength. It can be a float number, reasonable
 +values lay between -1.5 and 1.5.
 +
 +Negative values will blur the input video, while positive values will
 +sharpen it, a value of zero will disable the effect.
 +
 +Default value is 1.0.
 +
 +@item chroma_msize_x, cx
 +Set the chroma matrix horizontal size. It must be an odd integer
 +between 3 and 63, default value is 5.
 +
 +@item chroma_msize_y, cy
 +Set the chroma matrix vertical size. It must be an odd integer
 +between 3 and 63, default value is 5.
 +
 +@item chroma_amount, ca
 +Set the chroma effect strength. It can be a float number, reasonable
 +values lay between -1.5 and 1.5.
 +
 +Negative values will blur the input video, while positive values will
 +sharpen it, a value of zero will disable the effect.
 +
 +Default value is 0.0.
 +
 +@item opencl
 +If set to 1, specify using OpenCL capabilities, only available if
 +FFmpeg was configured with @code{--enable-opencl}. Default value is 0.
 +
 +@end table
 +
 +All parameters are optional and default to the equivalent of the
 +string '5:5:1.0:5:5:0.0'.
 +
 +@subsection Examples
 +
 +@itemize
 +@item
 +Apply strong luma sharpen effect:
 +@example
 +unsharp=luma_msize_x=7:luma_msize_y=7:luma_amount=2.5
 +@end example
 +
 +@item
 +Apply strong blur of both luma and chroma parameters:
 +@example
 +unsharp=7:7:-2:7:7:-2
 +@end example
 +@end itemize
 +
 +@anchor{vidstabdetect}
 +@section vidstabdetect
 +
 +Analyze video stabilization/deshaking. Perform pass 1 of 2, see
 +@ref{vidstabtransform} for pass 2.
 +
 +This filter generates a file with relative translation and rotation
 +transform information about subsequent frames, which is then used by
 +the @ref{vidstabtransform} filter.
 +
 +To enable compilation of this filter you need to configure FFmpeg with
 +@code{--enable-libvidstab}.
 +
 +This filter accepts the following options:
 +
 +@table @option
 +@item result
 +Set the path to the file used to write the transforms information.
 +Default value is @file{transforms.trf}.
 +
 +@item shakiness
 +Set how shaky the video is and how quick the camera is. It accepts an
 +integer in the range 1-10, a value of 1 means little shakiness, a
 +value of 10 means strong shakiness. Default value is 5.
 +
 +@item accuracy
 +Set the accuracy of the detection process. It must be a value in the
 +range 1-15. A value of 1 means low accuracy, a value of 15 means high
 +accuracy. Default value is 9.
 +
 +@item stepsize
 +Set stepsize of the search process. The region around minimum is
 +scanned with 1 pixel resolution. Default value is 6.
 +
 +@item mincontrast
 +Set minimum contrast. Below this value a local measurement field is
 +discarded. Must be a floating point value in the range 0-1. Default
 +value is 0.3.
 +
 +@item tripod
 +Set reference frame number for tripod mode.
 +
 +If enabled, the motion of the frames is compared to a reference frame
 +in the filtered stream, identified by the specified number. The idea
 +is to compensate all movements in a more-or-less static scene and keep
 +the camera view absolutely still.
 +
 +If set to 0, it is disabled. The frames are counted starting from 1.
 +
 +@item show
 +Show fields and transforms in the resulting frames. It accepts an
 +integer in the range 0-2. Default value is 0, which disables any
 +visualization.
 +@end table
 +
 +@subsection Examples
 +
 +@itemize
 +@item
 +Use default values:
 +@example
 +vidstabdetect
 +@end example
 +
 +@item
 +Analyze strongly shaky movie and put the results in file
 +@file{mytransforms.trf}:
 +@example
 +vidstabdetect=shakiness=10:accuracy=15:result="mytransforms.trf"
 +@end example
 +
 +@item
 +Visualize the result of internal transformations in the resulting
 +video:
 +@example
 +vidstabdetect=show=1
 +@end example
 +
 +@item
 +Analyze a video with medium shakiness using @command{ffmpeg}:
 +@example
 +ffmpeg -i input -vf vidstabdetect=shakiness=5:show=1 dummy.avi
 +@end example
 +@end itemize
 +
 +@anchor{vidstabtransform}
 +@section vidstabtransform
 +
 +Video stabilization/deshaking: pass 2 of 2,
 +see @ref{vidstabdetect} for pass 1.
 +
 +Read a file with transform information for each frame and
 +apply/compensate them. Together with the @ref{vidstabdetect}
 +filter this can be used to deshake videos. See also
 +@url{http://public.hronopik.de/vid.stab}. It is important to also use
 +the unsharp filter, see below.
 +
 +To enable compilation of this filter you need to configure FFmpeg with
 +@code{--enable-libvidstab}.
 +
 +This filter accepts the following options:
 +
 +@table @option
 +
 +@item input
 +path to the file used to read the transforms (default: @file{transforms.trf})
 +
 +@item smoothing
 +number of frames (value*2 + 1) used for lowpass filtering the camera movements
 +(default: 10). For example a number of 10 means that 21 frames are used
 +(10 in the past and 10 in the future) to smoothen the motion in the
 +video. A larger values leads to a smoother video, but limits the
 +acceleration of the camera (pan/tilt movements).
 +
 +@item maxshift
 +maximal number of pixels to translate frames (default: -1 no limit)
 +
 +@item maxangle
 +maximal angle in radians (degree*PI/180) to rotate frames (default: -1
 +no limit)
 +
 +@item crop
 +How to deal with borders that may be visible due to movement
 +compensation. Available values are:
 +
 +@table @samp
 +@item keep
 +keep image information from previous frame (default)
 +@item black
 +fill the border black
 +@end table
 +
 +@item invert
 +@table @samp
 +@item 0
 +keep transforms normal (default)
 +@item 1
 +invert transforms
 +@end table
 +
 +@item relative
 +consider transforms as
 +@table @samp
 +@item 0
 +absolute
 +@item 1
 +relative to previous frame (default)
 +@end table
 +
 +@item zoom
 +percentage to zoom (default: 0)
 +@table @samp
 +@item >0
 +zoom in
 +@item <0
 +zoom out
 +@end table
 +
 +@item optzoom
 +set optimal zooming to avoid borders
 +@table @samp
 +@item 0
 +disabled
 +@item 1
 +optimal static zoom value is determined (only very strong movements will lead to visible borders) (default)
 +@item 2
 +optimal adaptive zoom value is determined (no borders will be visible)
 +@end table
 +Note that the value given at zoom is added to the one calculated
 +here.
 +
 +@item interpol
 +type of interpolation
 +
 +Available values are:
 +@table @samp
 +@item no
 +no interpolation
 +@item linear
 +linear only horizontal
 +@item bilinear
 +linear in both directions (default)
 +@item bicubic
 +cubic in both directions (slow)
 +@end table
 +
 +@item tripod
 +virtual tripod mode means that the video is stabilized such that the
 +camera stays stationary. Use also @code{tripod} option of
 +@ref{vidstabdetect}.
 +@table @samp
 +@item 0
 +off (default)
 +@item 1
 +virtual tripod mode: equivalent to @code{relative=0:smoothing=0}
 +@end table
 +
 +@end table
 +
 +@subsection Examples
 +
 +@itemize
 +@item
 +typical call with default default values:
 + (note the unsharp filter which is always recommended)
 +@example
 +ffmpeg -i inp.mpeg -vf vidstabtransform,unsharp=5:5:0.8:3:3:0.4 inp_stabilized.mpeg
 +@end example
 +
 +@item
 +zoom in a bit more and load transform data from a given file
 +@example
 +vidstabtransform=zoom=5:input="mytransforms.trf"
 +@end example
 +
 +@item
 +smoothen the video even more
 +@example
 +vidstabtransform=smoothing=30
 +@end example
 +
 +@end itemize
 +
 +@section vflip
 +
 +Flip the input video vertically.
 +
 +For example, to vertically flip a video with @command{ffmpeg}:
 +@example
 +ffmpeg -i in.avi -vf "vflip" out.avi
 +@end example
 +
 +@section vignette
 +
 +Make or reverse a natural vignetting effect.
 +
 +The filter accepts the following options:
 +
 +@table @option
 +@item angle, a
 +Set lens angle expression as a number of radians.
 +
 +The value is clipped in the @code{[0,PI/2]} range.
 +
 +Default value: @code{"PI/5"}
 +
 +@item x0
 +@item y0
 +Set center coordinates expressions. Respectively @code{"w/2"} and @code{"h/2"}
 +by default.
 +
 +@item mode
 +Set forward/backward mode.
 +
 +Available modes are:
 +@table @samp
 +@item forward
 +The larger the distance from the central point, the darker the image becomes.
 +
 +@item backward
 +The larger the distance from the central point, the brighter the image becomes.
 +This can be used to reverse a vignette effect, though there is no automatic
 +detection to extract the lens @option{angle} and other settings (yet). It can
 +also be used to create a burning effect.
 +@end table
 +
 +Default value is @samp{forward}.
 +
 +@item eval
 +Set evaluation mode for the expressions (@option{angle}, @option{x0}, @option{y0}).
 +
 +It accepts the following values:
 +@table @samp
 +@item init
 +Evaluate expressions only once during the filter initialization.
 +
 +@item frame
 +Evaluate expressions for each incoming frame. This is way slower than the
 +@samp{init} mode since it requires all the scalers to be re-computed, but it
 +allows advanced dynamic expressions.
 +@end table
 +
 +Default value is @samp{init}.
 +
 +@item dither
 +Set dithering to reduce the circular banding effects. Default is @code{1}
 +(enabled).
 +
 +@item aspect
 +Set vignette aspect. This setting allows to adjust the shape of the vignette.
 +Setting this value to the SAR of the input will make a rectangular vignetting
 +following the dimensions of the video.
 +
 +Default is @code{1/1}.
 +@end table
 +
 +@subsection Expressions
 +
 +The @option{alpha}, @option{x0} and @option{y0} expressions can contain the
 +following parameters.
 +
 +@table @option
 +@item w
 +@item h
 +input width and height
 +
 +@item n
 +the number of input frame, starting from 0
 +
 +@item pts
 +the PTS (Presentation TimeStamp) time of the filtered video frame, expressed in
 +@var{TB} units, NAN if undefined
 +
 +@item r
 +frame rate of the input video, NAN if the input frame rate is unknown
 +
 +@item t
 +the PTS (Presentation TimeStamp) of the filtered video frame,
 +expressed in seconds, NAN if undefined
 +
 +@item tb
 +time base of the input video
 +@end table
 +
 +
 +@subsection Examples
 +
 +@itemize
 +@item
 +Apply simple strong vignetting effect:
 +@example
 +vignette=PI/4
 +@end example
 +
 +@item
 +Make a flickering vignetting:
 +@example
 +vignette='PI/4+random(1)*PI/50':eval=frame
 +@end example
 +
 +@end itemize
 +
 +@section w3fdif
 +
 +Deinterlace the input video ("w3fdif" stands for "Weston 3 Field
 +Deinterlacing Filter").
 +
 +Based on the process described by Martin Weston for BBC R&D, and
 +implemented based on the de-interlace algorithm written by Jim
 +Easterbrook for BBC R&D, the Weston 3 field deinterlacing filter
 +uses filter coefficients calculated by BBC R&D.
 +
 +There are two sets of filter coefficients, so called "simple":
 +and "complex". Which set of filter coefficients is used can
 +be set by passing an optional parameter:
 +
 +@table @option
 +@item filter
 +Set the interlacing filter coefficients. Accepts one of the following values:
 +
 +@table @samp
 +@item simple
 +Simple filter coefficient set.
 +@item complex
 +More-complex filter coefficient set.
 +@end table
 +Default value is @samp{complex}.
 +
 +@item deint
 +Specify which frames to deinterlace. Accept one of the following values:
 +
 +@table @samp
 +@item all
 +Deinterlace all frames,
 +@item interlaced
 +Only deinterlace frames marked as interlaced.
 +@end table
 +
 +Default value is @samp{all}.
 +@end table
 +
 +@anchor{yadif}
 +@section yadif
 +
 +Deinterlace the input video ("yadif" means "yet another deinterlacing
 +filter").
 +
 +This filter accepts the following options:
 +
 +
 +@table @option
 +
 +@item mode
 +The interlacing mode to adopt, accepts one of the following values:
 +
 +@table @option
 +@item 0, send_frame
 +output 1 frame for each frame
 +@item 1, send_field
 +output 1 frame for each field
 +@item 2, send_frame_nospatial
 +like @code{send_frame} but skip spatial interlacing check
 +@item 3, send_field_nospatial
 +like @code{send_field} but skip spatial interlacing check
 +@end table
 +
 +Default value is @code{send_frame}.
 +
 +@item parity
 +The picture field parity assumed for the input interlaced video, accepts one of
 +the following values:
 +
 +@table @option
 +@item 0, tff
 +assume top field first
 +@item 1, bff
 +assume bottom field first
 +@item -1, auto
 +enable automatic detection
 +@end table
 +
 +Default value is @code{auto}.
 +If interlacing is unknown or decoder does not export this information,
 +top field first will be assumed.
 +
 +@item deint
 +Specify which frames to deinterlace. Accept one of the following
 +values:
 +
 +@table @option
 +@item 0, all
 +deinterlace all frames
 +@item 1, interlaced
 +only deinterlace frames marked as interlaced
 +@end table
 +
 +Default value is @code{all}.
 +@end table
 +
 +@c man end VIDEO FILTERS
 +
 +@chapter Video Sources
 +@c man begin VIDEO SOURCES
 +
 +Below is a description of the currently available video sources.
 +
 +@section buffer
 +
 +Buffer video frames, and make them available to the filter chain.
 +
 +This source is mainly intended for a programmatic use, in particular
 +through the interface defined in @file{libavfilter/vsrc_buffer.h}.
 +
 +This source accepts the following options:
 +
 +@table @option
 +
 +@item video_size
 +Specify the size (width and height) of the buffered video frames. For the
 +syntax of this option, check the "Video size" section in the ffmpeg-utils
 +manual.
 +
 +@item width
 +Input video width.
 +
 +@item height
 +Input video height.
 +
 +@item pix_fmt
 +A string representing the pixel format of the buffered video frames.
 +It may be a number corresponding to a pixel format, or a pixel format
 +name.
 +
 +@item time_base
 +Specify the timebase assumed by the timestamps of the buffered frames.
 +
 +@item frame_rate
 +Specify the frame rate expected for the video stream.
 +
 +@item pixel_aspect, sar
 +Specify the sample aspect ratio assumed by the video frames.
 +
 +@item sws_param
 +Specify the optional parameters to be used for the scale filter which
 +is automatically inserted when an input change is detected in the
 +input size or format.
 +@end table
 +
 +For example:
 +@example
 +buffer=width=320:height=240:pix_fmt=yuv410p:time_base=1/24:sar=1
 +@end example
 +
 +will instruct the source to accept video frames with size 320x240 and
 +with format "yuv410p", assuming 1/24 as the timestamps timebase and
 +square pixels (1:1 sample aspect ratio).
 +Since the pixel format with name "yuv410p" corresponds to the number 6
 +(check the enum AVPixelFormat definition in @file{libavutil/pixfmt.h}),
 +this example corresponds to:
 +@example
 +buffer=size=320x240:pixfmt=6:time_base=1/24:pixel_aspect=1/1
 +@end example
 +
 +Alternatively, the options can be specified as a flat string, but this
 +syntax is deprecated:
 +
 +@var{width}:@var{height}:@var{pix_fmt}:@var{time_base.num}:@var{time_base.den}:@var{pixel_aspect.num}:@var{pixel_aspect.den}[:@var{sws_param}]
 +
 +@section cellauto
 +
 +Create a pattern generated by an elementary cellular automaton.
 +
 +The initial state of the cellular automaton can be defined through the
 +@option{filename}, and @option{pattern} options. If such options are
 +not specified an initial state is created randomly.
 +
 +At each new frame a new row in the video is filled with the result of
 +the cellular automaton next generation. The behavior when the whole
 +frame is filled is defined by the @option{scroll} option.
 +
 +This source accepts the following options:
 +
 +@table @option
 +@item filename, f
 +Read the initial cellular automaton state, i.e. the starting row, from
 +the specified file.
 +In the file, each non-whitespace character is considered an alive
 +cell, a newline will terminate the row, and further characters in the
 +file will be ignored.
 +
 +@item pattern, p
 +Read the initial cellular automaton state, i.e. the starting row, from
 +the specified string.
 +
 +Each non-whitespace character in the string is considered an alive
 +cell, a newline will terminate the row, and further characters in the
 +string will be ignored.
 +
 +@item rate, r
 +Set the video rate, that is the number of frames generated per second.
 +Default is 25.
 +
 +@item random_fill_ratio, ratio
 +Set the random fill ratio for the initial cellular automaton row. It
 +is a floating point number value ranging from 0 to 1, defaults to
 +1/PHI.
 +
 +This option is ignored when a file or a pattern is specified.
 +
 +@item random_seed, seed
 +Set the seed for filling randomly the initial row, must be an integer
 +included between 0 and UINT32_MAX. If not specified, or if explicitly
 +set to -1, the filter will try to use a good random seed on a best
 +effort basis.
 +
 +@item rule
 +Set the cellular automaton rule, it is a number ranging from 0 to 255.
 +Default value is 110.
 +
 +@item size, s
 +Set the size of the output video. For the syntax of this option, check
 +the "Video size" section in the ffmpeg-utils manual.
 +
 +If @option{filename} or @option{pattern} is specified, the size is set
 +by default to the width of the specified initial state row, and the
 +height is set to @var{width} * PHI.
 +
 +If @option{size} is set, it must contain the width of the specified
 +pattern string, and the specified pattern will be centered in the
 +larger row.
 +
 +If a filename or a pattern string is not specified, the size value
 +defaults to "320x518" (used for a randomly generated initial state).
 +
 +@item scroll
 +If set to 1, scroll the output upward when all the rows in the output
 +have been already filled. If set to 0, the new generated row will be
 +written over the top row just after the bottom row is filled.
 +Defaults to 1.
 +
 +@item start_full, full
 +If set to 1, completely fill the output with generated rows before
 +outputting the first frame.
 +This is the default behavior, for disabling set the value to 0.
 +
 +@item stitch
 +If set to 1, stitch the left and right row edges together.
 +This is the default behavior, for disabling set the value to 0.
 +@end table
 +
 +@subsection Examples
 +
 +@itemize
 +@item
 +Read the initial state from @file{pattern}, and specify an output of
 +size 200x400.
 +@example
 +cellauto=f=pattern:s=200x400
 +@end example
  
 -@anchor{dilate}
 -@subsection dilate
 +@item
 +Generate a random initial row with a width of 200 cells, with a fill
 +ratio of 2/3:
 +@example
 +cellauto=ratio=2/3:s=200x200
 +@end example
  
 -Dilate an image by using a specific structuring element.
 -This filter corresponds to the libopencv function @code{cvDilate}.
 +@item
 +Create a pattern generated by rule 18 starting by a single alive cell
 +centered on an initial row with width 100:
 +@example
 +cellauto=p=@@:s=100x400:full=0:rule=18
 +@end example
  
 -It accepts the parameters: @var{struct_el}|@var{nb_iterations}.
 +@item
 +Specify a more elaborated initial pattern:
 +@example
 +cellauto=p='@@@@ @@ @@@@':s=100x400:full=0:rule=18
 +@end example
  
 -@var{struct_el} represents a structuring element, and has the syntax:
 -@var{cols}x@var{rows}+@var{anchor_x}x@var{anchor_y}/@var{shape}
 +@end itemize
  
 -@var{cols} and @var{rows} represent the number of columns and rows of
 -the structuring element, @var{anchor_x} and @var{anchor_y} the anchor
 -point, and @var{shape} the shape for the structuring element, and
 -can be one of the values "rect", "cross", "ellipse", "custom".
 +@section mandelbrot
  
 -If the value for @var{shape} is "custom", it must be followed by a
 -string of the form "=@var{filename}". The file with name
 -@var{filename} is assumed to represent a binary image, with each
 -printable character corresponding to a bright pixel. When a custom
 -@var{shape} is used, @var{cols} and @var{rows} are ignored, the number
 -or columns and rows of the read file are assumed instead.
 +Generate a Mandelbrot set fractal, and progressively zoom towards the
 +point specified with @var{start_x} and @var{start_y}.
  
 -The default value for @var{struct_el} is "3x3+0x0/rect".
 +This source accepts the following options:
  
 -@var{nb_iterations} specifies the number of times the transform is
 -applied to the image, and defaults to 1.
 +@table @option
  
 -Follow some example:
 +@item end_pts
 +Set the terminal pts value. Default value is 400.
 +
 +@item end_scale
 +Set the terminal scale value.
 +Must be a floating point value. Default value is 0.3.
 +
 +@item inner
 +Set the inner coloring mode, that is the algorithm used to draw the
 +Mandelbrot fractal internal region.
 +
 +It shall assume one of the following values:
 +@table @option
 +@item black
 +Set black mode.
 +@item convergence
 +Show time until convergence.
 +@item mincol
 +Set color based on point closest to the origin of the iterations.
 +@item period
 +Set period mode.
 +@end table
 +
 +Default value is @var{mincol}.
 +
 +@item bailout
 +Set the bailout value. Default value is 10.0.
 +
 +@item maxiter
 +Set the maximum of iterations performed by the rendering
 +algorithm. Default value is 7189.
 +
 +@item outer
 +Set outer coloring mode.
 +It shall assume one of following values:
 +@table @option
 +@item iteration_count
 +Set iteration cound mode.
 +@item normalized_iteration_count
 +set normalized iteration count mode.
 +@end table
 +Default value is @var{normalized_iteration_count}.
 +
 +@item rate, r
 +Set frame rate, expressed as number of frames per second. Default
 +value is "25".
 +
 +@item size, s
 +Set frame size. For the syntax of this option, check the "Video
 +size" section in the ffmpeg-utils manual. Default value is "640x480".
 +
 +@item start_scale
 +Set the initial scale value. Default value is 3.0.
 +
 +@item start_x
 +Set the initial x position. Must be a floating point value between
 +-100 and 100. Default value is -0.743643887037158704752191506114774.
 +
 +@item start_y
 +Set the initial y position. Must be a floating point value between
 +-100 and 100. Default value is -0.131825904205311970493132056385139.
 +@end table
 +
 +@section mptestsrc
 +
 +Generate various test patterns, as generated by the MPlayer test filter.
 +
 +The size of the generated video is fixed, and is 256x256.
 +This source is useful in particular for testing encoding features.
 +
 +This source accepts the following options:
 +
 +@table @option
 +
 +@item rate, r
 +Specify the frame rate of the sourced video, as the number of frames
 +generated per second. It has to be a string in the format
 +@var{frame_rate_num}/@var{frame_rate_den}, an integer number, a float
 +number or a valid video frame rate abbreviation. The default value is
 +"25".
 +
 +@item duration, d
 +Set the video duration of the sourced video. The accepted syntax is:
  @example
 -# use the default values
 -ocv=dilate
 +[-]HH:MM:SS[.m...]
 +[-]S+[.m...]
 +@end example
 +See also the function @code{av_parse_time()}.
  
 -# dilate using a structuring element with a 5x5 cross, iterate two times
 -ocv=filter_name=dilate:filter_params=5x5+2x2/cross|2
 +If not specified, or the expressed duration is negative, the video is
 +supposed to be generated forever.
  
 -# read the shape from the file diamond.shape, iterate two times
 -# the file diamond.shape may contain a pattern of characters like this:
 -#   *
 -#  ***
 -# *****
 -#  ***
 -#   *
 -# the specified cols and rows are ignored (but not the anchor point coordinates)
 -ocv=dilate:0x0+2x2/custom=diamond.shape|2
 +@item test, t
 +
 +Set the number or the name of the test to perform. Supported tests are:
 +@table @option
 +@item dc_luma
 +@item dc_chroma
 +@item freq_luma
 +@item freq_chroma
 +@item amp_luma
 +@item amp_chroma
 +@item cbp
 +@item mv
 +@item ring1
 +@item ring2
 +@item all
 +@end table
 +
 +Default value is "all", which will cycle through the list of all tests.
 +@end table
 +
 +For example the following:
 +@example
 +testsrc=t=dc_luma
  @end example
  
 -@subsection erode
 +will generate a "dc_luma" test pattern.
  
 -Erode an image by using a specific structuring element.
 -This filter corresponds to the libopencv function @code{cvErode}.
 +@section frei0r_src
  
 -The filter accepts the parameters: @var{struct_el}:@var{nb_iterations},
 -with the same syntax and semantics as the @ref{dilate} filter.
 +Provide a frei0r source.
  
 -@subsection smooth
 +To enable compilation of this filter you need to install the frei0r
 +header and configure FFmpeg with @code{--enable-frei0r}.
  
 -Smooth the input video.
 +This source accepts the following options:
  
 -The filter takes the following parameters:
 -@var{type}|@var{param1}|@var{param2}|@var{param3}|@var{param4}.
 +@table @option
  
 -@var{type} is the type of smooth filter to apply, and can be one of
 -the following values: "blur", "blur_no_scale", "median", "gaussian",
 -"bilateral". The default value is "gaussian".
 +@item size
 +The size of the video to generate. For the syntax of this option, check the
 +"Video size" section in the ffmpeg-utils manual.
  
 -@var{param1}, @var{param2}, @var{param3}, and @var{param4} are
 -parameters whose meanings depend on smooth type. @var{param1} and
 -@var{param2} accept integer positive values or 0, @var{param3} and
 -@var{param4} accept float values.
 +@item framerate
 +Framerate of the generated video, may be a string of the form
 +@var{num}/@var{den} or a frame rate abbreviation.
  
 -The default value for @var{param1} is 3, the default value for the
 -other parameters is 0.
 +@item filter_name
 +The name to the frei0r source to load. For more information regarding frei0r and
 +how to set the parameters read the section @ref{frei0r} in the description of
 +the video filters.
  
 -These parameters correspond to the parameters assigned to the
 -libopencv function @code{cvSmooth}.
 +@item filter_params
 +A '|'-separated list of parameters to pass to the frei0r source.
  
 -@anchor{overlay}
 -@section overlay
 +@end table
  
 -Overlay one video on top of another.
 +For example, to generate a frei0r partik0l source with size 200x200
 +and frame rate 10 which is overlayed on the overlay filter main input:
 +@example
 +frei0r_src=size=200x200:framerate=10:filter_name=partik0l:filter_params=1234 [overlay]; [in][overlay] overlay
 +@end example
  
 -It takes two inputs and one output, the first input is the "main"
 -video on which the second input is overlayed.
 +@section life
  
 -This filter accepts the following parameters:
 +Generate a life pattern.
 +
 +This source is based on a generalization of John Conway's life game.
 +
 +The sourced input represents a life grid, each pixel represents a cell
 +which can be in one of two possible states, alive or dead. Every cell
 +interacts with its eight neighbours, which are the cells that are
 +horizontally, vertically, or diagonally adjacent.
 +
 +At each interaction the grid evolves according to the adopted rule,
 +which specifies the number of neighbor alive cells which will make a
 +cell stay alive or born. The @option{rule} option allows to specify
 +the rule to adopt.
 +
 +This source accepts the following options:
  
  @table @option
 +@item filename, f
 +Set the file from which to read the initial grid state. In the file,
 +each non-whitespace character is considered an alive cell, and newline
 +is used to delimit the end of each row.
  
 -@item x
 -The horizontal position of the left edge of the overlaid video on the main video.
 +If this option is not specified, the initial grid is generated
 +randomly.
  
 -@item y
 -The vertical position of the top edge of the overlaid video on the main video.
 +@item rate, r
 +Set the video rate, that is the number of frames generated per second.
 +Default is 25.
 +
 +@item random_fill_ratio, ratio
 +Set the random fill ratio for the initial random grid. It is a
 +floating point number value ranging from 0 to 1, defaults to 1/PHI.
 +It is ignored when a file is specified.
 +
 +@item random_seed, seed
 +Set the seed for filling the initial random grid, must be an integer
 +included between 0 and UINT32_MAX. If not specified, or if explicitly
 +set to -1, the filter will try to use a good random seed on a best
 +effort basis.
 +
 +@item rule
 +Set the life rule.
 +
 +A rule can be specified with a code of the kind "S@var{NS}/B@var{NB}",
 +where @var{NS} and @var{NB} are sequences of numbers in the range 0-8,
 +@var{NS} specifies the number of alive neighbor cells which make a
 +live cell stay alive, and @var{NB} the number of alive neighbor cells
 +which make a dead cell to become alive (i.e. to "born").
 +"s" and "b" can be used in place of "S" and "B", respectively.
 +
 +Alternatively a rule can be specified by an 18-bits integer. The 9
 +high order bits are used to encode the next cell state if it is alive
 +for each number of neighbor alive cells, the low order bits specify
 +the rule for "borning" new cells. Higher order bits encode for an
 +higher number of neighbor cells.
 +For example the number 6153 = @code{(12<<9)+9} specifies a stay alive
 +rule of 12 and a born rule of 9, which corresponds to "S23/B03".
 +
 +Default value is "S23/B3", which is the original Conway's game of life
 +rule, and will keep a cell alive if it has 2 or 3 neighbor alive
 +cells, and will born a new cell if there are three alive cells around
 +a dead cell.
 +
 +@item size, s
 +Set the size of the output video. For the syntax of this option, check the
 +"Video size" section in the ffmpeg-utils manual.
 +
 +If @option{filename} is specified, the size is set by default to the
 +same size of the input file. If @option{size} is set, it must contain
 +the size specified in the input file, and the initial grid defined in
 +that file is centered in the larger resulting area.
 +
 +If a filename is not specified, the size value defaults to "320x240"
 +(used for a randomly generated initial grid).
 +
 +@item stitch
 +If set to 1, stitch the left and right grid edges together, and the
 +top and bottom edges also. Defaults to 1.
 +
 +@item mold
 +Set cell mold speed. If set, a dead cell will go from @option{death_color} to
 +@option{mold_color} with a step of @option{mold}. @option{mold} can have a
 +value from 0 to 255.
 +
 +@item life_color
 +Set the color of living (or new born) cells.
  
 +@item death_color
 +Set the color of dead cells. If @option{mold} is set, this is the first color
 +used to represent a dead cell.
 +
 +@item mold_color
 +Set mold color, for definitely dead and moldy cells.
 +
 +For the syntax of these 3 color options, check the "Color" section in the
 +ffmpeg-utils manual.
  @end table
  
 -The parameters are expressions containing the following parameters:
 +@subsection Examples
 +
 +@itemize
 +@item
 +Read a grid from @file{pattern}, and center it on a grid of size
 +300x300 pixels:
 +@example
 +life=f=pattern:s=300x300
 +@end example
 +
 +@item
 +Generate a random grid of size 200x200, with a fill ratio of 2/3:
 +@example
 +life=ratio=2/3:s=200x200
 +@end example
 +
 +@item
 +Specify a custom rule for evolving a randomly generated grid:
 +@example
 +life=rule=S14/B34
 +@end example
 +
 +@item
 +Full example with slow death effect (mold) using @command{ffplay}:
 +@example
 +ffplay -f lavfi life=s=300x200:mold=10:r=60:ratio=0.1:death_color=#C83232:life_color=#00ff00,scale=1200:800:flags=16
 +@end example
 +@end itemize
 +
 +@anchor{color}
 +@anchor{haldclutsrc}
 +@anchor{nullsrc}
 +@anchor{rgbtestsrc}
 +@anchor{smptebars}
 +@anchor{smptehdbars}
 +@anchor{testsrc}
 +@section color, haldclutsrc, nullsrc, rgbtestsrc, smptebars, smptehdbars, testsrc
 +
 +The @code{color} source provides an uniformly colored input.
 +
 +The @code{haldclutsrc} source provides an identity Hald CLUT. See also
 +@ref{haldclut} filter.
 +
 +The @code{nullsrc} source returns unprocessed video frames. It is
 +mainly useful to be employed in analysis / debugging tools, or as the
 +source for filters which ignore the input data.
 +
 +The @code{rgbtestsrc} source generates an RGB test pattern useful for
 +detecting RGB vs BGR issues. You should see a red, green and blue
 +stripe from top to bottom.
 +
 +The @code{smptebars} source generates a color bars pattern, based on
 +the SMPTE Engineering Guideline EG 1-1990.
 +
 +The @code{smptehdbars} source generates a color bars pattern, based on
 +the SMPTE RP 219-2002.
 +
 +The @code{testsrc} source generates a test video pattern, showing a
 +color pattern, a scrolling gradient and a timestamp. This is mainly
 +intended for testing purposes.
 +
 +The sources accept the following options:
  
  @table @option
 -@item main_w, main_h
 -main input width and height
  
 -@item W, H
 -same as @var{main_w} and @var{main_h}
 +@item color, c
 +Specify the color of the source, only available in the @code{color}
 +source. For the syntax of this option, check the "Color" section in the
 +ffmpeg-utils manual.
  
 -@item overlay_w, overlay_h
 -overlay input width and height
 +@item level
 +Specify the level of the Hald CLUT, only available in the @code{haldclutsrc}
 +source. A level of @code{N} generates a picture of @code{N*N*N} by @code{N*N*N}
 +pixels to be used as identity matrix for 3D lookup tables. Each component is
 +coded on a @code{1/(N*N)} scale.
  
 -@item w, h
 -same as @var{overlay_w} and @var{overlay_h}
 -@end table
 +@item size, s
 +Specify the size of the sourced video. For the syntax of this option, check the
 +"Video size" section in the ffmpeg-utils manual. The default value is
 +"320x240".
  
 -Be aware that frames are taken from each input video in timestamp
 -order, hence, if their initial timestamps differ, it is a a good idea
 -to pass the two inputs through a @var{setpts=PTS-STARTPTS} filter to
 -have them begin in the same zero timestamp, as it does the example for
 -the @var{movie} filter.
 +This option is not available with the @code{haldclutsrc} filter.
 +
 +@item rate, r
 +Specify the frame rate of the sourced video, as the number of frames
 +generated per second. It has to be a string in the format
 +@var{frame_rate_num}/@var{frame_rate_den}, an integer number, a float
 +number or a valid video frame rate abbreviation. The default value is
 +"25".
 +
 +@item sar
 +Set the sample aspect ratio of the sourced video.
  
 -Follow some examples:
 +@item duration, d
 +Set the video duration of the sourced video. The accepted syntax is:
  @example
 -# draw the overlay at 10 pixels from the bottom right
 -# corner of the main video.
 -overlay=x=main_w-overlay_w-10:y=main_h-overlay_h-10
 +[-]HH[:MM[:SS[.m...]]]
 +[-]S+[.m...]
 +@end example
 +See also the function @code{av_parse_time()}.
 +
 +If not specified, or the expressed duration is negative, the video is
 +supposed to be generated forever.
 +
 +@item decimals, n
 +Set the number of decimals to show in the timestamp, only available in the
 +@code{testsrc} source.
 +
 +The displayed timestamp value will correspond to the original
 +timestamp value multiplied by the power of 10 of the specified
 +value. Default value is 0.
 +@end table
 +
 +For example the following:
 +@example
 +testsrc=duration=5.3:size=qcif:rate=10
 +@end example
  
 -# insert a transparent PNG logo in the bottom left corner of the input
 -avconv -i input -i logo -filter_complex 'overlay=x=10:y=main_h-overlay_h-10' output
 +will generate a video with a duration of 5.3 seconds, with size
 +176x144 and a frame rate of 10 frames per second.
  
 -# insert 2 different transparent PNG logos (second logo on bottom
 -# right corner):
 -avconv -i input -i logo1 -i logo2 -filter_complex
 -'overlay=x=10:y=H-h-10,overlay=x=W-w-10:y=H-h-10' output
 +The following graph description will generate a red source
 +with an opacity of 0.2, with size "qcif" and a frame rate of 10
 +frames per second.
 +@example
 +color=c=red@@0.2:s=qcif:r=10
 +@end example
  
 -# add a transparent color layer on top of the main video,
 -# WxH specifies the size of the main input to the overlay filter
 -color=red@.3:WxH [over]; [in][over] overlay [out]
 +If the input content is to be ignored, @code{nullsrc} can be used. The
 +following command generates noise in the luminance plane by employing
 +the @code{geq} filter:
 +@example
 +nullsrc=s=256x256, geq=random(1)*255:128:128
  @end example
  
 -You can chain together more overlays but the efficiency of such
 -approach is yet to be tested.
 +@subsection Commands
 +
 +The @code{color} source supports the following commands:
 +
 +@table @option
 +@item c, color
 +Set the color of the created image. Accepts the same syntax of the
 +corresponding @option{color} option.
 +@end table
 +
 +@c man end VIDEO SOURCES
 +
 +@chapter Video Sinks
 +@c man begin VIDEO SINKS
 +
 +Below is a description of the currently available video sinks.
 +
 +@section buffersink
 +
 +Buffer video frames, and make them available to the end of the filter
 +graph.
 +
 +This sink is mainly intended for a programmatic use, in particular
 +through the interface defined in @file{libavfilter/buffersink.h}
 +or the options system.
 +
 +It accepts a pointer to an AVBufferSinkContext structure, which
 +defines the incoming buffers' formats, to be passed as the opaque
 +parameter to @code{avfilter_init_filter} for initialization.
  
 -@section pad
 +@section nullsink
  
 -Add paddings to the input image, and places the original input at the
 -given coordinates @var{x}, @var{y}.
 +Null video sink, do absolutely nothing with the input video. It is
 +mainly useful as a template and to be employed in analysis / debugging
 +tools.
  
 -This filter accepts the following parameters:
 +@c man end VIDEO SINKS
  
 -@table @option
 -@item width, height
 +@chapter Multimedia Filters
 +@c man begin MULTIMEDIA FILTERS
  
 -Specify the size of the output image with the paddings added. If the
 -value for @var{width} or @var{height} is 0, the corresponding input size
 -is used for the output.
 +Below is a description of the currently available multimedia filters.
  
 -The @var{width} expression can reference the value set by the
 -@var{height} expression, and vice versa.
 +@section avectorscope
  
 -The default value of @var{width} and @var{height} is 0.
 +Convert input audio to a video output, representing the audio vector
 +scope.
  
 -@item x, y
 +The filter is used to measure the difference between channels of stereo
 +audio stream. A monoaural signal, consisting of identical left and right
 +signal, results in straight vertical line. Any stereo separation is visible
 +as a deviation from this line, creating a Lissajous figure.
 +If the straight (or deviation from it) but horizontal line appears this
 +indicates that the left and right channels are out of phase.
  
 -Specify the offsets where to place the input image in the padded area
 -with respect to the top/left border of the output image.
 +The filter accepts the following options:
  
 -The @var{x} expression can reference the value set by the @var{y}
 -expression, and vice versa.
 +@table @option
 +@item mode, m
 +Set the vectorscope mode.
  
 -The default value of @var{x} and @var{y} is 0.
 +Available values are:
 +@table @samp
 +@item lissajous
 +Lissajous rotated by 45 degrees.
  
 -@item color
 +@item lissajous_xy
 +Same as above but not rotated.
 +@end table
  
 -Specify the color of the padded area, it can be the name of a color
 -(case insensitive match) or a 0xRRGGBB[AA] sequence.
 +Default value is @samp{lissajous}.
  
 -The default value of @var{color} is "black".
 +@item size, s
 +Set the video size for the output. For the syntax of this option, check the "Video size"
 +section in the ffmpeg-utils manual. Default value is @code{400x400}.
  
 +@item rate, r
 +Set the output frame rate. Default value is @code{25}.
 +
 +@item rc
 +@item gc
 +@item bc
 +Specify the red, green and blue contrast. Default values are @code{40}, @code{160} and @code{80}.
 +Allowed range is @code{[0, 255]}.
 +
 +@item rf
 +@item gf
 +@item bf
 +Specify the red, green and blue fade. Default values are @code{15}, @code{10} and @code{5}.
 +Allowed range is @code{[0, 255]}.
 +
 +@item zoom
 +Set the zoom factor. Default value is @code{1}. Allowed range is @code{[1, 10]}.
  @end table
  
 -The parameters @var{width}, @var{height}, @var{x}, and @var{y} are
 -expressions containing the following constants:
 +@subsection Examples
  
 -@table @option
 -@item E, PI, PHI
 -the corresponding mathematical approximated values for e
 -(euler number), pi (greek PI), phi (golden ratio)
 +@itemize
 +@item
 +Complete example using @command{ffplay}:
 +@example
 +ffplay -f lavfi 'amovie=input.mp3, asplit [a][out1];
 +             [a] avectorscope=zoom=1.3:rc=2:gc=200:bc=10:rf=1:gf=8:bf=7 [out0]'
 +@end example
 +@end itemize
  
 -@item in_w, in_h
 -the input video width and height
 +@section concat
  
 -@item iw, ih
 -same as @var{in_w} and @var{in_h}
 +Concatenate audio and video streams, joining them together one after the
 +other.
  
 -@item out_w, out_h
 -the output width and height, that is the size of the padded area as
 -specified by the @var{width} and @var{height} expressions
 +The filter works on segments of synchronized video and audio streams. All
 +segments must have the same number of streams of each type, and that will
 +also be the number of streams at output.
  
 -@item ow, oh
 -same as @var{out_w} and @var{out_h}
 +The filter accepts the following options:
  
 -@item x, y
 -x and y offsets as specified by the @var{x} and @var{y}
 -expressions, or NAN if not yet specified
 +@table @option
 +
 +@item n
 +Set the number of segments. Default is 2.
 +
 +@item v
 +Set the number of output video streams, that is also the number of video
 +streams in each segment. Default is 1.
  
  @item a
 -input display aspect ratio, same as @var{iw} / @var{ih}
 +Set the number of output audio streams, that is also the number of video
 +streams in each segment. Default is 0.
 +
 +@item unsafe
 +Activate unsafe mode: do not fail if segments have a different format.
  
 -@item hsub, vsub
 -horizontal and vertical chroma subsample values. For example for the
 -pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  @end table
  
 -Some examples follow:
 +The filter has @var{v}+@var{a} outputs: first @var{v} video outputs, then
 +@var{a} audio outputs.
  
 -@example
 -# Add paddings with color "violet" to the input video. Output video
 -# size is 640x480, the top-left corner of the input video is placed at
 -# column 0, row 40.
 -pad=width=640:height=480:x=0:y=40:color=violet
 +There are @var{n}x(@var{v}+@var{a}) inputs: first the inputs for the first
 +segment, in the same order as the outputs, then the inputs for the second
 +segment, etc.
  
 -# pad the input to get an output with dimensions increased bt 3/2,
 -# and put the input video at the center of the padded area
 -pad="3/2*iw:3/2*ih:(ow-iw)/2:(oh-ih)/2"
 +Related streams do not always have exactly the same duration, for various
 +reasons including codec frame size or sloppy authoring. For that reason,
 +related synchronized streams (e.g. a video and its audio track) should be
 +concatenated at once. The concat filter will use the duration of the longest
 +stream in each segment (except the last one), and if necessary pad shorter
 +audio streams with silence.
  
 -# pad the input to get a squared output with size equal to the maximum
 -# value between the input width and height, and put the input video at
 -# the center of the padded area
 -pad="max(iw\,ih):ow:(ow-iw)/2:(oh-ih)/2"
 +For this filter to work correctly, all segments must start at timestamp 0.
  
 -# pad the input to get a final w/h ratio of 16:9
 -pad="ih*16/9:ih:(ow-iw)/2:(oh-ih)/2"
 +All corresponding streams must have the same parameters in all segments; the
 +filtering system will automatically select a common pixel format for video
 +streams, and a common sample format, sample rate and channel layout for
 +audio streams, but other settings, such as resolution, must be converted
 +explicitly by the user.
  
 -# double output size and put the input video in the bottom-right
 -# corner of the output padded area
 -pad="2*iw:2*ih:ow-iw:oh-ih"
 -@end example
 +Different frame rates are acceptable but will result in variable frame rate
 +at output; be sure to configure the output file to handle it.
  
 -@section pixdesctest
 +@subsection Examples
  
 -Pixel format descriptor test filter, mainly useful for internal
 -testing. The output video should be equal to the input video.
 +@itemize
 +@item
 +Concatenate an opening, an episode and an ending, all in bilingual version
 +(video in stream 0, audio in streams 1 and 2):
 +@example
 +ffmpeg -i opening.mkv -i episode.mkv -i ending.mkv -filter_complex \
 +  '[0:0] [0:1] [0:2] [1:0] [1:1] [1:2] [2:0] [2:1] [2:2]
 +   concat=n=3:v=1:a=2 [v] [a1] [a2]' \
 +  -map '[v]' -map '[a1]' -map '[a2]' output.mkv
 +@end example
  
 -For example:
 +@item
 +Concatenate two parts, handling audio and video separately, using the
 +(a)movie sources, and adjusting the resolution:
  @example
 -format=monow, pixdesctest
 +movie=part1.mp4, scale=512:288 [v1] ; amovie=part1.mp4 [a1] ;
 +movie=part2.mp4, scale=512:288 [v2] ; amovie=part2.mp4 [a2] ;
 +[v1] [v2] concat [outv] ; [a1] [a2] concat=v=0:a=1 [outa]
  @end example
 +Note that a desync will happen at the stitch if the audio and video streams
 +do not have exactly the same duration in the first file.
  
 -can be used to test the monowhite pixel format descriptor definition.
 +@end itemize
  
 -@section scale
 +@section ebur128
  
 -Scale the input video and/or convert the image format.
 +EBU R128 scanner filter. This filter takes an audio stream as input and outputs
 +it unchanged. By default, it logs a message at a frequency of 10Hz with the
 +Momentary loudness (identified by @code{M}), Short-term loudness (@code{S}),
 +Integrated loudness (@code{I}) and Loudness Range (@code{LRA}).
  
 -This filter accepts the following options:
 +The filter also has a video output (see the @var{video} option) with a real
 +time graph to observe the loudness evolution. The graphic contains the logged
 +message mentioned above, so it is not printed anymore when this option is set,
 +unless the verbose logging is set. The main graphing area contains the
 +short-term loudness (3 seconds of analysis), and the gauge on the right is for
 +the momentary loudness (400 milliseconds).
 +
 +More information about the Loudness Recommendation EBU R128 on
 +@url{http://tech.ebu.ch/loudness}.
 +
 +The filter accepts the following options:
  
  @table @option
  
@@@ -39,43 -66,26 +66,35 @@@ typedef struct 
      const AVClass *class;
      AVRational dar;
      AVRational sar;
 +    int max;
  #if FF_API_OLD_FILTER_OPTS
 -    float aspect_num, aspect_den;
 +    float aspect_den;
  #endif
-     char *ratio_str;
+     char *ratio_expr;
  } AspectContext;
  
 -#if FF_API_OLD_FILTER_OPTS
  static av_cold int init(AVFilterContext *ctx)
  {
      AspectContext *s = ctx->priv;
 +    int ret;
  
 -    if (s->aspect_num > 0 && s->aspect_den > 0) {
 -        av_log(ctx, AV_LOG_WARNING, "This syntax is deprecated, use "
 -               "dar=<number> or dar=num/den.\n");
 -        s->sar = s->dar = av_d2q(s->aspect_num / s->aspect_den, INT_MAX);
 +#if FF_API_OLD_FILTER_OPTS
-     if (s->ratio_str && s->aspect_den > 0) {
++    if (s->ratio_expr && s->aspect_den > 0) {
 +        double num;
 +        av_log(ctx, AV_LOG_WARNING,
 +               "num:den syntax is deprecated, please use num/den or named options instead\n");
-         ret = av_expr_parse_and_eval(&num, s->ratio_str, NULL, NULL,
++        ret = av_expr_parse_and_eval(&num, s->ratio_expr, NULL, NULL,
 +                                     NULL, NULL, NULL, NULL, NULL, 0, ctx);
 +        if (ret < 0) {
-             av_log(ctx, AV_LOG_ERROR, "Unable to parse ratio numerator \"%s\"\n", s->ratio_str);
++            av_log(ctx, AV_LOG_ERROR, "Unable to parse ratio numerator \"%s\"\n", s->ratio_expr);
 +            return AVERROR(EINVAL);
 +        }
 +        s->sar = s->dar = av_d2q(num / s->aspect_den, s->max);
-     } else
- #endif
-     if (s->ratio_str) {
-         ret = av_parse_ratio(&s->sar, s->ratio_str, s->max, 0, ctx);
-         if (ret < 0 || s->sar.num < 0 || s->sar.den <= 0) {
-             av_log(ctx, AV_LOG_ERROR,
-                    "Invalid string '%s' for aspect ratio\n", s->ratio_str);
-             return AVERROR(EINVAL);
-         }
-         s->dar = s->sar;
      }
++#endif
      return 0;
  }
 -#endif
  
  static int filter_frame(AVFilterLink *link, AVFrame *frame)
  {
  }
  
  #define OFFSET(x) offsetof(AspectContext, x)
 -#define FLAGS AV_OPT_FLAG_VIDEO_PARAM
 +#define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
 +
 +static inline void compute_dar(AVRational *dar, AVRational sar, int w, int h)
 +{
 +    if (sar.num && sar.den) {
 +        av_reduce(&dar->num, &dar->den, sar.num * w, sar.den * h, INT_MAX);
 +    } else {
 +        av_reduce(&dar->num, &dar->den, w, h, INT_MAX);
 +    }
 +}
  
 -    if ((ret = av_expr_parse_and_eval(&res, s->ratio_expr,
+ static int get_aspect_ratio(AVFilterLink *inlink, AVRational *aspect_ratio)
+ {
+     AVFilterContext *ctx = inlink->dst;
+     AspectContext *s = inlink->dst->priv;
+     const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format);
+     double var_values[VARS_NB], res;
+     int ret;
+     var_values[VAR_PI]    = M_PI;
+     var_values[VAR_PHI]   = M_PHI;
+     var_values[VAR_E]     = M_E;
+     var_values[VAR_W]     = inlink->w;
+     var_values[VAR_H]     = inlink->h;
+     var_values[VAR_A]     = (double) inlink->w / inlink->h;
+     var_values[VAR_SAR]   = inlink->sample_aspect_ratio.num ?
+         (double) inlink->sample_aspect_ratio.num / inlink->sample_aspect_ratio.den : 1;
+     var_values[VAR_DAR]   = var_values[VAR_A] * var_values[VAR_SAR];
+     var_values[VAR_HSUB]  = 1 << desc->log2_chroma_w;
+     var_values[VAR_VSUB]  = 1 << desc->log2_chroma_h;
+     /* evaluate new aspect ratio*/
 -                                      NULL, NULL, NULL, NULL, NULL, 0, ctx)) < 0) {
 -        av_log(NULL, AV_LOG_ERROR,
++    ret = av_expr_parse_and_eval(&res, s->ratio_expr,
+                                       var_names, var_values,
 -    *aspect_ratio = av_d2q(res, INT_MAX);
++                                      NULL, NULL, NULL, NULL, NULL, 0, ctx);
++    if (ret < 0) {
++        ret = av_parse_ratio(aspect_ratio, s->ratio_expr, s->max, 0, ctx);
++    } else
++        *aspect_ratio = av_d2q(res, s->max);
++
++    if (ret < 0) {
++        av_log(ctx, AV_LOG_ERROR,
+                "Error when evaluating the expression '%s'\n", s->ratio_expr);
+         return ret;
+     }
++    if (aspect_ratio->num < 0 || aspect_ratio->den <= 0) {
++        av_log(ctx, AV_LOG_ERROR,
++                "Invalid string '%s' for aspect ratio\n", s->ratio_expr);
++        return AVERROR(EINVAL);
++    }
+     return 0;
+ }
  #if CONFIG_SETDAR_FILTER
 -/* for setdar filter, convert from frame aspect ratio to pixel aspect ratio */
 +
  static int setdar_config_props(AVFilterLink *inlink)
  {
      AspectContext *s = inlink->dst->priv;
      AVRational dar;
 -    if (!(s->aspect_num > 0 && s->aspect_den > 0)) {
 +    AVRational old_dar;
 +    AVRational old_sar = inlink->sample_aspect_ratio;
+     int ret;
+ #if FF_API_OLD_FILTER_OPTS
++    if (!(s->ratio_expr && s->aspect_den > 0)) {
+ #endif
+     if ((ret = get_aspect_ratio(inlink, &s->dar)))
+         return ret;
+ #if FF_API_OLD_FILTER_OPTS
+     }
+ #endif
  
      if (s->dar.num && s->dar.den) {
          av_reduce(&s->sar.num, &s->sar.den,
  }
  
  static const AVOption setdar_options[] = {
-     { "dar",   "set display aspect ratio", OFFSET(ratio_str), AV_OPT_TYPE_STRING, {.str="0"}, .flags=FLAGS },
-     { "ratio", "set display aspect ratio", OFFSET(ratio_str), AV_OPT_TYPE_STRING, {.str="0"}, .flags=FLAGS },
-     { "r",     "set display aspect ratio", OFFSET(ratio_str), AV_OPT_TYPE_STRING, {.str="0"}, .flags=FLAGS },
++    { "dar",   "set display aspect ratio", OFFSET(ratio_expr), AV_OPT_TYPE_STRING, { .str = "0" }, .flags = FLAGS },
++    { "ratio", "set display aspect ratio", OFFSET(ratio_expr), AV_OPT_TYPE_STRING, { .str = "0" }, .flags = FLAGS },
++    { "r",     "set display aspect ratio", OFFSET(ratio_expr), AV_OPT_TYPE_STRING, { .str = "0" }, .flags = FLAGS },
  #if FF_API_OLD_FILTER_OPTS
 -    { "dar_num", NULL, OFFSET(aspect_num), AV_OPT_TYPE_FLOAT, { .dbl = 0 }, 0, FLT_MAX, FLAGS },
      { "dar_den", NULL, OFFSET(aspect_den), AV_OPT_TYPE_FLOAT, { .dbl = 0 }, 0, FLT_MAX, FLAGS },
  #endif
 -    { "dar", "display aspect ratio", OFFSET(ratio_expr), AV_OPT_TYPE_STRING, { .str = "1" }, .flags = FLAGS },
 -    { NULL },
 +    { "max",   "set max value for nominator or denominator in the ratio", OFFSET(max), AV_OPT_TYPE_INT, {.i64=100}, 1, INT_MAX, FLAGS },
 +    { NULL }
  };
  
 -static const AVClass setdar_class = {
 -    .class_name = "setdar",
 -    .item_name  = av_default_item_name,
 -    .option     = setdar_options,
 -    .version    = LIBAVUTIL_VERSION_INT,
 -};
 +AVFILTER_DEFINE_CLASS(setdar);
  
  static const AVFilterPad avfilter_vf_setdar_inputs[] = {
      {
@@@ -173,8 -222,16 +244,18 @@@ AVFilter ff_vf_setdar = 
  static int setsar_config_props(AVFilterLink *inlink)
  {
      AspectContext *s = inlink->dst->priv;
 -    if (!(s->aspect_num > 0 && s->aspect_den > 0)) {
 +    AVRational old_sar = inlink->sample_aspect_ratio;
 +    AVRational old_dar, dar;
+     int ret;
+ #if FF_API_OLD_FILTER_OPTS
++    if (!(s->ratio_expr && s->aspect_den > 0)) {
+ #endif
+     if ((ret = get_aspect_ratio(inlink, &s->sar)))
+         return ret;
+ #if FF_API_OLD_FILTER_OPTS
+     }
+ #endif
  
      inlink->sample_aspect_ratio = s->sar;
  
  }
  
  static const AVOption setsar_options[] = {
-     { "sar",   "set sample (pixel) aspect ratio", OFFSET(ratio_str), AV_OPT_TYPE_STRING, {.str="0"}, .flags=FLAGS },
-     { "ratio", "set sample (pixel) aspect ratio", OFFSET(ratio_str), AV_OPT_TYPE_STRING, {.str="0"}, .flags=FLAGS },
-     { "r",     "set sample (pixel) aspect ratio", OFFSET(ratio_str), AV_OPT_TYPE_STRING, {.str="0"}, .flags=FLAGS },
++    { "sar",   "set sample (pixel) aspect ratio", OFFSET(ratio_expr), AV_OPT_TYPE_STRING, { .str = "0" }, .flags = FLAGS },
++    { "ratio", "set sample (pixel) aspect ratio", OFFSET(ratio_expr), AV_OPT_TYPE_STRING, { .str = "0" }, .flags = FLAGS },
++    { "r",     "set sample (pixel) aspect ratio", OFFSET(ratio_expr), AV_OPT_TYPE_STRING, { .str = "0" }, .flags = FLAGS },
  #if FF_API_OLD_FILTER_OPTS
 -    { "sar_num", NULL, OFFSET(aspect_num), AV_OPT_TYPE_FLOAT, { .dbl = 0 }, 0, FLT_MAX, FLAGS },
      { "sar_den", NULL, OFFSET(aspect_den), AV_OPT_TYPE_FLOAT, { .dbl = 0 }, 0, FLT_MAX, FLAGS },
  #endif
 -    { "sar", "sample (pixel) aspect ratio", OFFSET(ratio_expr), AV_OPT_TYPE_STRING, { .str = "1" }, .flags = FLAGS },
 -    { NULL },
 +    { "max",   "set max value for nominator or denominator in the ratio", OFFSET(max), AV_OPT_TYPE_INT, {.i64=100}, 1, INT_MAX, FLAGS },
 +    { NULL }
  };
  
 -static const AVClass setsar_class = {
 -    .class_name = "setsar",
 -    .item_name  = av_default_item_name,
 -    .option     = setsar_options,
 -    .version    = LIBAVUTIL_VERSION_INT,
 -};
 +AVFILTER_DEFINE_CLASS(setsar);
  
  static const AVFilterPad avfilter_vf_setsar_inputs[] = {
      {