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.

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