You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2181 lines
61KB

  1. @chapter Filtergraph description
  2. @c man begin FILTERGRAPH DESCRIPTION
  3. A filtergraph is a directed graph of connected filters. It can contain
  4. cycles, and there can be multiple links between a pair of
  5. filters. Each link has one input pad on one side connecting it to one
  6. filter from which it takes its input, and one output pad on the other
  7. side connecting it to the one filter accepting its output.
  8. Each filter in a filtergraph is an instance of a filter class
  9. registered in the application, which defines the features and the
  10. number of input and output pads of the filter.
  11. A filter with no input pads is called a "source", a filter with no
  12. output pads is called a "sink".
  13. @anchor{Filtergraph syntax}
  14. @section Filtergraph syntax
  15. A filtergraph can be represented using a textual representation, which is
  16. recognized by the @option{-filter}/@option{-vf} and @option{-filter_complex}
  17. options in @command{avconv} and @option{-vf} in @command{avplay}, and by the
  18. @code{avfilter_graph_parse()}/@code{avfilter_graph_parse2()} function defined in
  19. @file{libavfilter/avfiltergraph.h}.
  20. A filterchain consists of a sequence of connected filters, each one
  21. connected to the previous one in the sequence. A filterchain is
  22. represented by a list of ","-separated filter descriptions.
  23. A filtergraph consists of a sequence of filterchains. A sequence of
  24. filterchains is represented by a list of ";"-separated filterchain
  25. descriptions.
  26. A filter is represented by a string of the form:
  27. [@var{in_link_1}]...[@var{in_link_N}]@var{filter_name}=@var{arguments}[@var{out_link_1}]...[@var{out_link_M}]
  28. @var{filter_name} is the name of the filter class of which the
  29. described filter is an instance of, and has to be the name of one of
  30. the filter classes registered in the program.
  31. The name of the filter class is optionally followed by a string
  32. "=@var{arguments}".
  33. @var{arguments} is a string which contains the parameters used to
  34. initialize the filter instance, and are described in the filter
  35. descriptions below.
  36. The list of arguments can be quoted using the character "'" as initial
  37. and ending mark, and the character '\' for escaping the characters
  38. within the quoted text; otherwise the argument string is considered
  39. terminated when the next special character (belonging to the set
  40. "[]=;,") is encountered.
  41. The name and arguments of the filter are optionally preceded and
  42. followed by a list of link labels.
  43. A link label allows to name a link and associate it to a filter output
  44. or input pad. The preceding labels @var{in_link_1}
  45. ... @var{in_link_N}, are associated to the filter input pads,
  46. the following labels @var{out_link_1} ... @var{out_link_M}, are
  47. associated to the output pads.
  48. When two link labels with the same name are found in the
  49. filtergraph, a link between the corresponding input and output pad is
  50. created.
  51. If an output pad is not labelled, it is linked by default to the first
  52. unlabelled input pad of the next filter in the filterchain.
  53. For example in the filterchain:
  54. @example
  55. nullsrc, split[L1], [L2]overlay, nullsink
  56. @end example
  57. the split filter instance has two output pads, and the overlay filter
  58. instance two input pads. The first output pad of split is labelled
  59. "L1", the first input pad of overlay is labelled "L2", and the second
  60. output pad of split is linked to the second input pad of overlay,
  61. which are both unlabelled.
  62. In a complete filterchain all the unlabelled filter input and output
  63. pads must be connected. A filtergraph is considered valid if all the
  64. filter input and output pads of all the filterchains are connected.
  65. Libavfilter will automatically insert scale filters where format
  66. conversion is required. It is possible to specify swscale flags
  67. for those automatically inserted scalers by prepending
  68. @code{sws_flags=@var{flags};}
  69. to the filtergraph description.
  70. Follows a BNF description for the filtergraph syntax:
  71. @example
  72. @var{NAME} ::= sequence of alphanumeric characters and '_'
  73. @var{LINKLABEL} ::= "[" @var{NAME} "]"
  74. @var{LINKLABELS} ::= @var{LINKLABEL} [@var{LINKLABELS}]
  75. @var{FILTER_ARGUMENTS} ::= sequence of chars (eventually quoted)
  76. @var{FILTER} ::= [@var{LINKNAMES}] @var{NAME} ["=" @var{ARGUMENTS}] [@var{LINKNAMES}]
  77. @var{FILTERCHAIN} ::= @var{FILTER} [,@var{FILTERCHAIN}]
  78. @var{FILTERGRAPH} ::= [sws_flags=@var{flags};] @var{FILTERCHAIN} [;@var{FILTERGRAPH}]
  79. @end example
  80. @c man end FILTERGRAPH DESCRIPTION
  81. @chapter Audio Filters
  82. @c man begin AUDIO FILTERS
  83. When you configure your Libav build, you can disable any of the
  84. existing filters using --disable-filters.
  85. The configure output will show the audio filters included in your
  86. build.
  87. Below is a description of the currently available audio filters.
  88. @section aformat
  89. Convert the input audio to one of the specified formats. The framework will
  90. negotiate the most appropriate format to minimize conversions.
  91. The filter accepts the following named parameters:
  92. @table @option
  93. @item sample_fmts
  94. A comma-separated list of requested sample formats.
  95. @item sample_rates
  96. A comma-separated list of requested sample rates.
  97. @item channel_layouts
  98. A comma-separated list of requested channel layouts.
  99. @end table
  100. If a parameter is omitted, all values are allowed.
  101. For example to force the output to either unsigned 8-bit or signed 16-bit stereo:
  102. @example
  103. aformat=sample_fmts\=u8\,s16:channel_layouts\=stereo
  104. @end example
  105. @section anull
  106. Pass the audio source unchanged to the output.
  107. @section asyncts
  108. Synchronize audio data with timestamps by squeezing/stretching it and/or
  109. dropping samples/adding silence when needed.
  110. The filter accepts the following named parameters:
  111. @table @option
  112. @item compensate
  113. Enable stretching/squeezing the data to make it match the timestamps.
  114. @item min_delta
  115. Minimum difference between timestamps and audio data (in seconds) to trigger
  116. adding/dropping samples.
  117. @item max_comp
  118. Maximum compensation in samples per second.
  119. @end table
  120. @section resample
  121. Convert the audio sample format, sample rate and channel layout. This filter is
  122. not meant to be used directly, it is inserted automatically by libavfilter
  123. whenever conversion is needed. Use the @var{aformat} filter to force a specific
  124. conversion.
  125. @c man end AUDIO FILTERS
  126. @chapter Audio Sources
  127. @c man begin AUDIO SOURCES
  128. Below is a description of the currently available audio sources.
  129. @section anullsrc
  130. Null audio source, never return audio frames. It is mainly useful as a
  131. template and to be employed in analysis / debugging tools.
  132. It accepts as optional parameter a string of the form
  133. @var{sample_rate}:@var{channel_layout}.
  134. @var{sample_rate} specify the sample rate, and defaults to 44100.
  135. @var{channel_layout} specify the channel layout, and can be either an
  136. integer or a string representing a channel layout. The default value
  137. of @var{channel_layout} is 3, which corresponds to CH_LAYOUT_STEREO.
  138. Check the channel_layout_map definition in
  139. @file{libavcodec/audioconvert.c} for the mapping between strings and
  140. channel layout values.
  141. Follow some examples:
  142. @example
  143. # set the sample rate to 48000 Hz and the channel layout to CH_LAYOUT_MONO.
  144. anullsrc=48000:4
  145. # same as
  146. anullsrc=48000:mono
  147. @end example
  148. @section abuffer
  149. Buffer audio frames, and make them available to the filter chain.
  150. This source is not intended to be part of user-supplied graph descriptions but
  151. for insertion by calling programs through the interface defined in
  152. @file{libavfilter/buffersrc.h}.
  153. It accepts the following named parameters:
  154. @table @option
  155. @item time_base
  156. Timebase which will be used for timestamps of submitted frames. It must be
  157. either a floating-point number or in @var{numerator}/@var{denominator} form.
  158. @item sample_rate
  159. Audio sample rate.
  160. @item sample_fmt
  161. Name of the sample format, as returned by @code{av_get_sample_fmt_name()}.
  162. @item channel_layout
  163. Channel layout of the audio data, in the form that can be accepted by
  164. @code{av_get_channel_layout()}.
  165. @end table
  166. All the parameters need to be explicitly defined.
  167. @c man end AUDIO SOURCES
  168. @chapter Audio Sinks
  169. @c man begin AUDIO SINKS
  170. Below is a description of the currently available audio sinks.
  171. @section anullsink
  172. Null audio sink, do absolutely nothing with the input audio. It is
  173. mainly useful as a template and to be employed in analysis / debugging
  174. tools.
  175. @section abuffersink
  176. This sink is intended for programmatic use. Frames that arrive on this sink can
  177. be retrieved by the calling program using the interface defined in
  178. @file{libavfilter/buffersink.h}.
  179. This filter accepts no parameters.
  180. @c man end AUDIO SINKS
  181. @chapter Video Filters
  182. @c man begin VIDEO FILTERS
  183. When you configure your Libav build, you can disable any of the
  184. existing filters using --disable-filters.
  185. The configure output will show the video filters included in your
  186. build.
  187. Below is a description of the currently available video filters.
  188. @section blackframe
  189. Detect frames that are (almost) completely black. Can be useful to
  190. detect chapter transitions or commercials. Output lines consist of
  191. the frame number of the detected frame, the percentage of blackness,
  192. the position in the file if known or -1 and the timestamp in seconds.
  193. In order to display the output lines, you need to set the loglevel at
  194. least to the AV_LOG_INFO value.
  195. The filter accepts the syntax:
  196. @example
  197. blackframe[=@var{amount}:[@var{threshold}]]
  198. @end example
  199. @var{amount} is the percentage of the pixels that have to be below the
  200. threshold, and defaults to 98.
  201. @var{threshold} is the threshold below which a pixel value is
  202. considered black, and defaults to 32.
  203. @section boxblur
  204. Apply boxblur algorithm to the input video.
  205. This filter accepts the parameters:
  206. @var{luma_power}:@var{luma_radius}:@var{chroma_radius}:@var{chroma_power}:@var{alpha_radius}:@var{alpha_power}
  207. Chroma and alpha parameters are optional, if not specified they default
  208. to the corresponding values set for @var{luma_radius} and
  209. @var{luma_power}.
  210. @var{luma_radius}, @var{chroma_radius}, and @var{alpha_radius} represent
  211. the radius in pixels of the box used for blurring the corresponding
  212. input plane. They are expressions, and can contain the following
  213. constants:
  214. @table @option
  215. @item w, h
  216. the input width and height in pixels
  217. @item cw, ch
  218. the input chroma image width and height in pixels
  219. @item hsub, vsub
  220. horizontal and vertical chroma subsample values. For example for the
  221. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  222. @end table
  223. The radius must be a non-negative number, and must not be greater than
  224. the value of the expression @code{min(w,h)/2} for the luma and alpha planes,
  225. and of @code{min(cw,ch)/2} for the chroma planes.
  226. @var{luma_power}, @var{chroma_power}, and @var{alpha_power} represent
  227. how many times the boxblur filter is applied to the corresponding
  228. plane.
  229. Some examples follow:
  230. @itemize
  231. @item
  232. Apply a boxblur filter with luma, chroma, and alpha radius
  233. set to 2:
  234. @example
  235. boxblur=2:1
  236. @end example
  237. @item
  238. Set luma radius to 2, alpha and chroma radius to 0
  239. @example
  240. boxblur=2:1:0:0:0:0
  241. @end example
  242. @item
  243. Set luma and chroma radius to a fraction of the video dimension
  244. @example
  245. boxblur=min(h\,w)/10:1:min(cw\,ch)/10:1
  246. @end example
  247. @end itemize
  248. @section copy
  249. Copy the input source unchanged to the output. Mainly useful for
  250. testing purposes.
  251. @section crop
  252. Crop the input video to @var{out_w}:@var{out_h}:@var{x}:@var{y}.
  253. The parameters are expressions containing the following constants:
  254. @table @option
  255. @item E, PI, PHI
  256. the corresponding mathematical approximated values for e
  257. (euler number), pi (greek PI), PHI (golden ratio)
  258. @item x, y
  259. the computed values for @var{x} and @var{y}. They are evaluated for
  260. each new frame.
  261. @item in_w, in_h
  262. the input width and height
  263. @item iw, ih
  264. same as @var{in_w} and @var{in_h}
  265. @item out_w, out_h
  266. the output (cropped) width and height
  267. @item ow, oh
  268. same as @var{out_w} and @var{out_h}
  269. @item n
  270. the number of input frame, starting from 0
  271. @item pos
  272. the position in the file of the input frame, NAN if unknown
  273. @item t
  274. timestamp expressed in seconds, NAN if the input timestamp is unknown
  275. @end table
  276. The @var{out_w} and @var{out_h} parameters specify the expressions for
  277. the width and height of the output (cropped) video. They are
  278. evaluated just at the configuration of the filter.
  279. The default value of @var{out_w} is "in_w", and the default value of
  280. @var{out_h} is "in_h".
  281. The expression for @var{out_w} may depend on the value of @var{out_h},
  282. and the expression for @var{out_h} may depend on @var{out_w}, but they
  283. cannot depend on @var{x} and @var{y}, as @var{x} and @var{y} are
  284. evaluated after @var{out_w} and @var{out_h}.
  285. The @var{x} and @var{y} parameters specify the expressions for the
  286. position of the top-left corner of the output (non-cropped) area. They
  287. are evaluated for each frame. If the evaluated value is not valid, it
  288. is approximated to the nearest valid value.
  289. The default value of @var{x} is "(in_w-out_w)/2", and the default
  290. value for @var{y} is "(in_h-out_h)/2", which set the cropped area at
  291. the center of the input image.
  292. The expression for @var{x} may depend on @var{y}, and the expression
  293. for @var{y} may depend on @var{x}.
  294. Follow some examples:
  295. @example
  296. # crop the central input area with size 100x100
  297. crop=100:100
  298. # crop the central input area with size 2/3 of the input video
  299. "crop=2/3*in_w:2/3*in_h"
  300. # crop the input video central square
  301. crop=in_h
  302. # delimit the rectangle with the top-left corner placed at position
  303. # 100:100 and the right-bottom corner corresponding to the right-bottom
  304. # corner of the input image.
  305. crop=in_w-100:in_h-100:100:100
  306. # crop 10 pixels from the left and right borders, and 20 pixels from
  307. # the top and bottom borders
  308. "crop=in_w-2*10:in_h-2*20"
  309. # keep only the bottom right quarter of the input image
  310. "crop=in_w/2:in_h/2:in_w/2:in_h/2"
  311. # crop height for getting Greek harmony
  312. "crop=in_w:1/PHI*in_w"
  313. # trembling effect
  314. "crop=in_w/2:in_h/2:(in_w-out_w)/2+((in_w-out_w)/2)*sin(n/10):(in_h-out_h)/2 +((in_h-out_h)/2)*sin(n/7)"
  315. # erratic camera effect depending on timestamp
  316. "crop=in_w/2:in_h/2:(in_w-out_w)/2+((in_w-out_w)/2)*sin(t*10):(in_h-out_h)/2 +((in_h-out_h)/2)*sin(t*13)"
  317. # set x depending on the value of y
  318. "crop=in_w/2:in_h/2:y:10+10*sin(n/10)"
  319. @end example
  320. @section cropdetect
  321. Auto-detect crop size.
  322. Calculate necessary cropping parameters and prints the recommended
  323. parameters through the logging system. The detected dimensions
  324. correspond to the non-black area of the input video.
  325. It accepts the syntax:
  326. @example
  327. cropdetect[=@var{limit}[:@var{round}[:@var{reset}]]]
  328. @end example
  329. @table @option
  330. @item limit
  331. Threshold, which can be optionally specified from nothing (0) to
  332. everything (255), defaults to 24.
  333. @item round
  334. Value which the width/height should be divisible by, defaults to
  335. 16. The offset is automatically adjusted to center the video. Use 2 to
  336. get only even dimensions (needed for 4:2:2 video). 16 is best when
  337. encoding to most video codecs.
  338. @item reset
  339. Counter that determines after how many frames cropdetect will reset
  340. the previously detected largest video area and start over to detect
  341. the current optimal crop area. Defaults to 0.
  342. This can be useful when channel logos distort the video area. 0
  343. indicates never reset and return the largest area encountered during
  344. playback.
  345. @end table
  346. @section delogo
  347. Suppress a TV station logo by a simple interpolation of the surrounding
  348. pixels. Just set a rectangle covering the logo and watch it disappear
  349. (and sometimes something even uglier appear - your mileage may vary).
  350. The filter accepts parameters as a string of the form
  351. "@var{x}:@var{y}:@var{w}:@var{h}:@var{band}", or as a list of
  352. @var{key}=@var{value} pairs, separated by ":".
  353. The description of the accepted parameters follows.
  354. @table @option
  355. @item x, y
  356. Specify the top left corner coordinates of the logo. They must be
  357. specified.
  358. @item w, h
  359. Specify the width and height of the logo to clear. They must be
  360. specified.
  361. @item band, t
  362. Specify the thickness of the fuzzy edge of the rectangle (added to
  363. @var{w} and @var{h}). The default value is 4.
  364. @item show
  365. When set to 1, a green rectangle is drawn on the screen to simplify
  366. finding the right @var{x}, @var{y}, @var{w}, @var{h} parameters, and
  367. @var{band} is set to 4. The default value is 0.
  368. @end table
  369. Some examples follow.
  370. @itemize
  371. @item
  372. Set a rectangle covering the area with top left corner coordinates 0,0
  373. and size 100x77, setting a band of size 10:
  374. @example
  375. delogo=0:0:100:77:10
  376. @end example
  377. @item
  378. As the previous example, but use named options:
  379. @example
  380. delogo=x=0:y=0:w=100:h=77:band=10
  381. @end example
  382. @end itemize
  383. @section drawbox
  384. Draw a colored box on the input image.
  385. It accepts the syntax:
  386. @example
  387. drawbox=@var{x}:@var{y}:@var{width}:@var{height}:@var{color}
  388. @end example
  389. @table @option
  390. @item x, y
  391. Specify the top left corner coordinates of the box. Default to 0.
  392. @item width, height
  393. Specify the width and height of the box, if 0 they are interpreted as
  394. the input width and height. Default to 0.
  395. @item color
  396. Specify the color of the box to write, it can be the name of a color
  397. (case insensitive match) or a 0xRRGGBB[AA] sequence.
  398. @end table
  399. Follow some examples:
  400. @example
  401. # draw a black box around the edge of the input image
  402. drawbox
  403. # draw a box with color red and an opacity of 50%
  404. drawbox=10:20:200:60:red@@0.5"
  405. @end example
  406. @section drawtext
  407. Draw text string or text from specified file on top of video using the
  408. libfreetype library.
  409. To enable compilation of this filter you need to configure Libav with
  410. @code{--enable-libfreetype}.
  411. The filter also recognizes strftime() sequences in the provided text
  412. and expands them accordingly. Check the documentation of strftime().
  413. The filter accepts parameters as a list of @var{key}=@var{value} pairs,
  414. separated by ":".
  415. The description of the accepted parameters follows.
  416. @table @option
  417. @item fontfile
  418. The font file to be used for drawing text. Path must be included.
  419. This parameter is mandatory.
  420. @item text
  421. The text string to be drawn. The text must be a sequence of UTF-8
  422. encoded characters.
  423. This parameter is mandatory if no file is specified with the parameter
  424. @var{textfile}.
  425. @item textfile
  426. A text file containing text to be drawn. The text must be a sequence
  427. of UTF-8 encoded characters.
  428. This parameter is mandatory if no text string is specified with the
  429. parameter @var{text}.
  430. If both text and textfile are specified, an error is thrown.
  431. @item x, y
  432. The offsets where text will be drawn within the video frame.
  433. Relative to the top/left border of the output image.
  434. They accept expressions similar to the @ref{overlay} filter:
  435. @table @option
  436. @item x, y
  437. the computed values for @var{x} and @var{y}. They are evaluated for
  438. each new frame.
  439. @item main_w, main_h
  440. main input width and height
  441. @item W, H
  442. same as @var{main_w} and @var{main_h}
  443. @item text_w, text_h
  444. rendered text width and height
  445. @item w, h
  446. same as @var{text_w} and @var{text_h}
  447. @item n
  448. the number of frames processed, starting from 0
  449. @item t
  450. timestamp expressed in seconds, NAN if the input timestamp is unknown
  451. @end table
  452. The default value of @var{x} and @var{y} is 0.
  453. @item fontsize
  454. The font size to be used for drawing text.
  455. The default value of @var{fontsize} is 16.
  456. @item fontcolor
  457. The color to be used for drawing fonts.
  458. Either a string (e.g. "red") or in 0xRRGGBB[AA] format
  459. (e.g. "0xff000033"), possibly followed by an alpha specifier.
  460. The default value of @var{fontcolor} is "black".
  461. @item boxcolor
  462. The color to be used for drawing box around text.
  463. Either a string (e.g. "yellow") or in 0xRRGGBB[AA] format
  464. (e.g. "0xff00ff"), possibly followed by an alpha specifier.
  465. The default value of @var{boxcolor} is "white".
  466. @item box
  467. Used to draw a box around text using background color.
  468. Value should be either 1 (enable) or 0 (disable).
  469. The default value of @var{box} is 0.
  470. @item shadowx, shadowy
  471. The x and y offsets for the text shadow position with respect to the
  472. position of the text. They can be either positive or negative
  473. values. Default value for both is "0".
  474. @item shadowcolor
  475. The color to be used for drawing a shadow behind the drawn text. It
  476. can be a color name (e.g. "yellow") or a string in the 0xRRGGBB[AA]
  477. form (e.g. "0xff00ff"), possibly followed by an alpha specifier.
  478. The default value of @var{shadowcolor} is "black".
  479. @item ft_load_flags
  480. Flags to be used for loading the fonts.
  481. The flags map the corresponding flags supported by libfreetype, and are
  482. a combination of the following values:
  483. @table @var
  484. @item default
  485. @item no_scale
  486. @item no_hinting
  487. @item render
  488. @item no_bitmap
  489. @item vertical_layout
  490. @item force_autohint
  491. @item crop_bitmap
  492. @item pedantic
  493. @item ignore_global_advance_width
  494. @item no_recurse
  495. @item ignore_transform
  496. @item monochrome
  497. @item linear_design
  498. @item no_autohint
  499. @item end table
  500. @end table
  501. Default value is "render".
  502. For more information consult the documentation for the FT_LOAD_*
  503. libfreetype flags.
  504. @item tabsize
  505. The size in number of spaces to use for rendering the tab.
  506. Default value is 4.
  507. @item fix_bounds
  508. If true, check and fix text coords to avoid clipping.
  509. @end table
  510. For example the command:
  511. @example
  512. drawtext="fontfile=/usr/share/fonts/truetype/freefont/FreeSerif.ttf: text='Test Text'"
  513. @end example
  514. will draw "Test Text" with font FreeSerif, using the default values
  515. for the optional parameters.
  516. The command:
  517. @example
  518. drawtext="fontfile=/usr/share/fonts/truetype/freefont/FreeSerif.ttf: text='Test Text':\
  519. x=100: y=50: fontsize=24: fontcolor=yellow@@0.2: box=1: boxcolor=red@@0.2"
  520. @end example
  521. will draw 'Test Text' with font FreeSerif of size 24 at position x=100
  522. and y=50 (counting from the top-left corner of the screen), text is
  523. yellow with a red box around it. Both the text and the box have an
  524. opacity of 20%.
  525. Note that the double quotes are not necessary if spaces are not used
  526. within the parameter list.
  527. For more information about libfreetype, check:
  528. @url{http://www.freetype.org/}.
  529. @section fade
  530. Apply fade-in/out effect to input video.
  531. It accepts the parameters:
  532. @var{type}:@var{start_frame}:@var{nb_frames}
  533. @var{type} specifies if the effect type, can be either "in" for
  534. fade-in, or "out" for a fade-out effect.
  535. @var{start_frame} specifies the number of the start frame for starting
  536. to apply the fade effect.
  537. @var{nb_frames} specifies the number of frames for which the fade
  538. effect has to last. At the end of the fade-in effect the output video
  539. will have the same intensity as the input video, at the end of the
  540. fade-out transition the output video will be completely black.
  541. A few usage examples follow, usable too as test scenarios.
  542. @example
  543. # fade in first 30 frames of video
  544. fade=in:0:30
  545. # fade out last 45 frames of a 200-frame video
  546. fade=out:155:45
  547. # fade in first 25 frames and fade out last 25 frames of a 1000-frame video
  548. fade=in:0:25, fade=out:975:25
  549. # make first 5 frames black, then fade in from frame 5-24
  550. fade=in:5:20
  551. @end example
  552. @section fieldorder
  553. Transform the field order of the input video.
  554. It accepts one parameter which specifies the required field order that
  555. the input interlaced video will be transformed to. The parameter can
  556. assume one of the following values:
  557. @table @option
  558. @item 0 or bff
  559. output bottom field first
  560. @item 1 or tff
  561. output top field first
  562. @end table
  563. Default value is "tff".
  564. Transformation is achieved by shifting the picture content up or down
  565. by one line, and filling the remaining line with appropriate picture content.
  566. This method is consistent with most broadcast field order converters.
  567. If the input video is not flagged as being interlaced, or it is already
  568. flagged as being of the required output field order then this filter does
  569. not alter the incoming video.
  570. This filter is very useful when converting to or from PAL DV material,
  571. which is bottom field first.
  572. For example:
  573. @example
  574. ./avconv -i in.vob -vf "fieldorder=bff" out.dv
  575. @end example
  576. @section fifo
  577. Buffer input images and send them when they are requested.
  578. This filter is mainly useful when auto-inserted by the libavfilter
  579. framework.
  580. The filter does not take parameters.
  581. @section format
  582. Convert the input video to one of the specified pixel formats.
  583. Libavfilter will try to pick one that is supported for the input to
  584. the next filter.
  585. The filter accepts a list of pixel format names, separated by ":",
  586. for example "yuv420p:monow:rgb24".
  587. Some examples follow:
  588. @example
  589. # convert the input video to the format "yuv420p"
  590. format=yuv420p
  591. # convert the input video to any of the formats in the list
  592. format=yuv420p:yuv444p:yuv410p
  593. @end example
  594. @anchor{frei0r}
  595. @section frei0r
  596. Apply a frei0r effect to the input video.
  597. To enable compilation of this filter you need to install the frei0r
  598. header and configure Libav with --enable-frei0r.
  599. The filter supports the syntax:
  600. @example
  601. @var{filter_name}[@{:|=@}@var{param1}:@var{param2}:...:@var{paramN}]
  602. @end example
  603. @var{filter_name} is the name to the frei0r effect to load. If the
  604. environment variable @env{FREI0R_PATH} is defined, the frei0r effect
  605. is searched in each one of the directories specified by the colon
  606. separated list in @env{FREIOR_PATH}, otherwise in the standard frei0r
  607. paths, which are in this order: @file{HOME/.frei0r-1/lib/},
  608. @file{/usr/local/lib/frei0r-1/}, @file{/usr/lib/frei0r-1/}.
  609. @var{param1}, @var{param2}, ... , @var{paramN} specify the parameters
  610. for the frei0r effect.
  611. A frei0r effect parameter can be a boolean (whose values are specified
  612. with "y" and "n"), a double, a color (specified by the syntax
  613. @var{R}/@var{G}/@var{B}, @var{R}, @var{G}, and @var{B} being float
  614. numbers from 0.0 to 1.0) or by an @code{av_parse_color()} color
  615. description), a position (specified by the syntax @var{X}/@var{Y},
  616. @var{X} and @var{Y} being float numbers) and a string.
  617. The number and kind of parameters depend on the loaded effect. If an
  618. effect parameter is not specified the default value is set.
  619. Some examples follow:
  620. @example
  621. # apply the distort0r effect, set the first two double parameters
  622. frei0r=distort0r:0.5:0.01
  623. # apply the colordistance effect, takes a color as first parameter
  624. frei0r=colordistance:0.2/0.3/0.4
  625. frei0r=colordistance:violet
  626. frei0r=colordistance:0x112233
  627. # apply the perspective effect, specify the top left and top right
  628. # image positions
  629. frei0r=perspective:0.2/0.2:0.8/0.2
  630. @end example
  631. For more information see:
  632. @url{http://piksel.org/frei0r}
  633. @section gradfun
  634. Fix the banding artifacts that are sometimes introduced into nearly flat
  635. regions by truncation to 8bit colordepth.
  636. Interpolate the gradients that should go where the bands are, and
  637. dither them.
  638. This filter is designed for playback only. Do not use it prior to
  639. lossy compression, because compression tends to lose the dither and
  640. bring back the bands.
  641. The filter takes two optional parameters, separated by ':':
  642. @var{strength}:@var{radius}
  643. @var{strength} is the maximum amount by which the filter will change
  644. any one pixel. Also the threshold for detecting nearly flat
  645. regions. Acceptable values range from .51 to 255, default value is
  646. 1.2, out-of-range values will be clipped to the valid range.
  647. @var{radius} is the neighborhood to fit the gradient to. A larger
  648. radius makes for smoother gradients, but also prevents the filter from
  649. modifying the pixels near detailed regions. Acceptable values are
  650. 8-32, default value is 16, out-of-range values will be clipped to the
  651. valid range.
  652. @example
  653. # default parameters
  654. gradfun=1.2:16
  655. # omitting radius
  656. gradfun=1.2
  657. @end example
  658. @section hflip
  659. Flip the input video horizontally.
  660. For example to horizontally flip the input video with @command{avconv}:
  661. @example
  662. avconv -i in.avi -vf "hflip" out.avi
  663. @end example
  664. @section hqdn3d
  665. High precision/quality 3d denoise filter. This filter aims to reduce
  666. image noise producing smooth images and making still images really
  667. still. It should enhance compressibility.
  668. It accepts the following optional parameters:
  669. @var{luma_spatial}:@var{chroma_spatial}:@var{luma_tmp}:@var{chroma_tmp}
  670. @table @option
  671. @item luma_spatial
  672. a non-negative float number which specifies spatial luma strength,
  673. defaults to 4.0
  674. @item chroma_spatial
  675. a non-negative float number which specifies spatial chroma strength,
  676. defaults to 3.0*@var{luma_spatial}/4.0
  677. @item luma_tmp
  678. a float number which specifies luma temporal strength, defaults to
  679. 6.0*@var{luma_spatial}/4.0
  680. @item chroma_tmp
  681. a float number which specifies chroma temporal strength, defaults to
  682. @var{luma_tmp}*@var{chroma_spatial}/@var{luma_spatial}
  683. @end table
  684. @section lut, lutrgb, lutyuv
  685. Compute a look-up table for binding each pixel component input value
  686. to an output value, and apply it to input video.
  687. @var{lutyuv} applies a lookup table to a YUV input video, @var{lutrgb}
  688. to an RGB input video.
  689. These filters accept in input a ":"-separated list of options, which
  690. specify the expressions used for computing the lookup table for the
  691. corresponding pixel component values.
  692. The @var{lut} filter requires either YUV or RGB pixel formats in
  693. input, and accepts the options:
  694. @table @option
  695. @var{c0} (first pixel component)
  696. @var{c1} (second pixel component)
  697. @var{c2} (third pixel component)
  698. @var{c3} (fourth pixel component, corresponds to the alpha component)
  699. @end table
  700. The exact component associated to each option depends on the format in
  701. input.
  702. The @var{lutrgb} filter requires RGB pixel formats in input, and
  703. accepts the options:
  704. @table @option
  705. @var{r} (red component)
  706. @var{g} (green component)
  707. @var{b} (blue component)
  708. @var{a} (alpha component)
  709. @end table
  710. The @var{lutyuv} filter requires YUV pixel formats in input, and
  711. accepts the options:
  712. @table @option
  713. @var{y} (Y/luminance component)
  714. @var{u} (U/Cb component)
  715. @var{v} (V/Cr component)
  716. @var{a} (alpha component)
  717. @end table
  718. The expressions can contain the following constants and functions:
  719. @table @option
  720. @item E, PI, PHI
  721. the corresponding mathematical approximated values for e
  722. (euler number), pi (greek PI), PHI (golden ratio)
  723. @item w, h
  724. the input width and height
  725. @item val
  726. input value for the pixel component
  727. @item clipval
  728. the input value clipped in the @var{minval}-@var{maxval} range
  729. @item maxval
  730. maximum value for the pixel component
  731. @item minval
  732. minimum value for the pixel component
  733. @item negval
  734. the negated value for the pixel component value clipped in the
  735. @var{minval}-@var{maxval} range , it corresponds to the expression
  736. "maxval-clipval+minval"
  737. @item clip(val)
  738. the computed value in @var{val} clipped in the
  739. @var{minval}-@var{maxval} range
  740. @item gammaval(gamma)
  741. the computed gamma correction value of the pixel component value
  742. clipped in the @var{minval}-@var{maxval} range, corresponds to the
  743. expression
  744. "pow((clipval-minval)/(maxval-minval)\,@var{gamma})*(maxval-minval)+minval"
  745. @end table
  746. All expressions default to "val".
  747. Some examples follow:
  748. @example
  749. # negate input video
  750. lutrgb="r=maxval+minval-val:g=maxval+minval-val:b=maxval+minval-val"
  751. lutyuv="y=maxval+minval-val:u=maxval+minval-val:v=maxval+minval-val"
  752. # the above is the same as
  753. lutrgb="r=negval:g=negval:b=negval"
  754. lutyuv="y=negval:u=negval:v=negval"
  755. # negate luminance
  756. lutyuv=negval
  757. # remove chroma components, turns the video into a graytone image
  758. lutyuv="u=128:v=128"
  759. # apply a luma burning effect
  760. lutyuv="y=2*val"
  761. # remove green and blue components
  762. lutrgb="g=0:b=0"
  763. # set a constant alpha channel value on input
  764. format=rgba,lutrgb=a="maxval-minval/2"
  765. # correct luminance gamma by a 0.5 factor
  766. lutyuv=y=gammaval(0.5)
  767. @end example
  768. @section negate
  769. Negate input video.
  770. This filter accepts an integer in input, if non-zero it negates the
  771. alpha component (if available). The default value in input is 0.
  772. Force libavfilter not to use any of the specified pixel formats for the
  773. input to the next filter.
  774. The filter accepts a list of pixel format names, separated by ":",
  775. for example "yuv420p:monow:rgb24".
  776. Some examples follow:
  777. @example
  778. # force libavfilter to use a format different from "yuv420p" for the
  779. # input to the vflip filter
  780. noformat=yuv420p,vflip
  781. # convert the input video to any of the formats not contained in the list
  782. noformat=yuv420p:yuv444p:yuv410p
  783. @end example
  784. @section null
  785. Pass the video source unchanged to the output.
  786. @section ocv
  787. Apply video transform using libopencv.
  788. To enable this filter install libopencv library and headers and
  789. configure Libav with --enable-libopencv.
  790. The filter takes the parameters: @var{filter_name}@{:=@}@var{filter_params}.
  791. @var{filter_name} is the name of the libopencv filter to apply.
  792. @var{filter_params} specifies the parameters to pass to the libopencv
  793. filter. If not specified the default values are assumed.
  794. Refer to the official libopencv documentation for more precise
  795. information:
  796. @url{http://opencv.willowgarage.com/documentation/c/image_filtering.html}
  797. Follows the list of supported libopencv filters.
  798. @anchor{dilate}
  799. @subsection dilate
  800. Dilate an image by using a specific structuring element.
  801. This filter corresponds to the libopencv function @code{cvDilate}.
  802. It accepts the parameters: @var{struct_el}:@var{nb_iterations}.
  803. @var{struct_el} represents a structuring element, and has the syntax:
  804. @var{cols}x@var{rows}+@var{anchor_x}x@var{anchor_y}/@var{shape}
  805. @var{cols} and @var{rows} represent the number of columns and rows of
  806. the structuring element, @var{anchor_x} and @var{anchor_y} the anchor
  807. point, and @var{shape} the shape for the structuring element, and
  808. can be one of the values "rect", "cross", "ellipse", "custom".
  809. If the value for @var{shape} is "custom", it must be followed by a
  810. string of the form "=@var{filename}". The file with name
  811. @var{filename} is assumed to represent a binary image, with each
  812. printable character corresponding to a bright pixel. When a custom
  813. @var{shape} is used, @var{cols} and @var{rows} are ignored, the number
  814. or columns and rows of the read file are assumed instead.
  815. The default value for @var{struct_el} is "3x3+0x0/rect".
  816. @var{nb_iterations} specifies the number of times the transform is
  817. applied to the image, and defaults to 1.
  818. Follow some example:
  819. @example
  820. # use the default values
  821. ocv=dilate
  822. # dilate using a structuring element with a 5x5 cross, iterate two times
  823. ocv=dilate=5x5+2x2/cross:2
  824. # read the shape from the file diamond.shape, iterate two times
  825. # the file diamond.shape may contain a pattern of characters like this:
  826. # *
  827. # ***
  828. # *****
  829. # ***
  830. # *
  831. # the specified cols and rows are ignored (but not the anchor point coordinates)
  832. ocv=0x0+2x2/custom=diamond.shape:2
  833. @end example
  834. @subsection erode
  835. Erode an image by using a specific structuring element.
  836. This filter corresponds to the libopencv function @code{cvErode}.
  837. The filter accepts the parameters: @var{struct_el}:@var{nb_iterations},
  838. with the same syntax and semantics as the @ref{dilate} filter.
  839. @subsection smooth
  840. Smooth the input video.
  841. The filter takes the following parameters:
  842. @var{type}:@var{param1}:@var{param2}:@var{param3}:@var{param4}.
  843. @var{type} is the type of smooth filter to apply, and can be one of
  844. the following values: "blur", "blur_no_scale", "median", "gaussian",
  845. "bilateral". The default value is "gaussian".
  846. @var{param1}, @var{param2}, @var{param3}, and @var{param4} are
  847. parameters whose meanings depend on smooth type. @var{param1} and
  848. @var{param2} accept integer positive values or 0, @var{param3} and
  849. @var{param4} accept float values.
  850. The default value for @var{param1} is 3, the default value for the
  851. other parameters is 0.
  852. These parameters correspond to the parameters assigned to the
  853. libopencv function @code{cvSmooth}.
  854. @anchor{overlay}
  855. @section overlay
  856. Overlay one video on top of another.
  857. It takes two inputs and one output, the first input is the "main"
  858. video on which the second input is overlayed.
  859. It accepts the parameters: @var{x}:@var{y}.
  860. @var{x} is the x coordinate of the overlayed video on the main video,
  861. @var{y} is the y coordinate. The parameters are expressions containing
  862. the following parameters:
  863. @table @option
  864. @item main_w, main_h
  865. main input width and height
  866. @item W, H
  867. same as @var{main_w} and @var{main_h}
  868. @item overlay_w, overlay_h
  869. overlay input width and height
  870. @item w, h
  871. same as @var{overlay_w} and @var{overlay_h}
  872. @end table
  873. Be aware that frames are taken from each input video in timestamp
  874. order, hence, if their initial timestamps differ, it is a a good idea
  875. to pass the two inputs through a @var{setpts=PTS-STARTPTS} filter to
  876. have them begin in the same zero timestamp, as it does the example for
  877. the @var{movie} filter.
  878. Follow some examples:
  879. @example
  880. # draw the overlay at 10 pixels from the bottom right
  881. # corner of the main video.
  882. overlay=main_w-overlay_w-10:main_h-overlay_h-10
  883. # insert a transparent PNG logo in the bottom left corner of the input
  884. avconv -i input -i logo -filter_complex 'overlay=10:main_h-overlay_h-10' output
  885. # insert 2 different transparent PNG logos (second logo on bottom
  886. # right corner):
  887. avconv -i input -i logo1 -i logo2 -filter_complex
  888. 'overlay=10:H-h-10,overlay=W-w-10:H-h-10' output
  889. # add a transparent color layer on top of the main video,
  890. # WxH specifies the size of the main input to the overlay filter
  891. color=red@.3:WxH [over]; [in][over] overlay [out]
  892. @end example
  893. You can chain together more overlays but the efficiency of such
  894. approach is yet to be tested.
  895. @section pad
  896. Add paddings to the input image, and places the original input at the
  897. given coordinates @var{x}, @var{y}.
  898. It accepts the following parameters:
  899. @var{width}:@var{height}:@var{x}:@var{y}:@var{color}.
  900. The parameters @var{width}, @var{height}, @var{x}, and @var{y} are
  901. expressions containing the following constants:
  902. @table @option
  903. @item E, PI, PHI
  904. the corresponding mathematical approximated values for e
  905. (euler number), pi (greek PI), phi (golden ratio)
  906. @item in_w, in_h
  907. the input video width and height
  908. @item iw, ih
  909. same as @var{in_w} and @var{in_h}
  910. @item out_w, out_h
  911. the output width and height, that is the size of the padded area as
  912. specified by the @var{width} and @var{height} expressions
  913. @item ow, oh
  914. same as @var{out_w} and @var{out_h}
  915. @item x, y
  916. x and y offsets as specified by the @var{x} and @var{y}
  917. expressions, or NAN if not yet specified
  918. @item a
  919. input display aspect ratio, same as @var{iw} / @var{ih}
  920. @item hsub, vsub
  921. horizontal and vertical chroma subsample values. For example for the
  922. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  923. @end table
  924. Follows the description of the accepted parameters.
  925. @table @option
  926. @item width, height
  927. Specify the size of the output image with the paddings added. If the
  928. value for @var{width} or @var{height} is 0, the corresponding input size
  929. is used for the output.
  930. The @var{width} expression can reference the value set by the
  931. @var{height} expression, and vice versa.
  932. The default value of @var{width} and @var{height} is 0.
  933. @item x, y
  934. Specify the offsets where to place the input image in the padded area
  935. with respect to the top/left border of the output image.
  936. The @var{x} expression can reference the value set by the @var{y}
  937. expression, and vice versa.
  938. The default value of @var{x} and @var{y} is 0.
  939. @item color
  940. Specify the color of the padded area, it can be the name of a color
  941. (case insensitive match) or a 0xRRGGBB[AA] sequence.
  942. The default value of @var{color} is "black".
  943. @end table
  944. Some examples follow:
  945. @example
  946. # Add paddings with color "violet" to the input video. Output video
  947. # size is 640x480, the top-left corner of the input video is placed at
  948. # column 0, row 40.
  949. pad=640:480:0:40:violet
  950. # pad the input to get an output with dimensions increased bt 3/2,
  951. # and put the input video at the center of the padded area
  952. pad="3/2*iw:3/2*ih:(ow-iw)/2:(oh-ih)/2"
  953. # pad the input to get a squared output with size equal to the maximum
  954. # value between the input width and height, and put the input video at
  955. # the center of the padded area
  956. pad="max(iw\,ih):ow:(ow-iw)/2:(oh-ih)/2"
  957. # pad the input to get a final w/h ratio of 16:9
  958. pad="ih*16/9:ih:(ow-iw)/2:(oh-ih)/2"
  959. # double output size and put the input video in the bottom-right
  960. # corner of the output padded area
  961. pad="2*iw:2*ih:ow-iw:oh-ih"
  962. @end example
  963. @section pixdesctest
  964. Pixel format descriptor test filter, mainly useful for internal
  965. testing. The output video should be equal to the input video.
  966. For example:
  967. @example
  968. format=monow, pixdesctest
  969. @end example
  970. can be used to test the monowhite pixel format descriptor definition.
  971. @section scale
  972. Scale the input video to @var{width}:@var{height} and/or convert the image format.
  973. The parameters @var{width} and @var{height} are expressions containing
  974. the following constants:
  975. @table @option
  976. @item E, PI, PHI
  977. the corresponding mathematical approximated values for e
  978. (euler number), pi (greek PI), phi (golden ratio)
  979. @item in_w, in_h
  980. the input width and height
  981. @item iw, ih
  982. same as @var{in_w} and @var{in_h}
  983. @item out_w, out_h
  984. the output (cropped) width and height
  985. @item ow, oh
  986. same as @var{out_w} and @var{out_h}
  987. @item dar, a
  988. input display aspect ratio, same as @var{iw} / @var{ih}
  989. @item sar
  990. input sample aspect ratio
  991. @item hsub, vsub
  992. horizontal and vertical chroma subsample values. For example for the
  993. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  994. @end table
  995. If the input image format is different from the format requested by
  996. the next filter, the scale filter will convert the input to the
  997. requested format.
  998. If the value for @var{width} or @var{height} is 0, the respective input
  999. size is used for the output.
  1000. If the value for @var{width} or @var{height} is -1, the scale filter will
  1001. use, for the respective output size, a value that maintains the aspect
  1002. ratio of the input image.
  1003. The default value of @var{width} and @var{height} is 0.
  1004. Some examples follow:
  1005. @example
  1006. # scale the input video to a size of 200x100.
  1007. scale=200:100
  1008. # scale the input to 2x
  1009. scale=2*iw:2*ih
  1010. # the above is the same as
  1011. scale=2*in_w:2*in_h
  1012. # scale the input to half size
  1013. scale=iw/2:ih/2
  1014. # increase the width, and set the height to the same size
  1015. scale=3/2*iw:ow
  1016. # seek for Greek harmony
  1017. scale=iw:1/PHI*iw
  1018. scale=ih*PHI:ih
  1019. # increase the height, and set the width to 3/2 of the height
  1020. scale=3/2*oh:3/5*ih
  1021. # increase the size, but make the size a multiple of the chroma
  1022. scale="trunc(3/2*iw/hsub)*hsub:trunc(3/2*ih/vsub)*vsub"
  1023. # increase the width to a maximum of 500 pixels, keep the same input aspect ratio
  1024. scale='min(500\, iw*3/2):-1'
  1025. @end example
  1026. @section select
  1027. Select frames to pass in output.
  1028. It accepts in input an expression, which is evaluated for each input
  1029. frame. If the expression is evaluated to a non-zero value, the frame
  1030. is selected and passed to the output, otherwise it is discarded.
  1031. The expression can contain the following constants:
  1032. @table @option
  1033. @item PI
  1034. Greek PI
  1035. @item PHI
  1036. golden ratio
  1037. @item E
  1038. Euler number
  1039. @item n
  1040. the sequential number of the filtered frame, starting from 0
  1041. @item selected_n
  1042. the sequential number of the selected frame, starting from 0
  1043. @item prev_selected_n
  1044. the sequential number of the last selected frame, NAN if undefined
  1045. @item TB
  1046. timebase of the input timestamps
  1047. @item pts
  1048. the PTS (Presentation TimeStamp) of the filtered video frame,
  1049. expressed in @var{TB} units, NAN if undefined
  1050. @item t
  1051. the PTS (Presentation TimeStamp) of the filtered video frame,
  1052. expressed in seconds, NAN if undefined
  1053. @item prev_pts
  1054. the PTS of the previously filtered video frame, NAN if undefined
  1055. @item prev_selected_pts
  1056. the PTS of the last previously filtered video frame, NAN if undefined
  1057. @item prev_selected_t
  1058. the PTS of the last previously selected video frame, NAN if undefined
  1059. @item start_pts
  1060. the PTS of the first video frame in the video, NAN if undefined
  1061. @item start_t
  1062. the time of the first video frame in the video, NAN if undefined
  1063. @item pict_type
  1064. the type of the filtered frame, can assume one of the following
  1065. values:
  1066. @table @option
  1067. @item I
  1068. @item P
  1069. @item B
  1070. @item S
  1071. @item SI
  1072. @item SP
  1073. @item BI
  1074. @end table
  1075. @item interlace_type
  1076. the frame interlace type, can assume one of the following values:
  1077. @table @option
  1078. @item PROGRESSIVE
  1079. the frame is progressive (not interlaced)
  1080. @item TOPFIRST
  1081. the frame is top-field-first
  1082. @item BOTTOMFIRST
  1083. the frame is bottom-field-first
  1084. @end table
  1085. @item key
  1086. 1 if the filtered frame is a key-frame, 0 otherwise
  1087. @item pos
  1088. the position in the file of the filtered frame, -1 if the information
  1089. is not available (e.g. for synthetic video)
  1090. @end table
  1091. The default value of the select expression is "1".
  1092. Some examples follow:
  1093. @example
  1094. # select all frames in input
  1095. select
  1096. # the above is the same as:
  1097. select=1
  1098. # skip all frames:
  1099. select=0
  1100. # select only I-frames
  1101. select='eq(pict_type\,I)'
  1102. # select one frame every 100
  1103. select='not(mod(n\,100))'
  1104. # select only frames contained in the 10-20 time interval
  1105. select='gte(t\,10)*lte(t\,20)'
  1106. # select only I frames contained in the 10-20 time interval
  1107. select='gte(t\,10)*lte(t\,20)*eq(pict_type\,I)'
  1108. # select frames with a minimum distance of 10 seconds
  1109. select='isnan(prev_selected_t)+gte(t-prev_selected_t\,10)'
  1110. @end example
  1111. @anchor{setdar}
  1112. @section setdar
  1113. Set the Display Aspect Ratio for the filter output video.
  1114. This is done by changing the specified Sample (aka Pixel) Aspect
  1115. Ratio, according to the following equation:
  1116. @math{DAR = HORIZONTAL_RESOLUTION / VERTICAL_RESOLUTION * SAR}
  1117. Keep in mind that this filter does not modify the pixel dimensions of
  1118. the video frame. Also the display aspect ratio set by this filter may
  1119. be changed by later filters in the filterchain, e.g. in case of
  1120. scaling or if another "setdar" or a "setsar" filter is applied.
  1121. The filter accepts a parameter string which represents the wanted
  1122. display aspect ratio.
  1123. The parameter can be a floating point number string, or an expression
  1124. of the form @var{num}:@var{den}, where @var{num} and @var{den} are the
  1125. numerator and denominator of the aspect ratio.
  1126. If the parameter is not specified, it is assumed the value "0:1".
  1127. For example to change the display aspect ratio to 16:9, specify:
  1128. @example
  1129. setdar=16:9
  1130. # the above is equivalent to
  1131. setdar=1.77777
  1132. @end example
  1133. See also the @ref{setsar} filter documentation.
  1134. @section setpts
  1135. Change the PTS (presentation timestamp) of the input video frames.
  1136. Accept in input an expression evaluated through the eval API, which
  1137. can contain the following constants:
  1138. @table @option
  1139. @item PTS
  1140. the presentation timestamp in input
  1141. @item PI
  1142. Greek PI
  1143. @item PHI
  1144. golden ratio
  1145. @item E
  1146. Euler number
  1147. @item N
  1148. the count of the input frame, starting from 0.
  1149. @item STARTPTS
  1150. the PTS of the first video frame
  1151. @item INTERLACED
  1152. tell if the current frame is interlaced
  1153. @item POS
  1154. original position in the file of the frame, or undefined if undefined
  1155. for the current frame
  1156. @item PREV_INPTS
  1157. previous input PTS
  1158. @item PREV_OUTPTS
  1159. previous output PTS
  1160. @end table
  1161. Some examples follow:
  1162. @example
  1163. # start counting PTS from zero
  1164. setpts=PTS-STARTPTS
  1165. # fast motion
  1166. setpts=0.5*PTS
  1167. # slow motion
  1168. setpts=2.0*PTS
  1169. # fixed rate 25 fps
  1170. setpts=N/(25*TB)
  1171. # fixed rate 25 fps with some jitter
  1172. setpts='1/(25*TB) * (N + 0.05 * sin(N*2*PI/25))'
  1173. @end example
  1174. @anchor{setsar}
  1175. @section setsar
  1176. Set the Sample (aka Pixel) Aspect Ratio for the filter output video.
  1177. Note that as a consequence of the application of this filter, the
  1178. output display aspect ratio will change according to the following
  1179. equation:
  1180. @math{DAR = HORIZONTAL_RESOLUTION / VERTICAL_RESOLUTION * SAR}
  1181. Keep in mind that the sample aspect ratio set by this filter may be
  1182. changed by later filters in the filterchain, e.g. if another "setsar"
  1183. or a "setdar" filter is applied.
  1184. The filter accepts a parameter string which represents the wanted
  1185. sample aspect ratio.
  1186. The parameter can be a floating point number string, or an expression
  1187. of the form @var{num}:@var{den}, where @var{num} and @var{den} are the
  1188. numerator and denominator of the aspect ratio.
  1189. If the parameter is not specified, it is assumed the value "0:1".
  1190. For example to change the sample aspect ratio to 10:11, specify:
  1191. @example
  1192. setsar=10:11
  1193. @end example
  1194. @section settb
  1195. Set the timebase to use for the output frames timestamps.
  1196. It is mainly useful for testing timebase configuration.
  1197. It accepts in input an arithmetic expression representing a rational.
  1198. The expression can contain the constants "PI", "E", "PHI", "AVTB" (the
  1199. default timebase), and "intb" (the input timebase).
  1200. The default value for the input is "intb".
  1201. Follow some examples.
  1202. @example
  1203. # set the timebase to 1/25
  1204. settb=1/25
  1205. # set the timebase to 1/10
  1206. settb=0.1
  1207. #set the timebase to 1001/1000
  1208. settb=1+0.001
  1209. #set the timebase to 2*intb
  1210. settb=2*intb
  1211. #set the default timebase value
  1212. settb=AVTB
  1213. @end example
  1214. @section showinfo
  1215. Show a line containing various information for each input video frame.
  1216. The input video is not modified.
  1217. The shown line contains a sequence of key/value pairs of the form
  1218. @var{key}:@var{value}.
  1219. A description of each shown parameter follows:
  1220. @table @option
  1221. @item n
  1222. sequential number of the input frame, starting from 0
  1223. @item pts
  1224. Presentation TimeStamp of the input frame, expressed as a number of
  1225. time base units. The time base unit depends on the filter input pad.
  1226. @item pts_time
  1227. Presentation TimeStamp of the input frame, expressed as a number of
  1228. seconds
  1229. @item pos
  1230. position of the frame in the input stream, -1 if this information in
  1231. unavailable and/or meaningless (for example in case of synthetic video)
  1232. @item fmt
  1233. pixel format name
  1234. @item sar
  1235. sample aspect ratio of the input frame, expressed in the form
  1236. @var{num}/@var{den}
  1237. @item s
  1238. size of the input frame, expressed in the form
  1239. @var{width}x@var{height}
  1240. @item i
  1241. interlaced mode ("P" for "progressive", "T" for top field first, "B"
  1242. for bottom field first)
  1243. @item iskey
  1244. 1 if the frame is a key frame, 0 otherwise
  1245. @item type
  1246. picture type of the input frame ("I" for an I-frame, "P" for a
  1247. P-frame, "B" for a B-frame, "?" for unknown type).
  1248. Check also the documentation of the @code{AVPictureType} enum and of
  1249. the @code{av_get_picture_type_char} function defined in
  1250. @file{libavutil/avutil.h}.
  1251. @item checksum
  1252. Adler-32 checksum of all the planes of the input frame
  1253. @item plane_checksum
  1254. Adler-32 checksum of each plane of the input frame, expressed in the form
  1255. "[@var{c0} @var{c1} @var{c2} @var{c3}]"
  1256. @end table
  1257. @section slicify
  1258. Pass the images of input video on to next video filter as multiple
  1259. slices.
  1260. @example
  1261. ./avconv -i in.avi -vf "slicify=32" out.avi
  1262. @end example
  1263. The filter accepts the slice height as parameter. If the parameter is
  1264. not specified it will use the default value of 16.
  1265. Adding this in the beginning of filter chains should make filtering
  1266. faster due to better use of the memory cache.
  1267. @section split
  1268. Split input video into several identical outputs.
  1269. The filter accepts a single parameter which specifies the number of outputs. If
  1270. unspecified, it defaults to 2.
  1271. For example
  1272. @example
  1273. avconv -i INPUT -filter_complex split=5 OUTPUT
  1274. @end example
  1275. will create 5 copies of the input video.
  1276. @section transpose
  1277. Transpose rows with columns in the input video and optionally flip it.
  1278. It accepts a parameter representing an integer, which can assume the
  1279. values:
  1280. @table @samp
  1281. @item 0
  1282. Rotate by 90 degrees counterclockwise and vertically flip (default), that is:
  1283. @example
  1284. L.R L.l
  1285. . . -> . .
  1286. l.r R.r
  1287. @end example
  1288. @item 1
  1289. Rotate by 90 degrees clockwise, that is:
  1290. @example
  1291. L.R l.L
  1292. . . -> . .
  1293. l.r r.R
  1294. @end example
  1295. @item 2
  1296. Rotate by 90 degrees counterclockwise, that is:
  1297. @example
  1298. L.R R.r
  1299. . . -> . .
  1300. l.r L.l
  1301. @end example
  1302. @item 3
  1303. Rotate by 90 degrees clockwise and vertically flip, that is:
  1304. @example
  1305. L.R r.R
  1306. . . -> . .
  1307. l.r l.L
  1308. @end example
  1309. @end table
  1310. @section unsharp
  1311. Sharpen or blur the input video.
  1312. It accepts the following parameters:
  1313. @var{luma_msize_x}:@var{luma_msize_y}:@var{luma_amount}:@var{chroma_msize_x}:@var{chroma_msize_y}:@var{chroma_amount}
  1314. Negative values for the amount will blur the input video, while positive
  1315. values will sharpen. All parameters are optional and default to the
  1316. equivalent of the string '5:5:1.0:5:5:0.0'.
  1317. @table @option
  1318. @item luma_msize_x
  1319. Set the luma matrix horizontal size. It can be an integer between 3
  1320. and 13, default value is 5.
  1321. @item luma_msize_y
  1322. Set the luma matrix vertical size. It can be an integer between 3
  1323. and 13, default value is 5.
  1324. @item luma_amount
  1325. Set the luma effect strength. It can be a float number between -2.0
  1326. and 5.0, default value is 1.0.
  1327. @item chroma_msize_x
  1328. Set the chroma matrix horizontal size. It can be an integer between 3
  1329. and 13, default value is 5.
  1330. @item chroma_msize_y
  1331. Set the chroma matrix vertical size. It can be an integer between 3
  1332. and 13, default value is 5.
  1333. @item luma_amount
  1334. Set the chroma effect strength. It can be a float number between -2.0
  1335. and 5.0, default value is 0.0.
  1336. @end table
  1337. @example
  1338. # Strong luma sharpen effect parameters
  1339. unsharp=7:7:2.5
  1340. # Strong blur of both luma and chroma parameters
  1341. unsharp=7:7:-2:7:7:-2
  1342. # Use the default values with @command{avconv}
  1343. ./avconv -i in.avi -vf "unsharp" out.mp4
  1344. @end example
  1345. @section vflip
  1346. Flip the input video vertically.
  1347. @example
  1348. ./avconv -i in.avi -vf "vflip" out.avi
  1349. @end example
  1350. @section yadif
  1351. Deinterlace the input video ("yadif" means "yet another deinterlacing
  1352. filter").
  1353. It accepts the optional parameters: @var{mode}:@var{parity}:@var{auto}.
  1354. @var{mode} specifies the interlacing mode to adopt, accepts one of the
  1355. following values:
  1356. @table @option
  1357. @item 0
  1358. output 1 frame for each frame
  1359. @item 1
  1360. output 1 frame for each field
  1361. @item 2
  1362. like 0 but skips spatial interlacing check
  1363. @item 3
  1364. like 1 but skips spatial interlacing check
  1365. @end table
  1366. Default value is 0.
  1367. @var{parity} specifies the picture field parity assumed for the input
  1368. interlaced video, accepts one of the following values:
  1369. @table @option
  1370. @item 0
  1371. assume top field first
  1372. @item 1
  1373. assume bottom field first
  1374. @item -1
  1375. enable automatic detection
  1376. @end table
  1377. Default value is -1.
  1378. If interlacing is unknown or decoder does not export this information,
  1379. top field first will be assumed.
  1380. @var{auto} specifies if deinterlacer should trust the interlaced flag
  1381. and only deinterlace frames marked as interlaced
  1382. @table @option
  1383. @item 0
  1384. deinterlace all frames
  1385. @item 1
  1386. only deinterlace frames marked as interlaced
  1387. @end table
  1388. Default value is 0.
  1389. @c man end VIDEO FILTERS
  1390. @chapter Video Sources
  1391. @c man begin VIDEO SOURCES
  1392. Below is a description of the currently available video sources.
  1393. @section buffer
  1394. Buffer video frames, and make them available to the filter chain.
  1395. This source is mainly intended for a programmatic use, in particular
  1396. through the interface defined in @file{libavfilter/vsrc_buffer.h}.
  1397. It accepts the following parameters:
  1398. @var{width}:@var{height}:@var{pix_fmt_string}:@var{timebase_num}:@var{timebase_den}:@var{sample_aspect_ratio_num}:@var{sample_aspect_ratio.den}
  1399. All the parameters need to be explicitly defined.
  1400. Follows the list of the accepted parameters.
  1401. @table @option
  1402. @item width, height
  1403. Specify the width and height of the buffered video frames.
  1404. @item pix_fmt_string
  1405. A string representing the pixel format of the buffered video frames.
  1406. It may be a number corresponding to a pixel format, or a pixel format
  1407. name.
  1408. @item timebase_num, timebase_den
  1409. Specify numerator and denomitor of the timebase assumed by the
  1410. timestamps of the buffered frames.
  1411. @item sample_aspect_ratio.num, sample_aspect_ratio.den
  1412. Specify numerator and denominator of the sample aspect ratio assumed
  1413. by the video frames.
  1414. @end table
  1415. For example:
  1416. @example
  1417. buffer=320:240:yuv410p:1:24:1:1
  1418. @end example
  1419. will instruct the source to accept video frames with size 320x240 and
  1420. with format "yuv410p", assuming 1/24 as the timestamps timebase and
  1421. square pixels (1:1 sample aspect ratio).
  1422. Since the pixel format with name "yuv410p" corresponds to the number 6
  1423. (check the enum PixelFormat definition in @file{libavutil/pixfmt.h}),
  1424. this example corresponds to:
  1425. @example
  1426. buffer=320:240:6:1:24
  1427. @end example
  1428. @section color
  1429. Provide an uniformly colored input.
  1430. It accepts the following parameters:
  1431. @var{color}:@var{frame_size}:@var{frame_rate}
  1432. Follows the description of the accepted parameters.
  1433. @table @option
  1434. @item color
  1435. Specify the color of the source. It can be the name of a color (case
  1436. insensitive match) or a 0xRRGGBB[AA] sequence, possibly followed by an
  1437. alpha specifier. The default value is "black".
  1438. @item frame_size
  1439. Specify the size of the sourced video, it may be a string of the form
  1440. @var{width}x@var{height}, or the name of a size abbreviation. The
  1441. default value is "320x240".
  1442. @item frame_rate
  1443. Specify the frame rate of the sourced video, as the number of frames
  1444. generated per second. It has to be a string in the format
  1445. @var{frame_rate_num}/@var{frame_rate_den}, an integer number, a float
  1446. number or a valid video frame rate abbreviation. The default value is
  1447. "25".
  1448. @end table
  1449. For example the following graph description will generate a red source
  1450. with an opacity of 0.2, with size "qcif" and a frame rate of 10
  1451. frames per second, which will be overlayed over the source connected
  1452. to the pad with identifier "in".
  1453. @example
  1454. "color=red@@0.2:qcif:10 [color]; [in][color] overlay [out]"
  1455. @end example
  1456. @section movie
  1457. Read a video stream from a movie container.
  1458. It accepts the syntax: @var{movie_name}[:@var{options}] where
  1459. @var{movie_name} is the name of the resource to read (not necessarily
  1460. a file but also a device or a stream accessed through some protocol),
  1461. and @var{options} is an optional sequence of @var{key}=@var{value}
  1462. pairs, separated by ":".
  1463. The description of the accepted options follows.
  1464. @table @option
  1465. @item format_name, f
  1466. Specifies the format assumed for the movie to read, and can be either
  1467. the name of a container or an input device. If not specified the
  1468. format is guessed from @var{movie_name} or by probing.
  1469. @item seek_point, sp
  1470. Specifies the seek point in seconds, the frames will be output
  1471. starting from this seek point, the parameter is evaluated with
  1472. @code{av_strtod} so the numerical value may be suffixed by an IS
  1473. postfix. Default value is "0".
  1474. @item stream_index, si
  1475. Specifies the index of the video stream to read. If the value is -1,
  1476. the best suited video stream will be automatically selected. Default
  1477. value is "-1".
  1478. @end table
  1479. This filter allows to overlay a second video on top of main input of
  1480. a filtergraph as shown in this graph:
  1481. @example
  1482. input -----------> deltapts0 --> overlay --> output
  1483. ^
  1484. |
  1485. movie --> scale--> deltapts1 -------+
  1486. @end example
  1487. Some examples follow:
  1488. @example
  1489. # skip 3.2 seconds from the start of the avi file in.avi, and overlay it
  1490. # on top of the input labelled as "in".
  1491. movie=in.avi:seek_point=3.2, scale=180:-1, setpts=PTS-STARTPTS [movie];
  1492. [in] setpts=PTS-STARTPTS, [movie] overlay=16:16 [out]
  1493. # read from a video4linux2 device, and overlay it on top of the input
  1494. # labelled as "in"
  1495. movie=/dev/video0:f=video4linux2, scale=180:-1, setpts=PTS-STARTPTS [movie];
  1496. [in] setpts=PTS-STARTPTS, [movie] overlay=16:16 [out]
  1497. @end example
  1498. @section nullsrc
  1499. Null video source, never return images. It is mainly useful as a
  1500. template and to be employed in analysis / debugging tools.
  1501. It accepts as optional parameter a string of the form
  1502. @var{width}:@var{height}:@var{timebase}.
  1503. @var{width} and @var{height} specify the size of the configured
  1504. source. The default values of @var{width} and @var{height} are
  1505. respectively 352 and 288 (corresponding to the CIF size format).
  1506. @var{timebase} specifies an arithmetic expression representing a
  1507. timebase. The expression can contain the constants "PI", "E", "PHI",
  1508. "AVTB" (the default timebase), and defaults to the value "AVTB".
  1509. @section frei0r_src
  1510. Provide a frei0r source.
  1511. To enable compilation of this filter you need to install the frei0r
  1512. header and configure Libav with --enable-frei0r.
  1513. The source supports the syntax:
  1514. @example
  1515. @var{size}:@var{rate}:@var{src_name}[@{=|:@}@var{param1}:@var{param2}:...:@var{paramN}]
  1516. @end example
  1517. @var{size} is the size of the video to generate, may be a string of the
  1518. form @var{width}x@var{height} or a frame size abbreviation.
  1519. @var{rate} is the rate of the video to generate, may be a string of
  1520. the form @var{num}/@var{den} or a frame rate abbreviation.
  1521. @var{src_name} is the name to the frei0r source to load. For more
  1522. information regarding frei0r and how to set the parameters read the
  1523. section @ref{frei0r} in the description of the video filters.
  1524. Some examples follow:
  1525. @example
  1526. # generate a frei0r partik0l source with size 200x200 and framerate 10
  1527. # which is overlayed on the overlay filter main input
  1528. frei0r_src=200x200:10:partik0l=1234 [overlay]; [in][overlay] overlay
  1529. @end example
  1530. @section rgbtestsrc, testsrc
  1531. The @code{rgbtestsrc} source generates an RGB test pattern useful for
  1532. detecting RGB vs BGR issues. You should see a red, green and blue
  1533. stripe from top to bottom.
  1534. The @code{testsrc} source generates a test video pattern, showing a
  1535. color pattern, a scrolling gradient and a timestamp. This is mainly
  1536. intended for testing purposes.
  1537. Both sources accept an optional sequence of @var{key}=@var{value} pairs,
  1538. separated by ":". The description of the accepted options follows.
  1539. @table @option
  1540. @item size, s
  1541. Specify the size of the sourced video, it may be a string of the form
  1542. @var{width}x@var{height}, or the name of a size abbreviation. The
  1543. default value is "320x240".
  1544. @item rate, r
  1545. Specify the frame rate of the sourced video, as the number of frames
  1546. generated per second. It has to be a string in the format
  1547. @var{frame_rate_num}/@var{frame_rate_den}, an integer number, a float
  1548. number or a valid video frame rate abbreviation. The default value is
  1549. "25".
  1550. @item sar
  1551. Set the sample aspect ratio of the sourced video.
  1552. @item duration
  1553. Set the video duration of the sourced video. The accepted syntax is:
  1554. @example
  1555. [-]HH[:MM[:SS[.m...]]]
  1556. [-]S+[.m...]
  1557. @end example
  1558. See also the function @code{av_parse_time()}.
  1559. If not specified, or the expressed duration is negative, the video is
  1560. supposed to be generated forever.
  1561. @end table
  1562. For example the following:
  1563. @example
  1564. testsrc=duration=5.3:size=qcif:rate=10
  1565. @end example
  1566. will generate a video with a duration of 5.3 seconds, with size
  1567. 176x144 and a framerate of 10 frames per second.
  1568. @c man end VIDEO SOURCES
  1569. @chapter Video Sinks
  1570. @c man begin VIDEO SINKS
  1571. Below is a description of the currently available video sinks.
  1572. @section buffersink
  1573. Buffer video frames, and make them available to the end of the filter
  1574. graph.
  1575. This sink is intended for a programmatic use through the interface defined in
  1576. @file{libavfilter/buffersink.h}.
  1577. @section nullsink
  1578. Null video sink, do absolutely nothing with the input video. It is
  1579. mainly useful as a template and to be employed in analysis / debugging
  1580. tools.
  1581. @c man end VIDEO SINKS