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.

12572 lines
339KB

  1. @chapter Filtering Introduction
  2. @c man begin FILTERING INTRODUCTION
  3. Filtering in FFmpeg is enabled through the libavfilter library.
  4. In libavfilter, a filter can have multiple inputs and multiple
  5. outputs.
  6. To illustrate the sorts of things that are possible, we consider the
  7. following filtergraph.
  8. @verbatim
  9. [main]
  10. input --> split ---------------------> overlay --> output
  11. | ^
  12. |[tmp] [flip]|
  13. +-----> crop --> vflip -------+
  14. @end verbatim
  15. This filtergraph splits the input stream in two streams, then sends one
  16. stream through the crop filter and the vflip filter, before merging it
  17. back with the other stream by overlaying it on top. You can use the
  18. following command to achieve this:
  19. @example
  20. ffmpeg -i INPUT -vf "split [main][tmp]; [tmp] crop=iw:ih/2:0:0, vflip [flip]; [main][flip] overlay=0:H/2" OUTPUT
  21. @end example
  22. The result will be that the top half of the video is mirrored
  23. onto the bottom half of the output video.
  24. Filters in the same linear chain are separated by commas, and distinct
  25. linear chains of filters are separated by semicolons. In our example,
  26. @var{crop,vflip} are in one linear chain, @var{split} and
  27. @var{overlay} are separately in another. The points where the linear
  28. chains join are labelled by names enclosed in square brackets. In the
  29. example, the split filter generates two outputs that are associated to
  30. the labels @var{[main]} and @var{[tmp]}.
  31. The stream sent to the second output of @var{split}, labelled as
  32. @var{[tmp]}, is processed through the @var{crop} filter, which crops
  33. away the lower half part of the video, and then vertically flipped. The
  34. @var{overlay} filter takes in input the first unchanged output of the
  35. split filter (which was labelled as @var{[main]}), and overlay on its
  36. lower half the output generated by the @var{crop,vflip} filterchain.
  37. Some filters take in input a list of parameters: they are specified
  38. after the filter name and an equal sign, and are separated from each other
  39. by a colon.
  40. There exist so-called @var{source filters} that do not have an
  41. audio/video input, and @var{sink filters} that will not have audio/video
  42. output.
  43. @c man end FILTERING INTRODUCTION
  44. @chapter graph2dot
  45. @c man begin GRAPH2DOT
  46. The @file{graph2dot} program included in the FFmpeg @file{tools}
  47. directory can be used to parse a filtergraph description and issue a
  48. corresponding textual representation in the dot language.
  49. Invoke the command:
  50. @example
  51. graph2dot -h
  52. @end example
  53. to see how to use @file{graph2dot}.
  54. You can then pass the dot description to the @file{dot} program (from
  55. the graphviz suite of programs) and obtain a graphical representation
  56. of the filtergraph.
  57. For example the sequence of commands:
  58. @example
  59. echo @var{GRAPH_DESCRIPTION} | \
  60. tools/graph2dot -o graph.tmp && \
  61. dot -Tpng graph.tmp -o graph.png && \
  62. display graph.png
  63. @end example
  64. can be used to create and display an image representing the graph
  65. described by the @var{GRAPH_DESCRIPTION} string. Note that this string must be
  66. a complete self-contained graph, with its inputs and outputs explicitly defined.
  67. For example if your command line is of the form:
  68. @example
  69. ffmpeg -i infile -vf scale=640:360 outfile
  70. @end example
  71. your @var{GRAPH_DESCRIPTION} string will need to be of the form:
  72. @example
  73. nullsrc,scale=640:360,nullsink
  74. @end example
  75. you may also need to set the @var{nullsrc} parameters and add a @var{format}
  76. filter in order to simulate a specific input file.
  77. @c man end GRAPH2DOT
  78. @chapter Filtergraph description
  79. @c man begin FILTERGRAPH DESCRIPTION
  80. A filtergraph is a directed graph of connected filters. It can contain
  81. cycles, and there can be multiple links between a pair of
  82. filters. Each link has one input pad on one side connecting it to one
  83. filter from which it takes its input, and one output pad on the other
  84. side connecting it to one filter accepting its output.
  85. Each filter in a filtergraph is an instance of a filter class
  86. registered in the application, which defines the features and the
  87. number of input and output pads of the filter.
  88. A filter with no input pads is called a "source", and a filter with no
  89. output pads is called a "sink".
  90. @anchor{Filtergraph syntax}
  91. @section Filtergraph syntax
  92. A filtergraph has a textual representation, which is recognized by the
  93. @option{-filter}/@option{-vf}/@option{-af} and
  94. @option{-filter_complex} options in @command{ffmpeg} and
  95. @option{-vf}/@option{-af} in @command{ffplay}, and by the
  96. @code{avfilter_graph_parse_ptr()} function defined in
  97. @file{libavfilter/avfilter.h}.
  98. A filterchain consists of a sequence of connected filters, each one
  99. connected to the previous one in the sequence. A filterchain is
  100. represented by a list of ","-separated filter descriptions.
  101. A filtergraph consists of a sequence of filterchains. A sequence of
  102. filterchains is represented by a list of ";"-separated filterchain
  103. descriptions.
  104. A filter is represented by a string of the form:
  105. [@var{in_link_1}]...[@var{in_link_N}]@var{filter_name}=@var{arguments}[@var{out_link_1}]...[@var{out_link_M}]
  106. @var{filter_name} is the name of the filter class of which the
  107. described filter is an instance of, and has to be the name of one of
  108. the filter classes registered in the program.
  109. The name of the filter class is optionally followed by a string
  110. "=@var{arguments}".
  111. @var{arguments} is a string which contains the parameters used to
  112. initialize the filter instance. It may have one of two forms:
  113. @itemize
  114. @item
  115. A ':'-separated list of @var{key=value} pairs.
  116. @item
  117. A ':'-separated list of @var{value}. In this case, the keys are assumed to be
  118. the option names in the order they are declared. E.g. the @code{fade} filter
  119. declares three options in this order -- @option{type}, @option{start_frame} and
  120. @option{nb_frames}. Then the parameter list @var{in:0:30} means that the value
  121. @var{in} is assigned to the option @option{type}, @var{0} to
  122. @option{start_frame} and @var{30} to @option{nb_frames}.
  123. @item
  124. A ':'-separated list of mixed direct @var{value} and long @var{key=value}
  125. pairs. The direct @var{value} must precede the @var{key=value} pairs, and
  126. follow the same constraints order of the previous point. The following
  127. @var{key=value} pairs can be set in any preferred order.
  128. @end itemize
  129. If the option value itself is a list of items (e.g. the @code{format} filter
  130. takes a list of pixel formats), the items in the list are usually separated by
  131. @samp{|}.
  132. The list of arguments can be quoted using the character @samp{'} as initial
  133. and ending mark, and the character @samp{\} for escaping the characters
  134. within the quoted text; otherwise the argument string is considered
  135. terminated when the next special character (belonging to the set
  136. @samp{[]=;,}) is encountered.
  137. The name and arguments of the filter are optionally preceded and
  138. followed by a list of link labels.
  139. A link label allows one to name a link and associate it to a filter output
  140. or input pad. The preceding labels @var{in_link_1}
  141. ... @var{in_link_N}, are associated to the filter input pads,
  142. the following labels @var{out_link_1} ... @var{out_link_M}, are
  143. associated to the output pads.
  144. When two link labels with the same name are found in the
  145. filtergraph, a link between the corresponding input and output pad is
  146. created.
  147. If an output pad is not labelled, it is linked by default to the first
  148. unlabelled input pad of the next filter in the filterchain.
  149. For example in the filterchain
  150. @example
  151. nullsrc, split[L1], [L2]overlay, nullsink
  152. @end example
  153. the split filter instance has two output pads, and the overlay filter
  154. instance two input pads. The first output pad of split is labelled
  155. "L1", the first input pad of overlay is labelled "L2", and the second
  156. output pad of split is linked to the second input pad of overlay,
  157. which are both unlabelled.
  158. In a filter description, if the input label of the first filter is not
  159. specified, "in" is assumed; if the output label of the last filter is not
  160. specified, "out" is assumed.
  161. In a complete filterchain all the unlabelled filter input and output
  162. pads must be connected. A filtergraph is considered valid if all the
  163. filter input and output pads of all the filterchains are connected.
  164. Libavfilter will automatically insert @ref{scale} filters where format
  165. conversion is required. It is possible to specify swscale flags
  166. for those automatically inserted scalers by prepending
  167. @code{sws_flags=@var{flags};}
  168. to the filtergraph description.
  169. Here is a BNF description of the filtergraph syntax:
  170. @example
  171. @var{NAME} ::= sequence of alphanumeric characters and '_'
  172. @var{LINKLABEL} ::= "[" @var{NAME} "]"
  173. @var{LINKLABELS} ::= @var{LINKLABEL} [@var{LINKLABELS}]
  174. @var{FILTER_ARGUMENTS} ::= sequence of chars (possibly quoted)
  175. @var{FILTER} ::= [@var{LINKLABELS}] @var{NAME} ["=" @var{FILTER_ARGUMENTS}] [@var{LINKLABELS}]
  176. @var{FILTERCHAIN} ::= @var{FILTER} [,@var{FILTERCHAIN}]
  177. @var{FILTERGRAPH} ::= [sws_flags=@var{flags};] @var{FILTERCHAIN} [;@var{FILTERGRAPH}]
  178. @end example
  179. @section Notes on filtergraph escaping
  180. Filtergraph description composition entails several levels of
  181. escaping. See @ref{quoting_and_escaping,,the "Quoting and escaping"
  182. section in the ffmpeg-utils(1) manual,ffmpeg-utils} for more
  183. information about the employed escaping procedure.
  184. A first level escaping affects the content of each filter option
  185. value, which may contain the special character @code{:} used to
  186. separate values, or one of the escaping characters @code{\'}.
  187. A second level escaping affects the whole filter description, which
  188. may contain the escaping characters @code{\'} or the special
  189. characters @code{[],;} used by the filtergraph description.
  190. Finally, when you specify a filtergraph on a shell commandline, you
  191. need to perform a third level escaping for the shell special
  192. characters contained within it.
  193. For example, consider the following string to be embedded in
  194. the @ref{drawtext} filter description @option{text} value:
  195. @example
  196. this is a 'string': may contain one, or more, special characters
  197. @end example
  198. This string contains the @code{'} special escaping character, and the
  199. @code{:} special character, so it needs to be escaped in this way:
  200. @example
  201. text=this is a \'string\'\: may contain one, or more, special characters
  202. @end example
  203. A second level of escaping is required when embedding the filter
  204. description in a filtergraph description, in order to escape all the
  205. filtergraph special characters. Thus the example above becomes:
  206. @example
  207. drawtext=text=this is a \\\'string\\\'\\: may contain one\, or more\, special characters
  208. @end example
  209. (note that in addition to the @code{\'} escaping special characters,
  210. also @code{,} needs to be escaped).
  211. Finally an additional level of escaping is needed when writing the
  212. filtergraph description in a shell command, which depends on the
  213. escaping rules of the adopted shell. For example, assuming that
  214. @code{\} is special and needs to be escaped with another @code{\}, the
  215. previous string will finally result in:
  216. @example
  217. -vf "drawtext=text=this is a \\\\\\'string\\\\\\'\\\\: may contain one\\, or more\\, special characters"
  218. @end example
  219. @chapter Timeline editing
  220. Some filters support a generic @option{enable} option. For the filters
  221. supporting timeline editing, this option can be set to an expression which is
  222. evaluated before sending a frame to the filter. If the evaluation is non-zero,
  223. the filter will be enabled, otherwise the frame will be sent unchanged to the
  224. next filter in the filtergraph.
  225. The expression accepts the following values:
  226. @table @samp
  227. @item t
  228. timestamp expressed in seconds, NAN if the input timestamp is unknown
  229. @item n
  230. sequential number of the input frame, starting from 0
  231. @item pos
  232. the position in the file of the input frame, NAN if unknown
  233. @item w
  234. @item h
  235. width and height of the input frame if video
  236. @end table
  237. Additionally, these filters support an @option{enable} command that can be used
  238. to re-define the expression.
  239. Like any other filtering option, the @option{enable} option follows the same
  240. rules.
  241. For example, to enable a blur filter (@ref{smartblur}) from 10 seconds to 3
  242. minutes, and a @ref{curves} filter starting at 3 seconds:
  243. @example
  244. smartblur = enable='between(t,10,3*60)',
  245. curves = enable='gte(t,3)' : preset=cross_process
  246. @end example
  247. @c man end FILTERGRAPH DESCRIPTION
  248. @chapter Audio Filters
  249. @c man begin AUDIO FILTERS
  250. When you configure your FFmpeg build, you can disable any of the
  251. existing filters using @code{--disable-filters}.
  252. The configure output will show the audio filters included in your
  253. build.
  254. Below is a description of the currently available audio filters.
  255. @section adelay
  256. Delay one or more audio channels.
  257. Samples in delayed channel are filled with silence.
  258. The filter accepts the following option:
  259. @table @option
  260. @item delays
  261. Set list of delays in milliseconds for each channel separated by '|'.
  262. At least one delay greater than 0 should be provided.
  263. Unused delays will be silently ignored. If number of given delays is
  264. smaller than number of channels all remaining channels will not be delayed.
  265. @end table
  266. @subsection Examples
  267. @itemize
  268. @item
  269. Delay first channel by 1.5 seconds, the third channel by 0.5 seconds and leave
  270. the second channel (and any other channels that may be present) unchanged.
  271. @example
  272. adelay=1500|0|500
  273. @end example
  274. @end itemize
  275. @section aecho
  276. Apply echoing to the input audio.
  277. Echoes are reflected sound and can occur naturally amongst mountains
  278. (and sometimes large buildings) when talking or shouting; digital echo
  279. effects emulate this behaviour and are often used to help fill out the
  280. sound of a single instrument or vocal. The time difference between the
  281. original signal and the reflection is the @code{delay}, and the
  282. loudness of the reflected signal is the @code{decay}.
  283. Multiple echoes can have different delays and decays.
  284. A description of the accepted parameters follows.
  285. @table @option
  286. @item in_gain
  287. Set input gain of reflected signal. Default is @code{0.6}.
  288. @item out_gain
  289. Set output gain of reflected signal. Default is @code{0.3}.
  290. @item delays
  291. Set list of time intervals in milliseconds between original signal and reflections
  292. separated by '|'. Allowed range for each @code{delay} is @code{(0 - 90000.0]}.
  293. Default is @code{1000}.
  294. @item decays
  295. Set list of loudnesses of reflected signals separated by '|'.
  296. Allowed range for each @code{decay} is @code{(0 - 1.0]}.
  297. Default is @code{0.5}.
  298. @end table
  299. @subsection Examples
  300. @itemize
  301. @item
  302. Make it sound as if there are twice as many instruments as are actually playing:
  303. @example
  304. aecho=0.8:0.88:60:0.4
  305. @end example
  306. @item
  307. If delay is very short, then it sound like a (metallic) robot playing music:
  308. @example
  309. aecho=0.8:0.88:6:0.4
  310. @end example
  311. @item
  312. A longer delay will sound like an open air concert in the mountains:
  313. @example
  314. aecho=0.8:0.9:1000:0.3
  315. @end example
  316. @item
  317. Same as above but with one more mountain:
  318. @example
  319. aecho=0.8:0.9:1000|1800:0.3|0.25
  320. @end example
  321. @end itemize
  322. @section aeval
  323. Modify an audio signal according to the specified expressions.
  324. This filter accepts one or more expressions (one for each channel),
  325. which are evaluated and used to modify a corresponding audio signal.
  326. It accepts the following parameters:
  327. @table @option
  328. @item exprs
  329. Set the '|'-separated expressions list for each separate channel. If
  330. the number of input channels is greater than the number of
  331. expressions, the last specified expression is used for the remaining
  332. output channels.
  333. @item channel_layout, c
  334. Set output channel layout. If not specified, the channel layout is
  335. specified by the number of expressions. If set to @samp{same}, it will
  336. use by default the same input channel layout.
  337. @end table
  338. Each expression in @var{exprs} can contain the following constants and functions:
  339. @table @option
  340. @item ch
  341. channel number of the current expression
  342. @item n
  343. number of the evaluated sample, starting from 0
  344. @item s
  345. sample rate
  346. @item t
  347. time of the evaluated sample expressed in seconds
  348. @item nb_in_channels
  349. @item nb_out_channels
  350. input and output number of channels
  351. @item val(CH)
  352. the value of input channel with number @var{CH}
  353. @end table
  354. Note: this filter is slow. For faster processing you should use a
  355. dedicated filter.
  356. @subsection Examples
  357. @itemize
  358. @item
  359. Half volume:
  360. @example
  361. aeval=val(ch)/2:c=same
  362. @end example
  363. @item
  364. Invert phase of the second channel:
  365. @example
  366. aeval=val(0)|-val(1)
  367. @end example
  368. @end itemize
  369. @section afade
  370. Apply fade-in/out effect to input audio.
  371. A description of the accepted parameters follows.
  372. @table @option
  373. @item type, t
  374. Specify the effect type, can be either @code{in} for fade-in, or
  375. @code{out} for a fade-out effect. Default is @code{in}.
  376. @item start_sample, ss
  377. Specify the number of the start sample for starting to apply the fade
  378. effect. Default is 0.
  379. @item nb_samples, ns
  380. Specify the number of samples for which the fade effect has to last. At
  381. the end of the fade-in effect the output audio will have the same
  382. volume as the input audio, at the end of the fade-out transition
  383. the output audio will be silence. Default is 44100.
  384. @item start_time, st
  385. Specify the start time of the fade effect. Default is 0.
  386. The value must be specified as a time duration; see
  387. @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}
  388. for the accepted syntax.
  389. If set this option is used instead of @var{start_sample}.
  390. @item duration, d
  391. Specify the duration of the fade effect. See
  392. @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}
  393. for the accepted syntax.
  394. At the end of the fade-in effect the output audio will have the same
  395. volume as the input audio, at the end of the fade-out transition
  396. the output audio will be silence.
  397. By default the duration is determined by @var{nb_samples}.
  398. If set this option is used instead of @var{nb_samples}.
  399. @item curve
  400. Set curve for fade transition.
  401. It accepts the following values:
  402. @table @option
  403. @item tri
  404. select triangular, linear slope (default)
  405. @item qsin
  406. select quarter of sine wave
  407. @item hsin
  408. select half of sine wave
  409. @item esin
  410. select exponential sine wave
  411. @item log
  412. select logarithmic
  413. @item ipar
  414. select inverted parabola
  415. @item qua
  416. select quadratic
  417. @item cub
  418. select cubic
  419. @item squ
  420. select square root
  421. @item cbr
  422. select cubic root
  423. @item par
  424. select parabola
  425. @item exp
  426. select exponential
  427. @item iqsin
  428. select inverted quarter of sine wave
  429. @item ihsin
  430. select inverted half of sine wave
  431. @item dese
  432. select double-exponential seat
  433. @item desi
  434. select double-exponential sigmoid
  435. @end table
  436. @end table
  437. @subsection Examples
  438. @itemize
  439. @item
  440. Fade in first 15 seconds of audio:
  441. @example
  442. afade=t=in:ss=0:d=15
  443. @end example
  444. @item
  445. Fade out last 25 seconds of a 900 seconds audio:
  446. @example
  447. afade=t=out:st=875:d=25
  448. @end example
  449. @end itemize
  450. @anchor{aformat}
  451. @section aformat
  452. Set output format constraints for the input audio. The framework will
  453. negotiate the most appropriate format to minimize conversions.
  454. It accepts the following parameters:
  455. @table @option
  456. @item sample_fmts
  457. A '|'-separated list of requested sample formats.
  458. @item sample_rates
  459. A '|'-separated list of requested sample rates.
  460. @item channel_layouts
  461. A '|'-separated list of requested channel layouts.
  462. See @ref{channel layout syntax,,the Channel Layout section in the ffmpeg-utils(1) manual,ffmpeg-utils}
  463. for the required syntax.
  464. @end table
  465. If a parameter is omitted, all values are allowed.
  466. Force the output to either unsigned 8-bit or signed 16-bit stereo
  467. @example
  468. aformat=sample_fmts=u8|s16:channel_layouts=stereo
  469. @end example
  470. @section allpass
  471. Apply a two-pole all-pass filter with central frequency (in Hz)
  472. @var{frequency}, and filter-width @var{width}.
  473. An all-pass filter changes the audio's frequency to phase relationship
  474. without changing its frequency to amplitude relationship.
  475. The filter accepts the following options:
  476. @table @option
  477. @item frequency, f
  478. Set frequency in Hz.
  479. @item width_type
  480. Set method to specify band-width of filter.
  481. @table @option
  482. @item h
  483. Hz
  484. @item q
  485. Q-Factor
  486. @item o
  487. octave
  488. @item s
  489. slope
  490. @end table
  491. @item width, w
  492. Specify the band-width of a filter in width_type units.
  493. @end table
  494. @section amerge
  495. Merge two or more audio streams into a single multi-channel stream.
  496. The filter accepts the following options:
  497. @table @option
  498. @item inputs
  499. Set the number of inputs. Default is 2.
  500. @end table
  501. If the channel layouts of the inputs are disjoint, and therefore compatible,
  502. the channel layout of the output will be set accordingly and the channels
  503. will be reordered as necessary. If the channel layouts of the inputs are not
  504. disjoint, the output will have all the channels of the first input then all
  505. the channels of the second input, in that order, and the channel layout of
  506. the output will be the default value corresponding to the total number of
  507. channels.
  508. For example, if the first input is in 2.1 (FL+FR+LF) and the second input
  509. is FC+BL+BR, then the output will be in 5.1, with the channels in the
  510. following order: a1, a2, b1, a3, b2, b3 (a1 is the first channel of the
  511. first input, b1 is the first channel of the second input).
  512. On the other hand, if both input are in stereo, the output channels will be
  513. in the default order: a1, a2, b1, b2, and the channel layout will be
  514. arbitrarily set to 4.0, which may or may not be the expected value.
  515. All inputs must have the same sample rate, and format.
  516. If inputs do not have the same duration, the output will stop with the
  517. shortest.
  518. @subsection Examples
  519. @itemize
  520. @item
  521. Merge two mono files into a stereo stream:
  522. @example
  523. amovie=left.wav [l] ; amovie=right.mp3 [r] ; [l] [r] amerge
  524. @end example
  525. @item
  526. Multiple merges assuming 1 video stream and 6 audio streams in @file{input.mkv}:
  527. @example
  528. ffmpeg -i input.mkv -filter_complex "[0:1][0:2][0:3][0:4][0:5][0:6] amerge=inputs=6" -c:a pcm_s16le output.mkv
  529. @end example
  530. @end itemize
  531. @section amix
  532. Mixes multiple audio inputs into a single output.
  533. Note that this filter only supports float samples (the @var{amerge}
  534. and @var{pan} audio filters support many formats). If the @var{amix}
  535. input has integer samples then @ref{aresample} will be automatically
  536. inserted to perform the conversion to float samples.
  537. For example
  538. @example
  539. ffmpeg -i INPUT1 -i INPUT2 -i INPUT3 -filter_complex amix=inputs=3:duration=first:dropout_transition=3 OUTPUT
  540. @end example
  541. will mix 3 input audio streams to a single output with the same duration as the
  542. first input and a dropout transition time of 3 seconds.
  543. It accepts the following parameters:
  544. @table @option
  545. @item inputs
  546. The number of inputs. If unspecified, it defaults to 2.
  547. @item duration
  548. How to determine the end-of-stream.
  549. @table @option
  550. @item longest
  551. The duration of the longest input. (default)
  552. @item shortest
  553. The duration of the shortest input.
  554. @item first
  555. The duration of the first input.
  556. @end table
  557. @item dropout_transition
  558. The transition time, in seconds, for volume renormalization when an input
  559. stream ends. The default value is 2 seconds.
  560. @end table
  561. @section anull
  562. Pass the audio source unchanged to the output.
  563. @section apad
  564. Pad the end of an audio stream with silence.
  565. This can be used together with @command{ffmpeg} @option{-shortest} to
  566. extend audio streams to the same length as the video stream.
  567. A description of the accepted options follows.
  568. @table @option
  569. @item packet_size
  570. Set silence packet size. Default value is 4096.
  571. @item pad_len
  572. Set the number of samples of silence to add to the end. After the
  573. value is reached, the stream is terminated. This option is mutually
  574. exclusive with @option{whole_len}.
  575. @item whole_len
  576. Set the minimum total number of samples in the output audio stream. If
  577. the value is longer than the input audio length, silence is added to
  578. the end, until the value is reached. This option is mutually exclusive
  579. with @option{pad_len}.
  580. @end table
  581. If neither the @option{pad_len} nor the @option{whole_len} option is
  582. set, the filter will add silence to the end of the input stream
  583. indefinitely.
  584. @subsection Examples
  585. @itemize
  586. @item
  587. Add 1024 samples of silence to the end of the input:
  588. @example
  589. apad=pad_len=1024
  590. @end example
  591. @item
  592. Make sure the audio output will contain at least 10000 samples, pad
  593. the input with silence if required:
  594. @example
  595. apad=whole_len=10000
  596. @end example
  597. @item
  598. Use @command{ffmpeg} to pad the audio input with silence, so that the
  599. video stream will always result the shortest and will be converted
  600. until the end in the output file when using the @option{shortest}
  601. option:
  602. @example
  603. ffmpeg -i VIDEO -i AUDIO -filter_complex "[1:0]apad" -shortest OUTPUT
  604. @end example
  605. @end itemize
  606. @section aphaser
  607. Add a phasing effect to the input audio.
  608. A phaser filter creates series of peaks and troughs in the frequency spectrum.
  609. The position of the peaks and troughs are modulated so that they vary over time, creating a sweeping effect.
  610. A description of the accepted parameters follows.
  611. @table @option
  612. @item in_gain
  613. Set input gain. Default is 0.4.
  614. @item out_gain
  615. Set output gain. Default is 0.74
  616. @item delay
  617. Set delay in milliseconds. Default is 3.0.
  618. @item decay
  619. Set decay. Default is 0.4.
  620. @item speed
  621. Set modulation speed in Hz. Default is 0.5.
  622. @item type
  623. Set modulation type. Default is triangular.
  624. It accepts the following values:
  625. @table @samp
  626. @item triangular, t
  627. @item sinusoidal, s
  628. @end table
  629. @end table
  630. @anchor{aresample}
  631. @section aresample
  632. Resample the input audio to the specified parameters, using the
  633. libswresample library. If none are specified then the filter will
  634. automatically convert between its input and output.
  635. This filter is also able to stretch/squeeze the audio data to make it match
  636. the timestamps or to inject silence / cut out audio to make it match the
  637. timestamps, do a combination of both or do neither.
  638. The filter accepts the syntax
  639. [@var{sample_rate}:]@var{resampler_options}, where @var{sample_rate}
  640. expresses a sample rate and @var{resampler_options} is a list of
  641. @var{key}=@var{value} pairs, separated by ":". See the
  642. ffmpeg-resampler manual for the complete list of supported options.
  643. @subsection Examples
  644. @itemize
  645. @item
  646. Resample the input audio to 44100Hz:
  647. @example
  648. aresample=44100
  649. @end example
  650. @item
  651. Stretch/squeeze samples to the given timestamps, with a maximum of 1000
  652. samples per second compensation:
  653. @example
  654. aresample=async=1000
  655. @end example
  656. @end itemize
  657. @section asetnsamples
  658. Set the number of samples per each output audio frame.
  659. The last output packet may contain a different number of samples, as
  660. the filter will flush all the remaining samples when the input audio
  661. signal its end.
  662. The filter accepts the following options:
  663. @table @option
  664. @item nb_out_samples, n
  665. Set the number of frames per each output audio frame. The number is
  666. intended as the number of samples @emph{per each channel}.
  667. Default value is 1024.
  668. @item pad, p
  669. If set to 1, the filter will pad the last audio frame with zeroes, so
  670. that the last frame will contain the same number of samples as the
  671. previous ones. Default value is 1.
  672. @end table
  673. For example, to set the number of per-frame samples to 1234 and
  674. disable padding for the last frame, use:
  675. @example
  676. asetnsamples=n=1234:p=0
  677. @end example
  678. @section asetrate
  679. Set the sample rate without altering the PCM data.
  680. This will result in a change of speed and pitch.
  681. The filter accepts the following options:
  682. @table @option
  683. @item sample_rate, r
  684. Set the output sample rate. Default is 44100 Hz.
  685. @end table
  686. @section ashowinfo
  687. Show a line containing various information for each input audio frame.
  688. The input audio is not modified.
  689. The shown line contains a sequence of key/value pairs of the form
  690. @var{key}:@var{value}.
  691. The following values are shown in the output:
  692. @table @option
  693. @item n
  694. The (sequential) number of the input frame, starting from 0.
  695. @item pts
  696. The presentation timestamp of the input frame, in time base units; the time base
  697. depends on the filter input pad, and is usually 1/@var{sample_rate}.
  698. @item pts_time
  699. The presentation timestamp of the input frame in seconds.
  700. @item pos
  701. position of the frame in the input stream, -1 if this information in
  702. unavailable and/or meaningless (for example in case of synthetic audio)
  703. @item fmt
  704. The sample format.
  705. @item chlayout
  706. The channel layout.
  707. @item rate
  708. The sample rate for the audio frame.
  709. @item nb_samples
  710. The number of samples (per channel) in the frame.
  711. @item checksum
  712. The Adler-32 checksum (printed in hexadecimal) of the audio data. For planar
  713. audio, the data is treated as if all the planes were concatenated.
  714. @item plane_checksums
  715. A list of Adler-32 checksums for each data plane.
  716. @end table
  717. @anchor{astats}
  718. @section astats
  719. Display time domain statistical information about the audio channels.
  720. Statistics are calculated and displayed for each audio channel and,
  721. where applicable, an overall figure is also given.
  722. It accepts the following option:
  723. @table @option
  724. @item length
  725. Short window length in seconds, used for peak and trough RMS measurement.
  726. Default is @code{0.05} (50 milliseconds). Allowed range is @code{[0.1 - 10]}.
  727. @item metadata
  728. Set metadata injection. All the metadata keys are prefixed with @code{lavfi.astats.X},
  729. where @code{X} is channel number starting from 1 or string @code{Overall}. Default is
  730. disabled.
  731. Available keys for each channel are:
  732. DC_offset
  733. Min_level
  734. Max_level
  735. Peak_level
  736. RMS_peak
  737. RMS_trough
  738. Crest_factor
  739. Flat_factor
  740. Peak_count
  741. and for Overall:
  742. DC_offset
  743. Min_level
  744. Max_level
  745. Peak_level
  746. RMS_level
  747. RMS_peak
  748. RMS_trough
  749. Flat_factor
  750. Peak_count
  751. Number_of_samples
  752. For example full key look like this @code{lavfi.astats.1.DC_offset} or
  753. this @code{lavfi.astats.Overall.Peak_count}.
  754. For description what each key means read bellow.
  755. @end table
  756. A description of each shown parameter follows:
  757. @table @option
  758. @item DC offset
  759. Mean amplitude displacement from zero.
  760. @item Min level
  761. Minimal sample level.
  762. @item Max level
  763. Maximal sample level.
  764. @item Peak level dB
  765. @item RMS level dB
  766. Standard peak and RMS level measured in dBFS.
  767. @item RMS peak dB
  768. @item RMS trough dB
  769. Peak and trough values for RMS level measured over a short window.
  770. @item Crest factor
  771. Standard ratio of peak to RMS level (note: not in dB).
  772. @item Flat factor
  773. Flatness (i.e. consecutive samples with the same value) of the signal at its peak levels
  774. (i.e. either @var{Min level} or @var{Max level}).
  775. @item Peak count
  776. Number of occasions (not the number of samples) that the signal attained either
  777. @var{Min level} or @var{Max level}.
  778. @end table
  779. @section astreamsync
  780. Forward two audio streams and control the order the buffers are forwarded.
  781. The filter accepts the following options:
  782. @table @option
  783. @item expr, e
  784. Set the expression deciding which stream should be
  785. forwarded next: if the result is negative, the first stream is forwarded; if
  786. the result is positive or zero, the second stream is forwarded. It can use
  787. the following variables:
  788. @table @var
  789. @item b1 b2
  790. number of buffers forwarded so far on each stream
  791. @item s1 s2
  792. number of samples forwarded so far on each stream
  793. @item t1 t2
  794. current timestamp of each stream
  795. @end table
  796. The default value is @code{t1-t2}, which means to always forward the stream
  797. that has a smaller timestamp.
  798. @end table
  799. @subsection Examples
  800. Stress-test @code{amerge} by randomly sending buffers on the wrong
  801. input, while avoiding too much of a desynchronization:
  802. @example
  803. amovie=file.ogg [a] ; amovie=file.mp3 [b] ;
  804. [a] [b] astreamsync=(2*random(1))-1+tanh(5*(t1-t2)) [a2] [b2] ;
  805. [a2] [b2] amerge
  806. @end example
  807. @section asyncts
  808. Synchronize audio data with timestamps by squeezing/stretching it and/or
  809. dropping samples/adding silence when needed.
  810. This filter is not built by default, please use @ref{aresample} to do squeezing/stretching.
  811. It accepts the following parameters:
  812. @table @option
  813. @item compensate
  814. Enable stretching/squeezing the data to make it match the timestamps. Disabled
  815. by default. When disabled, time gaps are covered with silence.
  816. @item min_delta
  817. The minimum difference between timestamps and audio data (in seconds) to trigger
  818. adding/dropping samples. The default value is 0.1. If you get an imperfect
  819. sync with this filter, try setting this parameter to 0.
  820. @item max_comp
  821. The maximum compensation in samples per second. Only relevant with compensate=1.
  822. The default value is 500.
  823. @item first_pts
  824. Assume that the first PTS should be this value. The time base is 1 / sample
  825. rate. This allows for padding/trimming at the start of the stream. By default,
  826. no assumption is made about the first frame's expected PTS, so no padding or
  827. trimming is done. For example, this could be set to 0 to pad the beginning with
  828. silence if an audio stream starts after the video stream or to trim any samples
  829. with a negative PTS due to encoder delay.
  830. @end table
  831. @section atempo
  832. Adjust audio tempo.
  833. The filter accepts exactly one parameter, the audio tempo. If not
  834. specified then the filter will assume nominal 1.0 tempo. Tempo must
  835. be in the [0.5, 2.0] range.
  836. @subsection Examples
  837. @itemize
  838. @item
  839. Slow down audio to 80% tempo:
  840. @example
  841. atempo=0.8
  842. @end example
  843. @item
  844. To speed up audio to 125% tempo:
  845. @example
  846. atempo=1.25
  847. @end example
  848. @end itemize
  849. @section atrim
  850. Trim the input so that the output contains one continuous subpart of the input.
  851. It accepts the following parameters:
  852. @table @option
  853. @item start
  854. Timestamp (in seconds) of the start of the section to keep. I.e. the audio
  855. sample with the timestamp @var{start} will be the first sample in the output.
  856. @item end
  857. Specify time of the first audio sample that will be dropped, i.e. the
  858. audio sample immediately preceding the one with the timestamp @var{end} will be
  859. the last sample in the output.
  860. @item start_pts
  861. Same as @var{start}, except this option sets the start timestamp in samples
  862. instead of seconds.
  863. @item end_pts
  864. Same as @var{end}, except this option sets the end timestamp in samples instead
  865. of seconds.
  866. @item duration
  867. The maximum duration of the output in seconds.
  868. @item start_sample
  869. The number of the first sample that should be output.
  870. @item end_sample
  871. The number of the first sample that should be dropped.
  872. @end table
  873. @option{start}, @option{end}, and @option{duration} are expressed as time
  874. duration specifications; see
  875. @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}.
  876. Note that the first two sets of the start/end options and the @option{duration}
  877. option look at the frame timestamp, while the _sample options simply count the
  878. samples that pass through the filter. So start/end_pts and start/end_sample will
  879. give different results when the timestamps are wrong, inexact or do not start at
  880. zero. Also note that this filter does not modify the timestamps. If you wish
  881. to have the output timestamps start at zero, insert the asetpts filter after the
  882. atrim filter.
  883. If multiple start or end options are set, this filter tries to be greedy and
  884. keep all samples that match at least one of the specified constraints. To keep
  885. only the part that matches all the constraints at once, chain multiple atrim
  886. filters.
  887. The defaults are such that all the input is kept. So it is possible to set e.g.
  888. just the end values to keep everything before the specified time.
  889. Examples:
  890. @itemize
  891. @item
  892. Drop everything except the second minute of input:
  893. @example
  894. ffmpeg -i INPUT -af atrim=60:120
  895. @end example
  896. @item
  897. Keep only the first 1000 samples:
  898. @example
  899. ffmpeg -i INPUT -af atrim=end_sample=1000
  900. @end example
  901. @end itemize
  902. @section bandpass
  903. Apply a two-pole Butterworth band-pass filter with central
  904. frequency @var{frequency}, and (3dB-point) band-width width.
  905. The @var{csg} option selects a constant skirt gain (peak gain = Q)
  906. instead of the default: constant 0dB peak gain.
  907. The filter roll off at 6dB per octave (20dB per decade).
  908. The filter accepts the following options:
  909. @table @option
  910. @item frequency, f
  911. Set the filter's central frequency. Default is @code{3000}.
  912. @item csg
  913. Constant skirt gain if set to 1. Defaults to 0.
  914. @item width_type
  915. Set method to specify band-width of filter.
  916. @table @option
  917. @item h
  918. Hz
  919. @item q
  920. Q-Factor
  921. @item o
  922. octave
  923. @item s
  924. slope
  925. @end table
  926. @item width, w
  927. Specify the band-width of a filter in width_type units.
  928. @end table
  929. @section bandreject
  930. Apply a two-pole Butterworth band-reject filter with central
  931. frequency @var{frequency}, and (3dB-point) band-width @var{width}.
  932. The filter roll off at 6dB per octave (20dB per decade).
  933. The filter accepts the following options:
  934. @table @option
  935. @item frequency, f
  936. Set the filter's central frequency. Default is @code{3000}.
  937. @item width_type
  938. Set method to specify band-width of filter.
  939. @table @option
  940. @item h
  941. Hz
  942. @item q
  943. Q-Factor
  944. @item o
  945. octave
  946. @item s
  947. slope
  948. @end table
  949. @item width, w
  950. Specify the band-width of a filter in width_type units.
  951. @end table
  952. @section bass
  953. Boost or cut the bass (lower) frequencies of the audio using a two-pole
  954. shelving filter with a response similar to that of a standard
  955. hi-fi's tone-controls. This is also known as shelving equalisation (EQ).
  956. The filter accepts the following options:
  957. @table @option
  958. @item gain, g
  959. Give the gain at 0 Hz. Its useful range is about -20
  960. (for a large cut) to +20 (for a large boost).
  961. Beware of clipping when using a positive gain.
  962. @item frequency, f
  963. Set the filter's central frequency and so can be used
  964. to extend or reduce the frequency range to be boosted or cut.
  965. The default value is @code{100} Hz.
  966. @item width_type
  967. Set method to specify band-width of filter.
  968. @table @option
  969. @item h
  970. Hz
  971. @item q
  972. Q-Factor
  973. @item o
  974. octave
  975. @item s
  976. slope
  977. @end table
  978. @item width, w
  979. Determine how steep is the filter's shelf transition.
  980. @end table
  981. @section biquad
  982. Apply a biquad IIR filter with the given coefficients.
  983. Where @var{b0}, @var{b1}, @var{b2} and @var{a0}, @var{a1}, @var{a2}
  984. are the numerator and denominator coefficients respectively.
  985. @section bs2b
  986. Bauer stereo to binaural transformation, which improves headphone listening of
  987. stereo audio records.
  988. It accepts the following parameters:
  989. @table @option
  990. @item profile
  991. Pre-defined crossfeed level.
  992. @table @option
  993. @item default
  994. Default level (fcut=700, feed=50).
  995. @item cmoy
  996. Chu Moy circuit (fcut=700, feed=60).
  997. @item jmeier
  998. Jan Meier circuit (fcut=650, feed=95).
  999. @end table
  1000. @item fcut
  1001. Cut frequency (in Hz).
  1002. @item feed
  1003. Feed level (in Hz).
  1004. @end table
  1005. @section channelmap
  1006. Remap input channels to new locations.
  1007. It accepts the following parameters:
  1008. @table @option
  1009. @item channel_layout
  1010. The channel layout of the output stream.
  1011. @item map
  1012. Map channels from input to output. The argument is a '|'-separated list of
  1013. mappings, each in the @code{@var{in_channel}-@var{out_channel}} or
  1014. @var{in_channel} form. @var{in_channel} can be either the name of the input
  1015. channel (e.g. FL for front left) or its index in the input channel layout.
  1016. @var{out_channel} is the name of the output channel or its index in the output
  1017. channel layout. If @var{out_channel} is not given then it is implicitly an
  1018. index, starting with zero and increasing by one for each mapping.
  1019. @end table
  1020. If no mapping is present, the filter will implicitly map input channels to
  1021. output channels, preserving indices.
  1022. For example, assuming a 5.1+downmix input MOV file,
  1023. @example
  1024. ffmpeg -i in.mov -filter 'channelmap=map=DL-FL|DR-FR' out.wav
  1025. @end example
  1026. will create an output WAV file tagged as stereo from the downmix channels of
  1027. the input.
  1028. To fix a 5.1 WAV improperly encoded in AAC's native channel order
  1029. @example
  1030. ffmpeg -i in.wav -filter 'channelmap=1|2|0|5|3|4:channel_layout=5.1' out.wav
  1031. @end example
  1032. @section channelsplit
  1033. Split each channel from an input audio stream into a separate output stream.
  1034. It accepts the following parameters:
  1035. @table @option
  1036. @item channel_layout
  1037. The channel layout of the input stream. The default is "stereo".
  1038. @end table
  1039. For example, assuming a stereo input MP3 file,
  1040. @example
  1041. ffmpeg -i in.mp3 -filter_complex channelsplit out.mkv
  1042. @end example
  1043. will create an output Matroska file with two audio streams, one containing only
  1044. the left channel and the other the right channel.
  1045. Split a 5.1 WAV file into per-channel files:
  1046. @example
  1047. ffmpeg -i in.wav -filter_complex
  1048. 'channelsplit=channel_layout=5.1[FL][FR][FC][LFE][SL][SR]'
  1049. -map '[FL]' front_left.wav -map '[FR]' front_right.wav -map '[FC]'
  1050. front_center.wav -map '[LFE]' lfe.wav -map '[SL]' side_left.wav -map '[SR]'
  1051. side_right.wav
  1052. @end example
  1053. @section chorus
  1054. Add a chorus effect to the audio.
  1055. Can make a single vocal sound like a chorus, but can also be applied to instrumentation.
  1056. Chorus resembles an echo effect with a short delay, but whereas with echo the delay is
  1057. constant, with chorus, it is varied using using sinusoidal or triangular modulation.
  1058. The modulation depth defines the range the modulated delay is played before or after
  1059. the delay. Hence the delayed sound will sound slower or faster, that is the delayed
  1060. sound tuned around the original one, like in a chorus where some vocals are slightly
  1061. off key.
  1062. It accepts the following parameters:
  1063. @table @option
  1064. @item in_gain
  1065. Set input gain. Default is 0.4.
  1066. @item out_gain
  1067. Set output gain. Default is 0.4.
  1068. @item delays
  1069. Set delays. A typical delay is around 40ms to 60ms.
  1070. @item decays
  1071. Set decays.
  1072. @item speeds
  1073. Set speeds.
  1074. @item depths
  1075. Set depths.
  1076. @end table
  1077. @subsection Examples
  1078. @itemize
  1079. @item
  1080. A single delay:
  1081. @example
  1082. chorus=0.7:0.9:55:0.4:0.25:2
  1083. @end example
  1084. @item
  1085. Two delays:
  1086. @example
  1087. chorus=0.6:0.9:50|60:0.4|0.32:0.25|0.4:2|1.3
  1088. @end example
  1089. @item
  1090. Fuller sounding chorus with three delays:
  1091. @example
  1092. chorus=0.5:0.9:50|60|40:0.4|0.32|0.3:0.25|0.4|0.3:2|2.3|1.3
  1093. @end example
  1094. @end itemize
  1095. @section compand
  1096. Compress or expand the audio's dynamic range.
  1097. It accepts the following parameters:
  1098. @table @option
  1099. @item attacks
  1100. @item decays
  1101. A list of times in seconds for each channel over which the instantaneous level
  1102. of the input signal is averaged to determine its volume. @var{attacks} refers to
  1103. increase of volume and @var{decays} refers to decrease of volume. For most
  1104. situations, the attack time (response to the audio getting louder) should be
  1105. shorter than the decay time, because the human ear is more sensitive to sudden
  1106. loud audio than sudden soft audio. A typical value for attack is 0.3 seconds and
  1107. a typical value for decay is 0.8 seconds.
  1108. @item points
  1109. A list of points for the transfer function, specified in dB relative to the
  1110. maximum possible signal amplitude. Each key points list must be defined using
  1111. the following syntax: @code{x0/y0|x1/y1|x2/y2|....} or
  1112. @code{x0/y0 x1/y1 x2/y2 ....}
  1113. The input values must be in strictly increasing order but the transfer function
  1114. does not have to be monotonically rising. The point @code{0/0} is assumed but
  1115. may be overridden (by @code{0/out-dBn}). Typical values for the transfer
  1116. function are @code{-70/-70|-60/-20}.
  1117. @item soft-knee
  1118. Set the curve radius in dB for all joints. It defaults to 0.01.
  1119. @item gain
  1120. Set the additional gain in dB to be applied at all points on the transfer
  1121. function. This allows for easy adjustment of the overall gain.
  1122. It defaults to 0.
  1123. @item volume
  1124. Set an initial volume, in dB, to be assumed for each channel when filtering
  1125. starts. This permits the user to supply a nominal level initially, so that, for
  1126. example, a very large gain is not applied to initial signal levels before the
  1127. companding has begun to operate. A typical value for audio which is initially
  1128. quiet is -90 dB. It defaults to 0.
  1129. @item delay
  1130. Set a delay, in seconds. The input audio is analyzed immediately, but audio is
  1131. delayed before being fed to the volume adjuster. Specifying a delay
  1132. approximately equal to the attack/decay times allows the filter to effectively
  1133. operate in predictive rather than reactive mode. It defaults to 0.
  1134. @end table
  1135. @subsection Examples
  1136. @itemize
  1137. @item
  1138. Make music with both quiet and loud passages suitable for listening to in a
  1139. noisy environment:
  1140. @example
  1141. compand=.3|.3:1|1:-90/-60|-60/-40|-40/-30|-20/-20:6:0:-90:0.2
  1142. @end example
  1143. Another example for audio with whisper and explosion parts:
  1144. @example
  1145. compand=0|0:1|1:-90/-900|-70/-70|-30/-9|0/-3:6:0:0:0
  1146. @end example
  1147. @item
  1148. A noise gate for when the noise is at a lower level than the signal:
  1149. @example
  1150. compand=.1|.1:.2|.2:-900/-900|-50.1/-900|-50/-50:.01:0:-90:.1
  1151. @end example
  1152. @item
  1153. Here is another noise gate, this time for when the noise is at a higher level
  1154. than the signal (making it, in some ways, similar to squelch):
  1155. @example
  1156. compand=.1|.1:.1|.1:-45.1/-45.1|-45/-900|0/-900:.01:45:-90:.1
  1157. @end example
  1158. @end itemize
  1159. @section dcshift
  1160. Apply a DC shift to the audio.
  1161. This can be useful to remove a DC offset (caused perhaps by a hardware problem
  1162. in the recording chain) from the audio. The effect of a DC offset is reduced
  1163. headroom and hence volume. The @ref{astats} filter can be used to determine if
  1164. a signal has a DC offset.
  1165. @table @option
  1166. @item shift
  1167. Set the DC shift, allowed range is [-1, 1]. It indicates the amount to shift
  1168. the audio.
  1169. @item limitergain
  1170. Optional. It should have a value much less than 1 (e.g. 0.05 or 0.02) and is
  1171. used to prevent clipping.
  1172. @end table
  1173. @section earwax
  1174. Make audio easier to listen to on headphones.
  1175. This filter adds `cues' to 44.1kHz stereo (i.e. audio CD format) audio
  1176. so that when listened to on headphones the stereo image is moved from
  1177. inside your head (standard for headphones) to outside and in front of
  1178. the listener (standard for speakers).
  1179. Ported from SoX.
  1180. @section equalizer
  1181. Apply a two-pole peaking equalisation (EQ) filter. With this
  1182. filter, the signal-level at and around a selected frequency can
  1183. be increased or decreased, whilst (unlike bandpass and bandreject
  1184. filters) that at all other frequencies is unchanged.
  1185. In order to produce complex equalisation curves, this filter can
  1186. be given several times, each with a different central frequency.
  1187. The filter accepts the following options:
  1188. @table @option
  1189. @item frequency, f
  1190. Set the filter's central frequency in Hz.
  1191. @item width_type
  1192. Set method to specify band-width of filter.
  1193. @table @option
  1194. @item h
  1195. Hz
  1196. @item q
  1197. Q-Factor
  1198. @item o
  1199. octave
  1200. @item s
  1201. slope
  1202. @end table
  1203. @item width, w
  1204. Specify the band-width of a filter in width_type units.
  1205. @item gain, g
  1206. Set the required gain or attenuation in dB.
  1207. Beware of clipping when using a positive gain.
  1208. @end table
  1209. @subsection Examples
  1210. @itemize
  1211. @item
  1212. Attenuate 10 dB at 1000 Hz, with a bandwidth of 200 Hz:
  1213. @example
  1214. equalizer=f=1000:width_type=h:width=200:g=-10
  1215. @end example
  1216. @item
  1217. Apply 2 dB gain at 1000 Hz with Q 1 and attenuate 5 dB at 100 Hz with Q 2:
  1218. @example
  1219. equalizer=f=1000:width_type=q:width=1:g=2,equalizer=f=100:width_type=q:width=2:g=-5
  1220. @end example
  1221. @end itemize
  1222. @section flanger
  1223. Apply a flanging effect to the audio.
  1224. The filter accepts the following options:
  1225. @table @option
  1226. @item delay
  1227. Set base delay in milliseconds. Range from 0 to 30. Default value is 0.
  1228. @item depth
  1229. Set added swep delay in milliseconds. Range from 0 to 10. Default value is 2.
  1230. @item regen
  1231. Set percentage regeneration (delayed signal feedback). Range from -95 to 95.
  1232. Default value is 0.
  1233. @item width
  1234. Set percentage of delayed signal mixed with original. Range from 0 to 100.
  1235. Default value is 71.
  1236. @item speed
  1237. Set sweeps per second (Hz). Range from 0.1 to 10. Default value is 0.5.
  1238. @item shape
  1239. Set swept wave shape, can be @var{triangular} or @var{sinusoidal}.
  1240. Default value is @var{sinusoidal}.
  1241. @item phase
  1242. Set swept wave percentage-shift for multi channel. Range from 0 to 100.
  1243. Default value is 25.
  1244. @item interp
  1245. Set delay-line interpolation, @var{linear} or @var{quadratic}.
  1246. Default is @var{linear}.
  1247. @end table
  1248. @section highpass
  1249. Apply a high-pass filter with 3dB point frequency.
  1250. The filter can be either single-pole, or double-pole (the default).
  1251. The filter roll off at 6dB per pole per octave (20dB per pole per decade).
  1252. The filter accepts the following options:
  1253. @table @option
  1254. @item frequency, f
  1255. Set frequency in Hz. Default is 3000.
  1256. @item poles, p
  1257. Set number of poles. Default is 2.
  1258. @item width_type
  1259. Set method to specify band-width of filter.
  1260. @table @option
  1261. @item h
  1262. Hz
  1263. @item q
  1264. Q-Factor
  1265. @item o
  1266. octave
  1267. @item s
  1268. slope
  1269. @end table
  1270. @item width, w
  1271. Specify the band-width of a filter in width_type units.
  1272. Applies only to double-pole filter.
  1273. The default is 0.707q and gives a Butterworth response.
  1274. @end table
  1275. @section join
  1276. Join multiple input streams into one multi-channel stream.
  1277. It accepts the following parameters:
  1278. @table @option
  1279. @item inputs
  1280. The number of input streams. It defaults to 2.
  1281. @item channel_layout
  1282. The desired output channel layout. It defaults to stereo.
  1283. @item map
  1284. Map channels from inputs to output. The argument is a '|'-separated list of
  1285. mappings, each in the @code{@var{input_idx}.@var{in_channel}-@var{out_channel}}
  1286. form. @var{input_idx} is the 0-based index of the input stream. @var{in_channel}
  1287. can be either the name of the input channel (e.g. FL for front left) or its
  1288. index in the specified input stream. @var{out_channel} is the name of the output
  1289. channel.
  1290. @end table
  1291. The filter will attempt to guess the mappings when they are not specified
  1292. explicitly. It does so by first trying to find an unused matching input channel
  1293. and if that fails it picks the first unused input channel.
  1294. Join 3 inputs (with properly set channel layouts):
  1295. @example
  1296. ffmpeg -i INPUT1 -i INPUT2 -i INPUT3 -filter_complex join=inputs=3 OUTPUT
  1297. @end example
  1298. Build a 5.1 output from 6 single-channel streams:
  1299. @example
  1300. ffmpeg -i fl -i fr -i fc -i sl -i sr -i lfe -filter_complex
  1301. 'join=inputs=6:channel_layout=5.1:map=0.0-FL|1.0-FR|2.0-FC|3.0-SL|4.0-SR|5.0-LFE'
  1302. out
  1303. @end example
  1304. @section ladspa
  1305. Load a LADSPA (Linux Audio Developer's Simple Plugin API) plugin.
  1306. To enable compilation of this filter you need to configure FFmpeg with
  1307. @code{--enable-ladspa}.
  1308. @table @option
  1309. @item file, f
  1310. Specifies the name of LADSPA plugin library to load. If the environment
  1311. variable @env{LADSPA_PATH} is defined, the LADSPA plugin is searched in
  1312. each one of the directories specified by the colon separated list in
  1313. @env{LADSPA_PATH}, otherwise in the standard LADSPA paths, which are in
  1314. this order: @file{HOME/.ladspa/lib/}, @file{/usr/local/lib/ladspa/},
  1315. @file{/usr/lib/ladspa/}.
  1316. @item plugin, p
  1317. Specifies the plugin within the library. Some libraries contain only
  1318. one plugin, but others contain many of them. If this is not set filter
  1319. will list all available plugins within the specified library.
  1320. @item controls, c
  1321. Set the '|' separated list of controls which are zero or more floating point
  1322. values that determine the behavior of the loaded plugin (for example delay,
  1323. threshold or gain).
  1324. Controls need to be defined using the following syntax:
  1325. c0=@var{value0}|c1=@var{value1}|c2=@var{value2}|..., where
  1326. @var{valuei} is the value set on the @var{i}-th control.
  1327. If @option{controls} is set to @code{help}, all available controls and
  1328. their valid ranges are printed.
  1329. @item sample_rate, s
  1330. Specify the sample rate, default to 44100. Only used if plugin have
  1331. zero inputs.
  1332. @item nb_samples, n
  1333. Set the number of samples per channel per each output frame, default
  1334. is 1024. Only used if plugin have zero inputs.
  1335. @item duration, d
  1336. Set the minimum duration of the sourced audio. See
  1337. @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}
  1338. for the accepted syntax.
  1339. Note that the resulting duration may be greater than the specified duration,
  1340. as the generated audio is always cut at the end of a complete frame.
  1341. If not specified, or the expressed duration is negative, the audio is
  1342. supposed to be generated forever.
  1343. Only used if plugin have zero inputs.
  1344. @end table
  1345. @subsection Examples
  1346. @itemize
  1347. @item
  1348. List all available plugins within amp (LADSPA example plugin) library:
  1349. @example
  1350. ladspa=file=amp
  1351. @end example
  1352. @item
  1353. List all available controls and their valid ranges for @code{vcf_notch}
  1354. plugin from @code{VCF} library:
  1355. @example
  1356. ladspa=f=vcf:p=vcf_notch:c=help
  1357. @end example
  1358. @item
  1359. Simulate low quality audio equipment using @code{Computer Music Toolkit} (CMT)
  1360. plugin library:
  1361. @example
  1362. ladspa=file=cmt:plugin=lofi:controls=c0=22|c1=12|c2=12
  1363. @end example
  1364. @item
  1365. Add reverberation to the audio using TAP-plugins
  1366. (Tom's Audio Processing plugins):
  1367. @example
  1368. ladspa=file=tap_reverb:tap_reverb
  1369. @end example
  1370. @item
  1371. Generate white noise, with 0.2 amplitude:
  1372. @example
  1373. ladspa=file=cmt:noise_source_white:c=c0=.2
  1374. @end example
  1375. @item
  1376. Generate 20 bpm clicks using plugin @code{C* Click - Metronome} from the
  1377. @code{C* Audio Plugin Suite} (CAPS) library:
  1378. @example
  1379. ladspa=file=caps:Click:c=c1=20'
  1380. @end example
  1381. @item
  1382. Apply @code{C* Eq10X2 - Stereo 10-band equaliser} effect:
  1383. @example
  1384. ladspa=caps:Eq10X2:c=c0=-48|c9=-24|c3=12|c4=2
  1385. @end example
  1386. @end itemize
  1387. @subsection Commands
  1388. This filter supports the following commands:
  1389. @table @option
  1390. @item cN
  1391. Modify the @var{N}-th control value.
  1392. If the specified value is not valid, it is ignored and prior one is kept.
  1393. @end table
  1394. @section lowpass
  1395. Apply a low-pass filter with 3dB point frequency.
  1396. The filter can be either single-pole or double-pole (the default).
  1397. The filter roll off at 6dB per pole per octave (20dB per pole per decade).
  1398. The filter accepts the following options:
  1399. @table @option
  1400. @item frequency, f
  1401. Set frequency in Hz. Default is 500.
  1402. @item poles, p
  1403. Set number of poles. Default is 2.
  1404. @item width_type
  1405. Set method to specify band-width of filter.
  1406. @table @option
  1407. @item h
  1408. Hz
  1409. @item q
  1410. Q-Factor
  1411. @item o
  1412. octave
  1413. @item s
  1414. slope
  1415. @end table
  1416. @item width, w
  1417. Specify the band-width of a filter in width_type units.
  1418. Applies only to double-pole filter.
  1419. The default is 0.707q and gives a Butterworth response.
  1420. @end table
  1421. @section pan
  1422. Mix channels with specific gain levels. The filter accepts the output
  1423. channel layout followed by a set of channels definitions.
  1424. This filter is also designed to efficiently remap the channels of an audio
  1425. stream.
  1426. The filter accepts parameters of the form:
  1427. "@var{l}|@var{outdef}|@var{outdef}|..."
  1428. @table @option
  1429. @item l
  1430. output channel layout or number of channels
  1431. @item outdef
  1432. output channel specification, of the form:
  1433. "@var{out_name}=[@var{gain}*]@var{in_name}[+[@var{gain}*]@var{in_name}...]"
  1434. @item out_name
  1435. output channel to define, either a channel name (FL, FR, etc.) or a channel
  1436. number (c0, c1, etc.)
  1437. @item gain
  1438. multiplicative coefficient for the channel, 1 leaving the volume unchanged
  1439. @item in_name
  1440. input channel to use, see out_name for details; it is not possible to mix
  1441. named and numbered input channels
  1442. @end table
  1443. If the `=' in a channel specification is replaced by `<', then the gains for
  1444. that specification will be renormalized so that the total is 1, thus
  1445. avoiding clipping noise.
  1446. @subsection Mixing examples
  1447. For example, if you want to down-mix from stereo to mono, but with a bigger
  1448. factor for the left channel:
  1449. @example
  1450. pan=1c|c0=0.9*c0+0.1*c1
  1451. @end example
  1452. A customized down-mix to stereo that works automatically for 3-, 4-, 5- and
  1453. 7-channels surround:
  1454. @example
  1455. pan=stereo| FL < FL + 0.5*FC + 0.6*BL + 0.6*SL | FR < FR + 0.5*FC + 0.6*BR + 0.6*SR
  1456. @end example
  1457. Note that @command{ffmpeg} integrates a default down-mix (and up-mix) system
  1458. that should be preferred (see "-ac" option) unless you have very specific
  1459. needs.
  1460. @subsection Remapping examples
  1461. The channel remapping will be effective if, and only if:
  1462. @itemize
  1463. @item gain coefficients are zeroes or ones,
  1464. @item only one input per channel output,
  1465. @end itemize
  1466. If all these conditions are satisfied, the filter will notify the user ("Pure
  1467. channel mapping detected"), and use an optimized and lossless method to do the
  1468. remapping.
  1469. For example, if you have a 5.1 source and want a stereo audio stream by
  1470. dropping the extra channels:
  1471. @example
  1472. pan="stereo| c0=FL | c1=FR"
  1473. @end example
  1474. Given the same source, you can also switch front left and front right channels
  1475. and keep the input channel layout:
  1476. @example
  1477. pan="5.1| c0=c1 | c1=c0 | c2=c2 | c3=c3 | c4=c4 | c5=c5"
  1478. @end example
  1479. If the input is a stereo audio stream, you can mute the front left channel (and
  1480. still keep the stereo channel layout) with:
  1481. @example
  1482. pan="stereo|c1=c1"
  1483. @end example
  1484. Still with a stereo audio stream input, you can copy the right channel in both
  1485. front left and right:
  1486. @example
  1487. pan="stereo| c0=FR | c1=FR"
  1488. @end example
  1489. @section replaygain
  1490. ReplayGain scanner filter. This filter takes an audio stream as an input and
  1491. outputs it unchanged.
  1492. At end of filtering it displays @code{track_gain} and @code{track_peak}.
  1493. @section resample
  1494. Convert the audio sample format, sample rate and channel layout. It is
  1495. not meant to be used directly.
  1496. @section silencedetect
  1497. Detect silence in an audio stream.
  1498. This filter logs a message when it detects that the input audio volume is less
  1499. or equal to a noise tolerance value for a duration greater or equal to the
  1500. minimum detected noise duration.
  1501. The printed times and duration are expressed in seconds.
  1502. The filter accepts the following options:
  1503. @table @option
  1504. @item duration, d
  1505. Set silence duration until notification (default is 2 seconds).
  1506. @item noise, n
  1507. Set noise tolerance. Can be specified in dB (in case "dB" is appended to the
  1508. specified value) or amplitude ratio. Default is -60dB, or 0.001.
  1509. @end table
  1510. @subsection Examples
  1511. @itemize
  1512. @item
  1513. Detect 5 seconds of silence with -50dB noise tolerance:
  1514. @example
  1515. silencedetect=n=-50dB:d=5
  1516. @end example
  1517. @item
  1518. Complete example with @command{ffmpeg} to detect silence with 0.0001 noise
  1519. tolerance in @file{silence.mp3}:
  1520. @example
  1521. ffmpeg -i silence.mp3 -af silencedetect=noise=0.0001 -f null -
  1522. @end example
  1523. @end itemize
  1524. @section silenceremove
  1525. Remove silence from the beginning, middle or end of the audio.
  1526. The filter accepts the following options:
  1527. @table @option
  1528. @item start_periods
  1529. This value is used to indicate if audio should be trimmed at beginning of
  1530. the audio. A value of zero indicates no silence should be trimmed from the
  1531. beginning. When specifying a non-zero value, it trims audio up until it
  1532. finds non-silence. Normally, when trimming silence from beginning of audio
  1533. the @var{start_periods} will be @code{1} but it can be increased to higher
  1534. values to trim all audio up to specific count of non-silence periods.
  1535. Default value is @code{0}.
  1536. @item start_duration
  1537. Specify the amount of time that non-silence must be detected before it stops
  1538. trimming audio. By increasing the duration, bursts of noises can be treated
  1539. as silence and trimmed off. Default value is @code{0}.
  1540. @item start_threshold
  1541. This indicates what sample value should be treated as silence. For digital
  1542. audio, a value of @code{0} may be fine but for audio recorded from analog,
  1543. you may wish to increase the value to account for background noise.
  1544. Can be specified in dB (in case "dB" is appended to the specified value)
  1545. or amplitude ratio. Default value is @code{0}.
  1546. @item stop_periods
  1547. Set the count for trimming silence from the end of audio.
  1548. To remove silence from the middle of a file, specify a @var{stop_periods}
  1549. that is negative. This value is then treated as a positive value and is
  1550. used to indicate the effect should restart processing as specified by
  1551. @var{start_periods}, making it suitable for removing periods of silence
  1552. in the middle of the audio.
  1553. Default value is @code{0}.
  1554. @item stop_duration
  1555. Specify a duration of silence that must exist before audio is not copied any
  1556. more. By specifying a higher duration, silence that is wanted can be left in
  1557. the audio.
  1558. Default value is @code{0}.
  1559. @item stop_threshold
  1560. This is the same as @option{start_threshold} but for trimming silence from
  1561. the end of audio.
  1562. Can be specified in dB (in case "dB" is appended to the specified value)
  1563. or amplitude ratio. Default value is @code{0}.
  1564. @item leave_silence
  1565. This indicate that @var{stop_duration} length of audio should be left intact
  1566. at the beginning of each period of silence.
  1567. For example, if you want to remove long pauses between words but do not want
  1568. to remove the pauses completely. Default value is @code{0}.
  1569. @end table
  1570. @subsection Examples
  1571. @itemize
  1572. @item
  1573. The following example shows how this filter can be used to start a recording
  1574. that does not contain the delay at the start which usually occurs between
  1575. pressing the record button and the start of the performance:
  1576. @example
  1577. silenceremove=1:5:0.02
  1578. @end example
  1579. @end itemize
  1580. @section treble
  1581. Boost or cut treble (upper) frequencies of the audio using a two-pole
  1582. shelving filter with a response similar to that of a standard
  1583. hi-fi's tone-controls. This is also known as shelving equalisation (EQ).
  1584. The filter accepts the following options:
  1585. @table @option
  1586. @item gain, g
  1587. Give the gain at whichever is the lower of ~22 kHz and the
  1588. Nyquist frequency. Its useful range is about -20 (for a large cut)
  1589. to +20 (for a large boost). Beware of clipping when using a positive gain.
  1590. @item frequency, f
  1591. Set the filter's central frequency and so can be used
  1592. to extend or reduce the frequency range to be boosted or cut.
  1593. The default value is @code{3000} Hz.
  1594. @item width_type
  1595. Set method to specify band-width of filter.
  1596. @table @option
  1597. @item h
  1598. Hz
  1599. @item q
  1600. Q-Factor
  1601. @item o
  1602. octave
  1603. @item s
  1604. slope
  1605. @end table
  1606. @item width, w
  1607. Determine how steep is the filter's shelf transition.
  1608. @end table
  1609. @section volume
  1610. Adjust the input audio volume.
  1611. It accepts the following parameters:
  1612. @table @option
  1613. @item volume
  1614. Set audio volume expression.
  1615. Output values are clipped to the maximum value.
  1616. The output audio volume is given by the relation:
  1617. @example
  1618. @var{output_volume} = @var{volume} * @var{input_volume}
  1619. @end example
  1620. The default value for @var{volume} is "1.0".
  1621. @item precision
  1622. This parameter represents the mathematical precision.
  1623. It determines which input sample formats will be allowed, which affects the
  1624. precision of the volume scaling.
  1625. @table @option
  1626. @item fixed
  1627. 8-bit fixed-point; this limits input sample format to U8, S16, and S32.
  1628. @item float
  1629. 32-bit floating-point; this limits input sample format to FLT. (default)
  1630. @item double
  1631. 64-bit floating-point; this limits input sample format to DBL.
  1632. @end table
  1633. @item replaygain
  1634. Choose the behaviour on encountering ReplayGain side data in input frames.
  1635. @table @option
  1636. @item drop
  1637. Remove ReplayGain side data, ignoring its contents (the default).
  1638. @item ignore
  1639. Ignore ReplayGain side data, but leave it in the frame.
  1640. @item track
  1641. Prefer the track gain, if present.
  1642. @item album
  1643. Prefer the album gain, if present.
  1644. @end table
  1645. @item replaygain_preamp
  1646. Pre-amplification gain in dB to apply to the selected replaygain gain.
  1647. Default value for @var{replaygain_preamp} is 0.0.
  1648. @item eval
  1649. Set when the volume expression is evaluated.
  1650. It accepts the following values:
  1651. @table @samp
  1652. @item once
  1653. only evaluate expression once during the filter initialization, or
  1654. when the @samp{volume} command is sent
  1655. @item frame
  1656. evaluate expression for each incoming frame
  1657. @end table
  1658. Default value is @samp{once}.
  1659. @end table
  1660. The volume expression can contain the following parameters.
  1661. @table @option
  1662. @item n
  1663. frame number (starting at zero)
  1664. @item nb_channels
  1665. number of channels
  1666. @item nb_consumed_samples
  1667. number of samples consumed by the filter
  1668. @item nb_samples
  1669. number of samples in the current frame
  1670. @item pos
  1671. original frame position in the file
  1672. @item pts
  1673. frame PTS
  1674. @item sample_rate
  1675. sample rate
  1676. @item startpts
  1677. PTS at start of stream
  1678. @item startt
  1679. time at start of stream
  1680. @item t
  1681. frame time
  1682. @item tb
  1683. timestamp timebase
  1684. @item volume
  1685. last set volume value
  1686. @end table
  1687. Note that when @option{eval} is set to @samp{once} only the
  1688. @var{sample_rate} and @var{tb} variables are available, all other
  1689. variables will evaluate to NAN.
  1690. @subsection Commands
  1691. This filter supports the following commands:
  1692. @table @option
  1693. @item volume
  1694. Modify the volume expression.
  1695. The command accepts the same syntax of the corresponding option.
  1696. If the specified expression is not valid, it is kept at its current
  1697. value.
  1698. @item replaygain_noclip
  1699. Prevent clipping by limiting the gain applied.
  1700. Default value for @var{replaygain_noclip} is 1.
  1701. @end table
  1702. @subsection Examples
  1703. @itemize
  1704. @item
  1705. Halve the input audio volume:
  1706. @example
  1707. volume=volume=0.5
  1708. volume=volume=1/2
  1709. volume=volume=-6.0206dB
  1710. @end example
  1711. In all the above example the named key for @option{volume} can be
  1712. omitted, for example like in:
  1713. @example
  1714. volume=0.5
  1715. @end example
  1716. @item
  1717. Increase input audio power by 6 decibels using fixed-point precision:
  1718. @example
  1719. volume=volume=6dB:precision=fixed
  1720. @end example
  1721. @item
  1722. Fade volume after time 10 with an annihilation period of 5 seconds:
  1723. @example
  1724. volume='if(lt(t,10),1,max(1-(t-10)/5,0))':eval=frame
  1725. @end example
  1726. @end itemize
  1727. @section volumedetect
  1728. Detect the volume of the input video.
  1729. The filter has no parameters. The input is not modified. Statistics about
  1730. the volume will be printed in the log when the input stream end is reached.
  1731. In particular it will show the mean volume (root mean square), maximum
  1732. volume (on a per-sample basis), and the beginning of a histogram of the
  1733. registered volume values (from the maximum value to a cumulated 1/1000 of
  1734. the samples).
  1735. All volumes are in decibels relative to the maximum PCM value.
  1736. @subsection Examples
  1737. Here is an excerpt of the output:
  1738. @example
  1739. [Parsed_volumedetect_0 @ 0xa23120] mean_volume: -27 dB
  1740. [Parsed_volumedetect_0 @ 0xa23120] max_volume: -4 dB
  1741. [Parsed_volumedetect_0 @ 0xa23120] histogram_4db: 6
  1742. [Parsed_volumedetect_0 @ 0xa23120] histogram_5db: 62
  1743. [Parsed_volumedetect_0 @ 0xa23120] histogram_6db: 286
  1744. [Parsed_volumedetect_0 @ 0xa23120] histogram_7db: 1042
  1745. [Parsed_volumedetect_0 @ 0xa23120] histogram_8db: 2551
  1746. [Parsed_volumedetect_0 @ 0xa23120] histogram_9db: 4609
  1747. [Parsed_volumedetect_0 @ 0xa23120] histogram_10db: 8409
  1748. @end example
  1749. It means that:
  1750. @itemize
  1751. @item
  1752. The mean square energy is approximately -27 dB, or 10^-2.7.
  1753. @item
  1754. The largest sample is at -4 dB, or more precisely between -4 dB and -5 dB.
  1755. @item
  1756. There are 6 samples at -4 dB, 62 at -5 dB, 286 at -6 dB, etc.
  1757. @end itemize
  1758. In other words, raising the volume by +4 dB does not cause any clipping,
  1759. raising it by +5 dB causes clipping for 6 samples, etc.
  1760. @c man end AUDIO FILTERS
  1761. @chapter Audio Sources
  1762. @c man begin AUDIO SOURCES
  1763. Below is a description of the currently available audio sources.
  1764. @section abuffer
  1765. Buffer audio frames, and make them available to the filter chain.
  1766. This source is mainly intended for a programmatic use, in particular
  1767. through the interface defined in @file{libavfilter/asrc_abuffer.h}.
  1768. It accepts the following parameters:
  1769. @table @option
  1770. @item time_base
  1771. The timebase which will be used for timestamps of submitted frames. It must be
  1772. either a floating-point number or in @var{numerator}/@var{denominator} form.
  1773. @item sample_rate
  1774. The sample rate of the incoming audio buffers.
  1775. @item sample_fmt
  1776. The sample format of the incoming audio buffers.
  1777. Either a sample format name or its corresponding integer representation from
  1778. the enum AVSampleFormat in @file{libavutil/samplefmt.h}
  1779. @item channel_layout
  1780. The channel layout of the incoming audio buffers.
  1781. Either a channel layout name from channel_layout_map in
  1782. @file{libavutil/channel_layout.c} or its corresponding integer representation
  1783. from the AV_CH_LAYOUT_* macros in @file{libavutil/channel_layout.h}
  1784. @item channels
  1785. The number of channels of the incoming audio buffers.
  1786. If both @var{channels} and @var{channel_layout} are specified, then they
  1787. must be consistent.
  1788. @end table
  1789. @subsection Examples
  1790. @example
  1791. abuffer=sample_rate=44100:sample_fmt=s16p:channel_layout=stereo
  1792. @end example
  1793. will instruct the source to accept planar 16bit signed stereo at 44100Hz.
  1794. Since the sample format with name "s16p" corresponds to the number
  1795. 6 and the "stereo" channel layout corresponds to the value 0x3, this is
  1796. equivalent to:
  1797. @example
  1798. abuffer=sample_rate=44100:sample_fmt=6:channel_layout=0x3
  1799. @end example
  1800. @section aevalsrc
  1801. Generate an audio signal specified by an expression.
  1802. This source accepts in input one or more expressions (one for each
  1803. channel), which are evaluated and used to generate a corresponding
  1804. audio signal.
  1805. This source accepts the following options:
  1806. @table @option
  1807. @item exprs
  1808. Set the '|'-separated expressions list for each separate channel. In case the
  1809. @option{channel_layout} option is not specified, the selected channel layout
  1810. depends on the number of provided expressions. Otherwise the last
  1811. specified expression is applied to the remaining output channels.
  1812. @item channel_layout, c
  1813. Set the channel layout. The number of channels in the specified layout
  1814. must be equal to the number of specified expressions.
  1815. @item duration, d
  1816. Set the minimum duration of the sourced audio. See
  1817. @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}
  1818. for the accepted syntax.
  1819. Note that the resulting duration may be greater than the specified
  1820. duration, as the generated audio is always cut at the end of a
  1821. complete frame.
  1822. If not specified, or the expressed duration is negative, the audio is
  1823. supposed to be generated forever.
  1824. @item nb_samples, n
  1825. Set the number of samples per channel per each output frame,
  1826. default to 1024.
  1827. @item sample_rate, s
  1828. Specify the sample rate, default to 44100.
  1829. @end table
  1830. Each expression in @var{exprs} can contain the following constants:
  1831. @table @option
  1832. @item n
  1833. number of the evaluated sample, starting from 0
  1834. @item t
  1835. time of the evaluated sample expressed in seconds, starting from 0
  1836. @item s
  1837. sample rate
  1838. @end table
  1839. @subsection Examples
  1840. @itemize
  1841. @item
  1842. Generate silence:
  1843. @example
  1844. aevalsrc=0
  1845. @end example
  1846. @item
  1847. Generate a sin signal with frequency of 440 Hz, set sample rate to
  1848. 8000 Hz:
  1849. @example
  1850. aevalsrc="sin(440*2*PI*t):s=8000"
  1851. @end example
  1852. @item
  1853. Generate a two channels signal, specify the channel layout (Front
  1854. Center + Back Center) explicitly:
  1855. @example
  1856. aevalsrc="sin(420*2*PI*t)|cos(430*2*PI*t):c=FC|BC"
  1857. @end example
  1858. @item
  1859. Generate white noise:
  1860. @example
  1861. aevalsrc="-2+random(0)"
  1862. @end example
  1863. @item
  1864. Generate an amplitude modulated signal:
  1865. @example
  1866. aevalsrc="sin(10*2*PI*t)*sin(880*2*PI*t)"
  1867. @end example
  1868. @item
  1869. Generate 2.5 Hz binaural beats on a 360 Hz carrier:
  1870. @example
  1871. aevalsrc="0.1*sin(2*PI*(360-2.5/2)*t) | 0.1*sin(2*PI*(360+2.5/2)*t)"
  1872. @end example
  1873. @end itemize
  1874. @section anullsrc
  1875. The null audio source, return unprocessed audio frames. It is mainly useful
  1876. as a template and to be employed in analysis / debugging tools, or as
  1877. the source for filters which ignore the input data (for example the sox
  1878. synth filter).
  1879. This source accepts the following options:
  1880. @table @option
  1881. @item channel_layout, cl
  1882. Specifies the channel layout, and can be either an integer or a string
  1883. representing a channel layout. The default value of @var{channel_layout}
  1884. is "stereo".
  1885. Check the channel_layout_map definition in
  1886. @file{libavutil/channel_layout.c} for the mapping between strings and
  1887. channel layout values.
  1888. @item sample_rate, r
  1889. Specifies the sample rate, and defaults to 44100.
  1890. @item nb_samples, n
  1891. Set the number of samples per requested frames.
  1892. @end table
  1893. @subsection Examples
  1894. @itemize
  1895. @item
  1896. Set the sample rate to 48000 Hz and the channel layout to AV_CH_LAYOUT_MONO.
  1897. @example
  1898. anullsrc=r=48000:cl=4
  1899. @end example
  1900. @item
  1901. Do the same operation with a more obvious syntax:
  1902. @example
  1903. anullsrc=r=48000:cl=mono
  1904. @end example
  1905. @end itemize
  1906. All the parameters need to be explicitly defined.
  1907. @section flite
  1908. Synthesize a voice utterance using the libflite library.
  1909. To enable compilation of this filter you need to configure FFmpeg with
  1910. @code{--enable-libflite}.
  1911. Note that the flite library is not thread-safe.
  1912. The filter accepts the following options:
  1913. @table @option
  1914. @item list_voices
  1915. If set to 1, list the names of the available voices and exit
  1916. immediately. Default value is 0.
  1917. @item nb_samples, n
  1918. Set the maximum number of samples per frame. Default value is 512.
  1919. @item textfile
  1920. Set the filename containing the text to speak.
  1921. @item text
  1922. Set the text to speak.
  1923. @item voice, v
  1924. Set the voice to use for the speech synthesis. Default value is
  1925. @code{kal}. See also the @var{list_voices} option.
  1926. @end table
  1927. @subsection Examples
  1928. @itemize
  1929. @item
  1930. Read from file @file{speech.txt}, and synthesize the text using the
  1931. standard flite voice:
  1932. @example
  1933. flite=textfile=speech.txt
  1934. @end example
  1935. @item
  1936. Read the specified text selecting the @code{slt} voice:
  1937. @example
  1938. flite=text='So fare thee well, poor devil of a Sub-Sub, whose commentator I am':voice=slt
  1939. @end example
  1940. @item
  1941. Input text to ffmpeg:
  1942. @example
  1943. ffmpeg -f lavfi -i flite=text='So fare thee well, poor devil of a Sub-Sub, whose commentator I am':voice=slt
  1944. @end example
  1945. @item
  1946. Make @file{ffplay} speak the specified text, using @code{flite} and
  1947. the @code{lavfi} device:
  1948. @example
  1949. ffplay -f lavfi flite=text='No more be grieved for which that thou hast done.'
  1950. @end example
  1951. @end itemize
  1952. For more information about libflite, check:
  1953. @url{http://www.speech.cs.cmu.edu/flite/}
  1954. @section sine
  1955. Generate an audio signal made of a sine wave with amplitude 1/8.
  1956. The audio signal is bit-exact.
  1957. The filter accepts the following options:
  1958. @table @option
  1959. @item frequency, f
  1960. Set the carrier frequency. Default is 440 Hz.
  1961. @item beep_factor, b
  1962. Enable a periodic beep every second with frequency @var{beep_factor} times
  1963. the carrier frequency. Default is 0, meaning the beep is disabled.
  1964. @item sample_rate, r
  1965. Specify the sample rate, default is 44100.
  1966. @item duration, d
  1967. Specify the duration of the generated audio stream.
  1968. @item samples_per_frame
  1969. Set the number of samples per output frame, default is 1024.
  1970. @end table
  1971. @subsection Examples
  1972. @itemize
  1973. @item
  1974. Generate a simple 440 Hz sine wave:
  1975. @example
  1976. sine
  1977. @end example
  1978. @item
  1979. Generate a 220 Hz sine wave with a 880 Hz beep each second, for 5 seconds:
  1980. @example
  1981. sine=220:4:d=5
  1982. sine=f=220:b=4:d=5
  1983. sine=frequency=220:beep_factor=4:duration=5
  1984. @end example
  1985. @end itemize
  1986. @c man end AUDIO SOURCES
  1987. @chapter Audio Sinks
  1988. @c man begin AUDIO SINKS
  1989. Below is a description of the currently available audio sinks.
  1990. @section abuffersink
  1991. Buffer audio frames, and make them available to the end of filter chain.
  1992. This sink is mainly intended for programmatic use, in particular
  1993. through the interface defined in @file{libavfilter/buffersink.h}
  1994. or the options system.
  1995. It accepts a pointer to an AVABufferSinkContext structure, which
  1996. defines the incoming buffers' formats, to be passed as the opaque
  1997. parameter to @code{avfilter_init_filter} for initialization.
  1998. @section anullsink
  1999. Null audio sink; do absolutely nothing with the input audio. It is
  2000. mainly useful as a template and for use in analysis / debugging
  2001. tools.
  2002. @c man end AUDIO SINKS
  2003. @chapter Video Filters
  2004. @c man begin VIDEO FILTERS
  2005. When you configure your FFmpeg build, you can disable any of the
  2006. existing filters using @code{--disable-filters}.
  2007. The configure output will show the video filters included in your
  2008. build.
  2009. Below is a description of the currently available video filters.
  2010. @section alphaextract
  2011. Extract the alpha component from the input as a grayscale video. This
  2012. is especially useful with the @var{alphamerge} filter.
  2013. @section alphamerge
  2014. Add or replace the alpha component of the primary input with the
  2015. grayscale value of a second input. This is intended for use with
  2016. @var{alphaextract} to allow the transmission or storage of frame
  2017. sequences that have alpha in a format that doesn't support an alpha
  2018. channel.
  2019. For example, to reconstruct full frames from a normal YUV-encoded video
  2020. and a separate video created with @var{alphaextract}, you might use:
  2021. @example
  2022. movie=in_alpha.mkv [alpha]; [in][alpha] alphamerge [out]
  2023. @end example
  2024. Since this filter is designed for reconstruction, it operates on frame
  2025. sequences without considering timestamps, and terminates when either
  2026. input reaches end of stream. This will cause problems if your encoding
  2027. pipeline drops frames. If you're trying to apply an image as an
  2028. overlay to a video stream, consider the @var{overlay} filter instead.
  2029. @section ass
  2030. Same as the @ref{subtitles} filter, except that it doesn't require libavcodec
  2031. and libavformat to work. On the other hand, it is limited to ASS (Advanced
  2032. Substation Alpha) subtitles files.
  2033. This filter accepts the following option in addition to the common options from
  2034. the @ref{subtitles} filter:
  2035. @table @option
  2036. @item shaping
  2037. Set the shaping engine
  2038. Available values are:
  2039. @table @samp
  2040. @item auto
  2041. The default libass shaping engine, which is the best available.
  2042. @item simple
  2043. Fast, font-agnostic shaper that can do only substitutions
  2044. @item complex
  2045. Slower shaper using OpenType for substitutions and positioning
  2046. @end table
  2047. The default is @code{auto}.
  2048. @end table
  2049. @section bbox
  2050. Compute the bounding box for the non-black pixels in the input frame
  2051. luminance plane.
  2052. This filter computes the bounding box containing all the pixels with a
  2053. luminance value greater than the minimum allowed value.
  2054. The parameters describing the bounding box are printed on the filter
  2055. log.
  2056. The filter accepts the following option:
  2057. @table @option
  2058. @item min_val
  2059. Set the minimal luminance value. Default is @code{16}.
  2060. @end table
  2061. @section blackdetect
  2062. Detect video intervals that are (almost) completely black. Can be
  2063. useful to detect chapter transitions, commercials, or invalid
  2064. recordings. Output lines contains the time for the start, end and
  2065. duration of the detected black interval expressed in seconds.
  2066. In order to display the output lines, you need to set the loglevel at
  2067. least to the AV_LOG_INFO value.
  2068. The filter accepts the following options:
  2069. @table @option
  2070. @item black_min_duration, d
  2071. Set the minimum detected black duration expressed in seconds. It must
  2072. be a non-negative floating point number.
  2073. Default value is 2.0.
  2074. @item picture_black_ratio_th, pic_th
  2075. Set the threshold for considering a picture "black".
  2076. Express the minimum value for the ratio:
  2077. @example
  2078. @var{nb_black_pixels} / @var{nb_pixels}
  2079. @end example
  2080. for which a picture is considered black.
  2081. Default value is 0.98.
  2082. @item pixel_black_th, pix_th
  2083. Set the threshold for considering a pixel "black".
  2084. The threshold expresses the maximum pixel luminance value for which a
  2085. pixel is considered "black". The provided value is scaled according to
  2086. the following equation:
  2087. @example
  2088. @var{absolute_threshold} = @var{luminance_minimum_value} + @var{pixel_black_th} * @var{luminance_range_size}
  2089. @end example
  2090. @var{luminance_range_size} and @var{luminance_minimum_value} depend on
  2091. the input video format, the range is [0-255] for YUV full-range
  2092. formats and [16-235] for YUV non full-range formats.
  2093. Default value is 0.10.
  2094. @end table
  2095. The following example sets the maximum pixel threshold to the minimum
  2096. value, and detects only black intervals of 2 or more seconds:
  2097. @example
  2098. blackdetect=d=2:pix_th=0.00
  2099. @end example
  2100. @section blackframe
  2101. Detect frames that are (almost) completely black. Can be useful to
  2102. detect chapter transitions or commercials. Output lines consist of
  2103. the frame number of the detected frame, the percentage of blackness,
  2104. the position in the file if known or -1 and the timestamp in seconds.
  2105. In order to display the output lines, you need to set the loglevel at
  2106. least to the AV_LOG_INFO value.
  2107. It accepts the following parameters:
  2108. @table @option
  2109. @item amount
  2110. The percentage of the pixels that have to be below the threshold; it defaults to
  2111. @code{98}.
  2112. @item threshold, thresh
  2113. The threshold below which a pixel value is considered black; it defaults to
  2114. @code{32}.
  2115. @end table
  2116. @section blend, tblend
  2117. Blend two video frames into each other.
  2118. The @code{blend} filter takes two input streams and outputs one
  2119. stream, the first input is the "top" layer and second input is
  2120. "bottom" layer. Output terminates when shortest input terminates.
  2121. The @code{tblend} (time blend) filter takes two consecutive frames
  2122. from one single stream, and outputs the result obtained by blending
  2123. the new frame on top of the old frame.
  2124. A description of the accepted options follows.
  2125. @table @option
  2126. @item c0_mode
  2127. @item c1_mode
  2128. @item c2_mode
  2129. @item c3_mode
  2130. @item all_mode
  2131. Set blend mode for specific pixel component or all pixel components in case
  2132. of @var{all_mode}. Default value is @code{normal}.
  2133. Available values for component modes are:
  2134. @table @samp
  2135. @item addition
  2136. @item and
  2137. @item average
  2138. @item burn
  2139. @item darken
  2140. @item difference
  2141. @item difference128
  2142. @item divide
  2143. @item dodge
  2144. @item exclusion
  2145. @item glow
  2146. @item hardlight
  2147. @item hardmix
  2148. @item lighten
  2149. @item linearlight
  2150. @item multiply
  2151. @item negation
  2152. @item normal
  2153. @item or
  2154. @item overlay
  2155. @item phoenix
  2156. @item pinlight
  2157. @item reflect
  2158. @item screen
  2159. @item softlight
  2160. @item subtract
  2161. @item vividlight
  2162. @item xor
  2163. @end table
  2164. @item c0_opacity
  2165. @item c1_opacity
  2166. @item c2_opacity
  2167. @item c3_opacity
  2168. @item all_opacity
  2169. Set blend opacity for specific pixel component or all pixel components in case
  2170. of @var{all_opacity}. Only used in combination with pixel component blend modes.
  2171. @item c0_expr
  2172. @item c1_expr
  2173. @item c2_expr
  2174. @item c3_expr
  2175. @item all_expr
  2176. Set blend expression for specific pixel component or all pixel components in case
  2177. of @var{all_expr}. Note that related mode options will be ignored if those are set.
  2178. The expressions can use the following variables:
  2179. @table @option
  2180. @item N
  2181. The sequential number of the filtered frame, starting from @code{0}.
  2182. @item X
  2183. @item Y
  2184. the coordinates of the current sample
  2185. @item W
  2186. @item H
  2187. the width and height of currently filtered plane
  2188. @item SW
  2189. @item SH
  2190. Width and height scale depending on the currently filtered plane. It is the
  2191. ratio between the corresponding luma plane number of pixels and the current
  2192. plane ones. E.g. for YUV4:2:0 the values are @code{1,1} for the luma plane, and
  2193. @code{0.5,0.5} for chroma planes.
  2194. @item T
  2195. Time of the current frame, expressed in seconds.
  2196. @item TOP, A
  2197. Value of pixel component at current location for first video frame (top layer).
  2198. @item BOTTOM, B
  2199. Value of pixel component at current location for second video frame (bottom layer).
  2200. @end table
  2201. @item shortest
  2202. Force termination when the shortest input terminates. Default is
  2203. @code{0}. This option is only defined for the @code{blend} filter.
  2204. @item repeatlast
  2205. Continue applying the last bottom frame after the end of the stream. A value of
  2206. @code{0} disable the filter after the last frame of the bottom layer is reached.
  2207. Default is @code{1}. This option is only defined for the @code{blend} filter.
  2208. @end table
  2209. @subsection Examples
  2210. @itemize
  2211. @item
  2212. Apply transition from bottom layer to top layer in first 10 seconds:
  2213. @example
  2214. blend=all_expr='A*(if(gte(T,10),1,T/10))+B*(1-(if(gte(T,10),1,T/10)))'
  2215. @end example
  2216. @item
  2217. Apply 1x1 checkerboard effect:
  2218. @example
  2219. blend=all_expr='if(eq(mod(X,2),mod(Y,2)),A,B)'
  2220. @end example
  2221. @item
  2222. Apply uncover left effect:
  2223. @example
  2224. blend=all_expr='if(gte(N*SW+X,W),A,B)'
  2225. @end example
  2226. @item
  2227. Apply uncover down effect:
  2228. @example
  2229. blend=all_expr='if(gte(Y-N*SH,0),A,B)'
  2230. @end example
  2231. @item
  2232. Apply uncover up-left effect:
  2233. @example
  2234. blend=all_expr='if(gte(T*SH*40+Y,H)*gte((T*40*SW+X)*W/H,W),A,B)'
  2235. @end example
  2236. @item
  2237. Display differences between the current and the previous frame:
  2238. @example
  2239. tblend=all_mode=difference128
  2240. @end example
  2241. @end itemize
  2242. @section boxblur
  2243. Apply a boxblur algorithm to the input video.
  2244. It accepts the following parameters:
  2245. @table @option
  2246. @item luma_radius, lr
  2247. @item luma_power, lp
  2248. @item chroma_radius, cr
  2249. @item chroma_power, cp
  2250. @item alpha_radius, ar
  2251. @item alpha_power, ap
  2252. @end table
  2253. A description of the accepted options follows.
  2254. @table @option
  2255. @item luma_radius, lr
  2256. @item chroma_radius, cr
  2257. @item alpha_radius, ar
  2258. Set an expression for the box radius in pixels used for blurring the
  2259. corresponding input plane.
  2260. The radius value must be a non-negative number, and must not be
  2261. greater than the value of the expression @code{min(w,h)/2} for the
  2262. luma and alpha planes, and of @code{min(cw,ch)/2} for the chroma
  2263. planes.
  2264. Default value for @option{luma_radius} is "2". If not specified,
  2265. @option{chroma_radius} and @option{alpha_radius} default to the
  2266. corresponding value set for @option{luma_radius}.
  2267. The expressions can contain the following constants:
  2268. @table @option
  2269. @item w
  2270. @item h
  2271. The input width and height in pixels.
  2272. @item cw
  2273. @item ch
  2274. The input chroma image width and height in pixels.
  2275. @item hsub
  2276. @item vsub
  2277. The horizontal and vertical chroma subsample values. For example, for the
  2278. pixel format "yuv422p", @var{hsub} is 2 and @var{vsub} is 1.
  2279. @end table
  2280. @item luma_power, lp
  2281. @item chroma_power, cp
  2282. @item alpha_power, ap
  2283. Specify how many times the boxblur filter is applied to the
  2284. corresponding plane.
  2285. Default value for @option{luma_power} is 2. If not specified,
  2286. @option{chroma_power} and @option{alpha_power} default to the
  2287. corresponding value set for @option{luma_power}.
  2288. A value of 0 will disable the effect.
  2289. @end table
  2290. @subsection Examples
  2291. @itemize
  2292. @item
  2293. Apply a boxblur filter with the luma, chroma, and alpha radii
  2294. set to 2:
  2295. @example
  2296. boxblur=luma_radius=2:luma_power=1
  2297. boxblur=2:1
  2298. @end example
  2299. @item
  2300. Set the luma radius to 2, and alpha and chroma radius to 0:
  2301. @example
  2302. boxblur=2:1:cr=0:ar=0
  2303. @end example
  2304. @item
  2305. Set the luma and chroma radii to a fraction of the video dimension:
  2306. @example
  2307. boxblur=luma_radius=min(h\,w)/10:luma_power=1:chroma_radius=min(cw\,ch)/10:chroma_power=1
  2308. @end example
  2309. @end itemize
  2310. @section codecview
  2311. Visualize information exported by some codecs.
  2312. Some codecs can export information through frames using side-data or other
  2313. means. For example, some MPEG based codecs export motion vectors through the
  2314. @var{export_mvs} flag in the codec @option{flags2} option.
  2315. The filter accepts the following option:
  2316. @table @option
  2317. @item mv
  2318. Set motion vectors to visualize.
  2319. Available flags for @var{mv} are:
  2320. @table @samp
  2321. @item pf
  2322. forward predicted MVs of P-frames
  2323. @item bf
  2324. forward predicted MVs of B-frames
  2325. @item bb
  2326. backward predicted MVs of B-frames
  2327. @end table
  2328. @end table
  2329. @subsection Examples
  2330. @itemize
  2331. @item
  2332. Visualizes multi-directionals MVs from P and B-Frames using @command{ffplay}:
  2333. @example
  2334. ffplay -flags2 +export_mvs input.mpg -vf codecview=mv=pf+bf+bb
  2335. @end example
  2336. @end itemize
  2337. @section colorbalance
  2338. Modify intensity of primary colors (red, green and blue) of input frames.
  2339. The filter allows an input frame to be adjusted in the shadows, midtones or highlights
  2340. regions for the red-cyan, green-magenta or blue-yellow balance.
  2341. A positive adjustment value shifts the balance towards the primary color, a negative
  2342. value towards the complementary color.
  2343. The filter accepts the following options:
  2344. @table @option
  2345. @item rs
  2346. @item gs
  2347. @item bs
  2348. Adjust red, green and blue shadows (darkest pixels).
  2349. @item rm
  2350. @item gm
  2351. @item bm
  2352. Adjust red, green and blue midtones (medium pixels).
  2353. @item rh
  2354. @item gh
  2355. @item bh
  2356. Adjust red, green and blue highlights (brightest pixels).
  2357. Allowed ranges for options are @code{[-1.0, 1.0]}. Defaults are @code{0}.
  2358. @end table
  2359. @subsection Examples
  2360. @itemize
  2361. @item
  2362. Add red color cast to shadows:
  2363. @example
  2364. colorbalance=rs=.3
  2365. @end example
  2366. @end itemize
  2367. @section colorkey
  2368. RGB colorspace color keying.
  2369. The filter accepts the following options:
  2370. @table @option
  2371. @item color
  2372. The color which will be replaced with transparency.
  2373. @item similarity
  2374. Similarity percentage with the key color.
  2375. 0.01 matches only the exact key color, while 1.0 matches everything.
  2376. @item blend
  2377. Blend percentage.
  2378. 0.0 makes pixels either fully transparent, or not transparent at all.
  2379. Higher values result in semi-transparent pixels, with a higher transparency
  2380. the more similar the pixels color is to the key color.
  2381. @end table
  2382. @subsection Examples
  2383. @itemize
  2384. @item
  2385. Make every green pixel in the input image transparent:
  2386. @example
  2387. ffmpeg -i input.png -vf colorkey=green out.png
  2388. @end example
  2389. @item
  2390. Overlay a greenscreen-video on top of a static background image.
  2391. @example
  2392. ffmpeg -i background.png -i video.mp4 -filter_complex "[1:v]colorkey=0x3BBD1E:0.3:0.2[ckout];[0:v][ckout]overlay[out]" -map "[out]" output.flv
  2393. @end example
  2394. @end itemize
  2395. @section colorlevels
  2396. Adjust video input frames using levels.
  2397. The filter accepts the following options:
  2398. @table @option
  2399. @item rimin
  2400. @item gimin
  2401. @item bimin
  2402. @item aimin
  2403. Adjust red, green, blue and alpha input black point.
  2404. Allowed ranges for options are @code{[-1.0, 1.0]}. Defaults are @code{0}.
  2405. @item rimax
  2406. @item gimax
  2407. @item bimax
  2408. @item aimax
  2409. Adjust red, green, blue and alpha input white point.
  2410. Allowed ranges for options are @code{[-1.0, 1.0]}. Defaults are @code{1}.
  2411. Input levels are used to lighten highlights (bright tones), darken shadows
  2412. (dark tones), change the balance of bright and dark tones.
  2413. @item romin
  2414. @item gomin
  2415. @item bomin
  2416. @item aomin
  2417. Adjust red, green, blue and alpha output black point.
  2418. Allowed ranges for options are @code{[0, 1.0]}. Defaults are @code{0}.
  2419. @item romax
  2420. @item gomax
  2421. @item bomax
  2422. @item aomax
  2423. Adjust red, green, blue and alpha output white point.
  2424. Allowed ranges for options are @code{[0, 1.0]}. Defaults are @code{1}.
  2425. Output levels allows manual selection of a constrained output level range.
  2426. @end table
  2427. @subsection Examples
  2428. @itemize
  2429. @item
  2430. Make video output darker:
  2431. @example
  2432. colorlevels=rimin=0.058:gimin=0.058:bimin=0.058
  2433. @end example
  2434. @item
  2435. Increase contrast:
  2436. @example
  2437. colorlevels=rimin=0.039:gimin=0.039:bimin=0.039:rimax=0.96:gimax=0.96:bimax=0.96
  2438. @end example
  2439. @item
  2440. Make video output lighter:
  2441. @example
  2442. colorlevels=rimax=0.902:gimax=0.902:bimax=0.902
  2443. @end example
  2444. @item
  2445. Increase brightness:
  2446. @example
  2447. colorlevels=romin=0.5:gomin=0.5:bomin=0.5
  2448. @end example
  2449. @end itemize
  2450. @section colorchannelmixer
  2451. Adjust video input frames by re-mixing color channels.
  2452. This filter modifies a color channel by adding the values associated to
  2453. the other channels of the same pixels. For example if the value to
  2454. modify is red, the output value will be:
  2455. @example
  2456. @var{red}=@var{red}*@var{rr} + @var{blue}*@var{rb} + @var{green}*@var{rg} + @var{alpha}*@var{ra}
  2457. @end example
  2458. The filter accepts the following options:
  2459. @table @option
  2460. @item rr
  2461. @item rg
  2462. @item rb
  2463. @item ra
  2464. Adjust contribution of input red, green, blue and alpha channels for output red channel.
  2465. Default is @code{1} for @var{rr}, and @code{0} for @var{rg}, @var{rb} and @var{ra}.
  2466. @item gr
  2467. @item gg
  2468. @item gb
  2469. @item ga
  2470. Adjust contribution of input red, green, blue and alpha channels for output green channel.
  2471. Default is @code{1} for @var{gg}, and @code{0} for @var{gr}, @var{gb} and @var{ga}.
  2472. @item br
  2473. @item bg
  2474. @item bb
  2475. @item ba
  2476. Adjust contribution of input red, green, blue and alpha channels for output blue channel.
  2477. Default is @code{1} for @var{bb}, and @code{0} for @var{br}, @var{bg} and @var{ba}.
  2478. @item ar
  2479. @item ag
  2480. @item ab
  2481. @item aa
  2482. Adjust contribution of input red, green, blue and alpha channels for output alpha channel.
  2483. Default is @code{1} for @var{aa}, and @code{0} for @var{ar}, @var{ag} and @var{ab}.
  2484. Allowed ranges for options are @code{[-2.0, 2.0]}.
  2485. @end table
  2486. @subsection Examples
  2487. @itemize
  2488. @item
  2489. Convert source to grayscale:
  2490. @example
  2491. colorchannelmixer=.3:.4:.3:0:.3:.4:.3:0:.3:.4:.3
  2492. @end example
  2493. @item
  2494. Simulate sepia tones:
  2495. @example
  2496. colorchannelmixer=.393:.769:.189:0:.349:.686:.168:0:.272:.534:.131
  2497. @end example
  2498. @end itemize
  2499. @section colormatrix
  2500. Convert color matrix.
  2501. The filter accepts the following options:
  2502. @table @option
  2503. @item src
  2504. @item dst
  2505. Specify the source and destination color matrix. Both values must be
  2506. specified.
  2507. The accepted values are:
  2508. @table @samp
  2509. @item bt709
  2510. BT.709
  2511. @item bt601
  2512. BT.601
  2513. @item smpte240m
  2514. SMPTE-240M
  2515. @item fcc
  2516. FCC
  2517. @end table
  2518. @end table
  2519. For example to convert from BT.601 to SMPTE-240M, use the command:
  2520. @example
  2521. colormatrix=bt601:smpte240m
  2522. @end example
  2523. @section copy
  2524. Copy the input source unchanged to the output. This is mainly useful for
  2525. testing purposes.
  2526. @section crop
  2527. Crop the input video to given dimensions.
  2528. It accepts the following parameters:
  2529. @table @option
  2530. @item w, out_w
  2531. The width of the output video. It defaults to @code{iw}.
  2532. This expression is evaluated only once during the filter
  2533. configuration.
  2534. @item h, out_h
  2535. The height of the output video. It defaults to @code{ih}.
  2536. This expression is evaluated only once during the filter
  2537. configuration.
  2538. @item x
  2539. The horizontal position, in the input video, of the left edge of the output
  2540. video. It defaults to @code{(in_w-out_w)/2}.
  2541. This expression is evaluated per-frame.
  2542. @item y
  2543. The vertical position, in the input video, of the top edge of the output video.
  2544. It defaults to @code{(in_h-out_h)/2}.
  2545. This expression is evaluated per-frame.
  2546. @item keep_aspect
  2547. If set to 1 will force the output display aspect ratio
  2548. to be the same of the input, by changing the output sample aspect
  2549. ratio. It defaults to 0.
  2550. @end table
  2551. The @var{out_w}, @var{out_h}, @var{x}, @var{y} parameters are
  2552. expressions containing the following constants:
  2553. @table @option
  2554. @item x
  2555. @item y
  2556. The computed values for @var{x} and @var{y}. They are evaluated for
  2557. each new frame.
  2558. @item in_w
  2559. @item in_h
  2560. The input width and height.
  2561. @item iw
  2562. @item ih
  2563. These are the same as @var{in_w} and @var{in_h}.
  2564. @item out_w
  2565. @item out_h
  2566. The output (cropped) width and height.
  2567. @item ow
  2568. @item oh
  2569. These are the same as @var{out_w} and @var{out_h}.
  2570. @item a
  2571. same as @var{iw} / @var{ih}
  2572. @item sar
  2573. input sample aspect ratio
  2574. @item dar
  2575. input display aspect ratio, it is the same as (@var{iw} / @var{ih}) * @var{sar}
  2576. @item hsub
  2577. @item vsub
  2578. horizontal and vertical chroma subsample values. For example for the
  2579. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  2580. @item n
  2581. The number of the input frame, starting from 0.
  2582. @item pos
  2583. the position in the file of the input frame, NAN if unknown
  2584. @item t
  2585. The timestamp expressed in seconds. It's NAN if the input timestamp is unknown.
  2586. @end table
  2587. The expression for @var{out_w} may depend on the value of @var{out_h},
  2588. and the expression for @var{out_h} may depend on @var{out_w}, but they
  2589. cannot depend on @var{x} and @var{y}, as @var{x} and @var{y} are
  2590. evaluated after @var{out_w} and @var{out_h}.
  2591. The @var{x} and @var{y} parameters specify the expressions for the
  2592. position of the top-left corner of the output (non-cropped) area. They
  2593. are evaluated for each frame. If the evaluated value is not valid, it
  2594. is approximated to the nearest valid value.
  2595. The expression for @var{x} may depend on @var{y}, and the expression
  2596. for @var{y} may depend on @var{x}.
  2597. @subsection Examples
  2598. @itemize
  2599. @item
  2600. Crop area with size 100x100 at position (12,34).
  2601. @example
  2602. crop=100:100:12:34
  2603. @end example
  2604. Using named options, the example above becomes:
  2605. @example
  2606. crop=w=100:h=100:x=12:y=34
  2607. @end example
  2608. @item
  2609. Crop the central input area with size 100x100:
  2610. @example
  2611. crop=100:100
  2612. @end example
  2613. @item
  2614. Crop the central input area with size 2/3 of the input video:
  2615. @example
  2616. crop=2/3*in_w:2/3*in_h
  2617. @end example
  2618. @item
  2619. Crop the input video central square:
  2620. @example
  2621. crop=out_w=in_h
  2622. crop=in_h
  2623. @end example
  2624. @item
  2625. Delimit the rectangle with the top-left corner placed at position
  2626. 100:100 and the right-bottom corner corresponding to the right-bottom
  2627. corner of the input image.
  2628. @example
  2629. crop=in_w-100:in_h-100:100:100
  2630. @end example
  2631. @item
  2632. Crop 10 pixels from the left and right borders, and 20 pixels from
  2633. the top and bottom borders
  2634. @example
  2635. crop=in_w-2*10:in_h-2*20
  2636. @end example
  2637. @item
  2638. Keep only the bottom right quarter of the input image:
  2639. @example
  2640. crop=in_w/2:in_h/2:in_w/2:in_h/2
  2641. @end example
  2642. @item
  2643. Crop height for getting Greek harmony:
  2644. @example
  2645. crop=in_w:1/PHI*in_w
  2646. @end example
  2647. @item
  2648. Apply trembling effect:
  2649. @example
  2650. 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)
  2651. @end example
  2652. @item
  2653. Apply erratic camera effect depending on timestamp:
  2654. @example
  2655. 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)"
  2656. @end example
  2657. @item
  2658. Set x depending on the value of y:
  2659. @example
  2660. crop=in_w/2:in_h/2:y:10+10*sin(n/10)
  2661. @end example
  2662. @end itemize
  2663. @section cropdetect
  2664. Auto-detect the crop size.
  2665. It calculates the necessary cropping parameters and prints the
  2666. recommended parameters via the logging system. The detected dimensions
  2667. correspond to the non-black area of the input video.
  2668. It accepts the following parameters:
  2669. @table @option
  2670. @item limit
  2671. Set higher black value threshold, which can be optionally specified
  2672. from nothing (0) to everything (255 for 8bit based formats). An intensity
  2673. value greater to the set value is considered non-black. It defaults to 24.
  2674. You can also specify a value between 0.0 and 1.0 which will be scaled depending
  2675. on the bitdepth of the pixel format.
  2676. @item round
  2677. The value which the width/height should be divisible by. It defaults to
  2678. 16. The offset is automatically adjusted to center the video. Use 2 to
  2679. get only even dimensions (needed for 4:2:2 video). 16 is best when
  2680. encoding to most video codecs.
  2681. @item reset_count, reset
  2682. Set the counter that determines after how many frames cropdetect will
  2683. reset the previously detected largest video area and start over to
  2684. detect the current optimal crop area. Default value is 0.
  2685. This can be useful when channel logos distort the video area. 0
  2686. indicates 'never reset', and returns the largest area encountered during
  2687. playback.
  2688. @end table
  2689. @anchor{curves}
  2690. @section curves
  2691. Apply color adjustments using curves.
  2692. This filter is similar to the Adobe Photoshop and GIMP curves tools. Each
  2693. component (red, green and blue) has its values defined by @var{N} key points
  2694. tied from each other using a smooth curve. The x-axis represents the pixel
  2695. values from the input frame, and the y-axis the new pixel values to be set for
  2696. the output frame.
  2697. By default, a component curve is defined by the two points @var{(0;0)} and
  2698. @var{(1;1)}. This creates a straight line where each original pixel value is
  2699. "adjusted" to its own value, which means no change to the image.
  2700. The filter allows you to redefine these two points and add some more. A new
  2701. curve (using a natural cubic spline interpolation) will be define to pass
  2702. smoothly through all these new coordinates. The new defined points needs to be
  2703. strictly increasing over the x-axis, and their @var{x} and @var{y} values must
  2704. be in the @var{[0;1]} interval. If the computed curves happened to go outside
  2705. the vector spaces, the values will be clipped accordingly.
  2706. If there is no key point defined in @code{x=0}, the filter will automatically
  2707. insert a @var{(0;0)} point. In the same way, if there is no key point defined
  2708. in @code{x=1}, the filter will automatically insert a @var{(1;1)} point.
  2709. The filter accepts the following options:
  2710. @table @option
  2711. @item preset
  2712. Select one of the available color presets. This option can be used in addition
  2713. to the @option{r}, @option{g}, @option{b} parameters; in this case, the later
  2714. options takes priority on the preset values.
  2715. Available presets are:
  2716. @table @samp
  2717. @item none
  2718. @item color_negative
  2719. @item cross_process
  2720. @item darker
  2721. @item increase_contrast
  2722. @item lighter
  2723. @item linear_contrast
  2724. @item medium_contrast
  2725. @item negative
  2726. @item strong_contrast
  2727. @item vintage
  2728. @end table
  2729. Default is @code{none}.
  2730. @item master, m
  2731. Set the master key points. These points will define a second pass mapping. It
  2732. is sometimes called a "luminance" or "value" mapping. It can be used with
  2733. @option{r}, @option{g}, @option{b} or @option{all} since it acts like a
  2734. post-processing LUT.
  2735. @item red, r
  2736. Set the key points for the red component.
  2737. @item green, g
  2738. Set the key points for the green component.
  2739. @item blue, b
  2740. Set the key points for the blue component.
  2741. @item all
  2742. Set the key points for all components (not including master).
  2743. Can be used in addition to the other key points component
  2744. options. In this case, the unset component(s) will fallback on this
  2745. @option{all} setting.
  2746. @item psfile
  2747. Specify a Photoshop curves file (@code{.asv}) to import the settings from.
  2748. @end table
  2749. To avoid some filtergraph syntax conflicts, each key points list need to be
  2750. defined using the following syntax: @code{x0/y0 x1/y1 x2/y2 ...}.
  2751. @subsection Examples
  2752. @itemize
  2753. @item
  2754. Increase slightly the middle level of blue:
  2755. @example
  2756. curves=blue='0.5/0.58'
  2757. @end example
  2758. @item
  2759. Vintage effect:
  2760. @example
  2761. curves=r='0/0.11 .42/.51 1/0.95':g='0.50/0.48':b='0/0.22 .49/.44 1/0.8'
  2762. @end example
  2763. Here we obtain the following coordinates for each components:
  2764. @table @var
  2765. @item red
  2766. @code{(0;0.11) (0.42;0.51) (1;0.95)}
  2767. @item green
  2768. @code{(0;0) (0.50;0.48) (1;1)}
  2769. @item blue
  2770. @code{(0;0.22) (0.49;0.44) (1;0.80)}
  2771. @end table
  2772. @item
  2773. The previous example can also be achieved with the associated built-in preset:
  2774. @example
  2775. curves=preset=vintage
  2776. @end example
  2777. @item
  2778. Or simply:
  2779. @example
  2780. curves=vintage
  2781. @end example
  2782. @item
  2783. Use a Photoshop preset and redefine the points of the green component:
  2784. @example
  2785. curves=psfile='MyCurvesPresets/purple.asv':green='0.45/0.53'
  2786. @end example
  2787. @end itemize
  2788. @section dctdnoiz
  2789. Denoise frames using 2D DCT (frequency domain filtering).
  2790. This filter is not designed for real time.
  2791. The filter accepts the following options:
  2792. @table @option
  2793. @item sigma, s
  2794. Set the noise sigma constant.
  2795. This @var{sigma} defines a hard threshold of @code{3 * sigma}; every DCT
  2796. coefficient (absolute value) below this threshold with be dropped.
  2797. If you need a more advanced filtering, see @option{expr}.
  2798. Default is @code{0}.
  2799. @item overlap
  2800. Set number overlapping pixels for each block. Since the filter can be slow, you
  2801. may want to reduce this value, at the cost of a less effective filter and the
  2802. risk of various artefacts.
  2803. If the overlapping value doesn't permit processing the whole input width or
  2804. height, a warning will be displayed and according borders won't be denoised.
  2805. Default value is @var{blocksize}-1, which is the best possible setting.
  2806. @item expr, e
  2807. Set the coefficient factor expression.
  2808. For each coefficient of a DCT block, this expression will be evaluated as a
  2809. multiplier value for the coefficient.
  2810. If this is option is set, the @option{sigma} option will be ignored.
  2811. The absolute value of the coefficient can be accessed through the @var{c}
  2812. variable.
  2813. @item n
  2814. Set the @var{blocksize} using the number of bits. @code{1<<@var{n}} defines the
  2815. @var{blocksize}, which is the width and height of the processed blocks.
  2816. The default value is @var{3} (8x8) and can be raised to @var{4} for a
  2817. @var{blocksize} of 16x16. Note that changing this setting has huge consequences
  2818. on the speed processing. Also, a larger block size does not necessarily means a
  2819. better de-noising.
  2820. @end table
  2821. @subsection Examples
  2822. Apply a denoise with a @option{sigma} of @code{4.5}:
  2823. @example
  2824. dctdnoiz=4.5
  2825. @end example
  2826. The same operation can be achieved using the expression system:
  2827. @example
  2828. dctdnoiz=e='gte(c, 4.5*3)'
  2829. @end example
  2830. Violent denoise using a block size of @code{16x16}:
  2831. @example
  2832. dctdnoiz=15:n=4
  2833. @end example
  2834. @anchor{decimate}
  2835. @section decimate
  2836. Drop duplicated frames at regular intervals.
  2837. The filter accepts the following options:
  2838. @table @option
  2839. @item cycle
  2840. Set the number of frames from which one will be dropped. Setting this to
  2841. @var{N} means one frame in every batch of @var{N} frames will be dropped.
  2842. Default is @code{5}.
  2843. @item dupthresh
  2844. Set the threshold for duplicate detection. If the difference metric for a frame
  2845. is less than or equal to this value, then it is declared as duplicate. Default
  2846. is @code{1.1}
  2847. @item scthresh
  2848. Set scene change threshold. Default is @code{15}.
  2849. @item blockx
  2850. @item blocky
  2851. Set the size of the x and y-axis blocks used during metric calculations.
  2852. Larger blocks give better noise suppression, but also give worse detection of
  2853. small movements. Must be a power of two. Default is @code{32}.
  2854. @item ppsrc
  2855. Mark main input as a pre-processed input and activate clean source input
  2856. stream. This allows the input to be pre-processed with various filters to help
  2857. the metrics calculation while keeping the frame selection lossless. When set to
  2858. @code{1}, the first stream is for the pre-processed input, and the second
  2859. stream is the clean source from where the kept frames are chosen. Default is
  2860. @code{0}.
  2861. @item chroma
  2862. Set whether or not chroma is considered in the metric calculations. Default is
  2863. @code{1}.
  2864. @end table
  2865. @section dejudder
  2866. Remove judder produced by partially interlaced telecined content.
  2867. Judder can be introduced, for instance, by @ref{pullup} filter. If the original
  2868. source was partially telecined content then the output of @code{pullup,dejudder}
  2869. will have a variable frame rate. May change the recorded frame rate of the
  2870. container. Aside from that change, this filter will not affect constant frame
  2871. rate video.
  2872. The option available in this filter is:
  2873. @table @option
  2874. @item cycle
  2875. Specify the length of the window over which the judder repeats.
  2876. Accepts any integer greater than 1. Useful values are:
  2877. @table @samp
  2878. @item 4
  2879. If the original was telecined from 24 to 30 fps (Film to NTSC).
  2880. @item 5
  2881. If the original was telecined from 25 to 30 fps (PAL to NTSC).
  2882. @item 20
  2883. If a mixture of the two.
  2884. @end table
  2885. The default is @samp{4}.
  2886. @end table
  2887. @section delogo
  2888. Suppress a TV station logo by a simple interpolation of the surrounding
  2889. pixels. Just set a rectangle covering the logo and watch it disappear
  2890. (and sometimes something even uglier appear - your mileage may vary).
  2891. It accepts the following parameters:
  2892. @table @option
  2893. @item x
  2894. @item y
  2895. Specify the top left corner coordinates of the logo. They must be
  2896. specified.
  2897. @item w
  2898. @item h
  2899. Specify the width and height of the logo to clear. They must be
  2900. specified.
  2901. @item band, t
  2902. Specify the thickness of the fuzzy edge of the rectangle (added to
  2903. @var{w} and @var{h}). The default value is 4.
  2904. @item show
  2905. When set to 1, a green rectangle is drawn on the screen to simplify
  2906. finding the right @var{x}, @var{y}, @var{w}, and @var{h} parameters.
  2907. The default value is 0.
  2908. The rectangle is drawn on the outermost pixels which will be (partly)
  2909. replaced with interpolated values. The values of the next pixels
  2910. immediately outside this rectangle in each direction will be used to
  2911. compute the interpolated pixel values inside the rectangle.
  2912. @end table
  2913. @subsection Examples
  2914. @itemize
  2915. @item
  2916. Set a rectangle covering the area with top left corner coordinates 0,0
  2917. and size 100x77, and a band of size 10:
  2918. @example
  2919. delogo=x=0:y=0:w=100:h=77:band=10
  2920. @end example
  2921. @end itemize
  2922. @section deshake
  2923. Attempt to fix small changes in horizontal and/or vertical shift. This
  2924. filter helps remove camera shake from hand-holding a camera, bumping a
  2925. tripod, moving on a vehicle, etc.
  2926. The filter accepts the following options:
  2927. @table @option
  2928. @item x
  2929. @item y
  2930. @item w
  2931. @item h
  2932. Specify a rectangular area where to limit the search for motion
  2933. vectors.
  2934. If desired the search for motion vectors can be limited to a
  2935. rectangular area of the frame defined by its top left corner, width
  2936. and height. These parameters have the same meaning as the drawbox
  2937. filter which can be used to visualise the position of the bounding
  2938. box.
  2939. This is useful when simultaneous movement of subjects within the frame
  2940. might be confused for camera motion by the motion vector search.
  2941. If any or all of @var{x}, @var{y}, @var{w} and @var{h} are set to -1
  2942. then the full frame is used. This allows later options to be set
  2943. without specifying the bounding box for the motion vector search.
  2944. Default - search the whole frame.
  2945. @item rx
  2946. @item ry
  2947. Specify the maximum extent of movement in x and y directions in the
  2948. range 0-64 pixels. Default 16.
  2949. @item edge
  2950. Specify how to generate pixels to fill blanks at the edge of the
  2951. frame. Available values are:
  2952. @table @samp
  2953. @item blank, 0
  2954. Fill zeroes at blank locations
  2955. @item original, 1
  2956. Original image at blank locations
  2957. @item clamp, 2
  2958. Extruded edge value at blank locations
  2959. @item mirror, 3
  2960. Mirrored edge at blank locations
  2961. @end table
  2962. Default value is @samp{mirror}.
  2963. @item blocksize
  2964. Specify the blocksize to use for motion search. Range 4-128 pixels,
  2965. default 8.
  2966. @item contrast
  2967. Specify the contrast threshold for blocks. Only blocks with more than
  2968. the specified contrast (difference between darkest and lightest
  2969. pixels) will be considered. Range 1-255, default 125.
  2970. @item search
  2971. Specify the search strategy. Available values are:
  2972. @table @samp
  2973. @item exhaustive, 0
  2974. Set exhaustive search
  2975. @item less, 1
  2976. Set less exhaustive search.
  2977. @end table
  2978. Default value is @samp{exhaustive}.
  2979. @item filename
  2980. If set then a detailed log of the motion search is written to the
  2981. specified file.
  2982. @item opencl
  2983. If set to 1, specify using OpenCL capabilities, only available if
  2984. FFmpeg was configured with @code{--enable-opencl}. Default value is 0.
  2985. @end table
  2986. @section detelecine
  2987. Apply an exact inverse of the telecine operation. It requires a predefined
  2988. pattern specified using the pattern option which must be the same as that passed
  2989. to the telecine filter.
  2990. This filter accepts the following options:
  2991. @table @option
  2992. @item first_field
  2993. @table @samp
  2994. @item top, t
  2995. top field first
  2996. @item bottom, b
  2997. bottom field first
  2998. The default value is @code{top}.
  2999. @end table
  3000. @item pattern
  3001. A string of numbers representing the pulldown pattern you wish to apply.
  3002. The default value is @code{23}.
  3003. @item start_frame
  3004. A number representing position of the first frame with respect to the telecine
  3005. pattern. This is to be used if the stream is cut. The default value is @code{0}.
  3006. @end table
  3007. @section drawbox
  3008. Draw a colored box on the input image.
  3009. It accepts the following parameters:
  3010. @table @option
  3011. @item x
  3012. @item y
  3013. The expressions which specify the top left corner coordinates of the box. It defaults to 0.
  3014. @item width, w
  3015. @item height, h
  3016. The expressions which specify the width and height of the box; if 0 they are interpreted as
  3017. the input width and height. It defaults to 0.
  3018. @item color, c
  3019. Specify the color of the box to write. For the general syntax of this option,
  3020. check the "Color" section in the ffmpeg-utils manual. If the special
  3021. value @code{invert} is used, the box edge color is the same as the
  3022. video with inverted luma.
  3023. @item thickness, t
  3024. The expression which sets the thickness of the box edge. Default value is @code{3}.
  3025. See below for the list of accepted constants.
  3026. @end table
  3027. The parameters for @var{x}, @var{y}, @var{w} and @var{h} and @var{t} are expressions containing the
  3028. following constants:
  3029. @table @option
  3030. @item dar
  3031. The input display aspect ratio, it is the same as (@var{w} / @var{h}) * @var{sar}.
  3032. @item hsub
  3033. @item vsub
  3034. horizontal and vertical chroma subsample values. For example for the
  3035. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  3036. @item in_h, ih
  3037. @item in_w, iw
  3038. The input width and height.
  3039. @item sar
  3040. The input sample aspect ratio.
  3041. @item x
  3042. @item y
  3043. The x and y offset coordinates where the box is drawn.
  3044. @item w
  3045. @item h
  3046. The width and height of the drawn box.
  3047. @item t
  3048. The thickness of the drawn box.
  3049. These constants allow the @var{x}, @var{y}, @var{w}, @var{h} and @var{t} expressions to refer to
  3050. each other, so you may for example specify @code{y=x/dar} or @code{h=w/dar}.
  3051. @end table
  3052. @subsection Examples
  3053. @itemize
  3054. @item
  3055. Draw a black box around the edge of the input image:
  3056. @example
  3057. drawbox
  3058. @end example
  3059. @item
  3060. Draw a box with color red and an opacity of 50%:
  3061. @example
  3062. drawbox=10:20:200:60:red@@0.5
  3063. @end example
  3064. The previous example can be specified as:
  3065. @example
  3066. drawbox=x=10:y=20:w=200:h=60:color=red@@0.5
  3067. @end example
  3068. @item
  3069. Fill the box with pink color:
  3070. @example
  3071. drawbox=x=10:y=10:w=100:h=100:color=pink@@0.5:t=max
  3072. @end example
  3073. @item
  3074. Draw a 2-pixel red 2.40:1 mask:
  3075. @example
  3076. drawbox=x=-t:y=0.5*(ih-iw/2.4)-t:w=iw+t*2:h=iw/2.4+t*2:t=2:c=red
  3077. @end example
  3078. @end itemize
  3079. @section drawgraph, adrawgraph
  3080. Draw a graph using input video or audio metadata.
  3081. It accepts the following parameters:
  3082. @table @option
  3083. @item m1
  3084. Set 1st frame metadata key from which metadata values will be used to draw a graph.
  3085. @item fg1
  3086. Set 1st foreground color expression.
  3087. @item m2
  3088. Set 2nd frame metadata key from which metadata values will be used to draw a graph.
  3089. @item fg2
  3090. Set 2nd foreground color expression.
  3091. @item m3
  3092. Set 3rd frame metadata key from which metadata values will be used to draw a graph.
  3093. @item fg3
  3094. Set 3rd foreground color expression.
  3095. @item m4
  3096. Set 4th frame metadata key from which metadata values will be used to draw a graph.
  3097. @item fg4
  3098. Set 4th foreground color expression.
  3099. @item min
  3100. Set minimal value of metadata value.
  3101. @item max
  3102. Set maximal value of metadata value.
  3103. @item bg
  3104. Set graph background color. Default is white.
  3105. @item mode
  3106. Set graph mode.
  3107. Available values for mode is:
  3108. @table @samp
  3109. @item bar
  3110. @item dot
  3111. @item line
  3112. @end table
  3113. Default is @code{line}.
  3114. @item slide
  3115. Set slide mode.
  3116. Available values for slide is:
  3117. @table @samp
  3118. @item frame
  3119. Draw new frame when right border is reached.
  3120. @item replace
  3121. Replace old columns with new ones.
  3122. @item scroll
  3123. Scroll from right to left.
  3124. @end table
  3125. Default is @code{frame}.
  3126. @item size
  3127. Set size of graph video. For the syntax of this option, check the
  3128. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  3129. The default value is @code{900x256}.
  3130. The foreground color expressions can use the following variables:
  3131. @table @option
  3132. @item MIN
  3133. Minimal value of metadata value.
  3134. @item MAX
  3135. Maximal value of metadata value.
  3136. @item VAL
  3137. Current metadata key value.
  3138. @end table
  3139. The color is defined as 0xAABBGGRR.
  3140. @end table
  3141. Example using metadata from @ref{signalstats} filter:
  3142. @example
  3143. signalstats,drawgraph=lavfi.signalstats.YAVG:min=0:max=255
  3144. @end example
  3145. Example using metadata from @ref{ebur128} filter:
  3146. @example
  3147. ebur128=metadata=1,adrawgraph=lavfi.r128.M:min=-120:max=5
  3148. @end example
  3149. @section drawgrid
  3150. Draw a grid on the input image.
  3151. It accepts the following parameters:
  3152. @table @option
  3153. @item x
  3154. @item y
  3155. The expressions which specify the coordinates of some point of grid intersection (meant to configure offset). Both default to 0.
  3156. @item width, w
  3157. @item height, h
  3158. The expressions which specify the width and height of the grid cell, if 0 they are interpreted as the
  3159. input width and height, respectively, minus @code{thickness}, so image gets
  3160. framed. Default to 0.
  3161. @item color, c
  3162. Specify the color of the grid. For the general syntax of this option,
  3163. check the "Color" section in the ffmpeg-utils manual. If the special
  3164. value @code{invert} is used, the grid color is the same as the
  3165. video with inverted luma.
  3166. @item thickness, t
  3167. The expression which sets the thickness of the grid line. Default value is @code{1}.
  3168. See below for the list of accepted constants.
  3169. @end table
  3170. The parameters for @var{x}, @var{y}, @var{w} and @var{h} and @var{t} are expressions containing the
  3171. following constants:
  3172. @table @option
  3173. @item dar
  3174. The input display aspect ratio, it is the same as (@var{w} / @var{h}) * @var{sar}.
  3175. @item hsub
  3176. @item vsub
  3177. horizontal and vertical chroma subsample values. For example for the
  3178. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  3179. @item in_h, ih
  3180. @item in_w, iw
  3181. The input grid cell width and height.
  3182. @item sar
  3183. The input sample aspect ratio.
  3184. @item x
  3185. @item y
  3186. The x and y coordinates of some point of grid intersection (meant to configure offset).
  3187. @item w
  3188. @item h
  3189. The width and height of the drawn cell.
  3190. @item t
  3191. The thickness of the drawn cell.
  3192. These constants allow the @var{x}, @var{y}, @var{w}, @var{h} and @var{t} expressions to refer to
  3193. each other, so you may for example specify @code{y=x/dar} or @code{h=w/dar}.
  3194. @end table
  3195. @subsection Examples
  3196. @itemize
  3197. @item
  3198. Draw a grid with cell 100x100 pixels, thickness 2 pixels, with color red and an opacity of 50%:
  3199. @example
  3200. drawgrid=width=100:height=100:thickness=2:color=red@@0.5
  3201. @end example
  3202. @item
  3203. Draw a white 3x3 grid with an opacity of 50%:
  3204. @example
  3205. drawgrid=w=iw/3:h=ih/3:t=2:c=white@@0.5
  3206. @end example
  3207. @end itemize
  3208. @anchor{drawtext}
  3209. @section drawtext
  3210. Draw a text string or text from a specified file on top of a video, using the
  3211. libfreetype library.
  3212. To enable compilation of this filter, you need to configure FFmpeg with
  3213. @code{--enable-libfreetype}.
  3214. To enable default font fallback and the @var{font} option you need to
  3215. configure FFmpeg with @code{--enable-libfontconfig}.
  3216. To enable the @var{text_shaping} option, you need to configure FFmpeg with
  3217. @code{--enable-libfribidi}.
  3218. @subsection Syntax
  3219. It accepts the following parameters:
  3220. @table @option
  3221. @item box
  3222. Used to draw a box around text using the background color.
  3223. The value must be either 1 (enable) or 0 (disable).
  3224. The default value of @var{box} is 0.
  3225. @item boxborderw
  3226. Set the width of the border to be drawn around the box using @var{boxcolor}.
  3227. The default value of @var{boxborderw} is 0.
  3228. @item boxcolor
  3229. The color to be used for drawing box around text. For the syntax of this
  3230. option, check the "Color" section in the ffmpeg-utils manual.
  3231. The default value of @var{boxcolor} is "white".
  3232. @item borderw
  3233. Set the width of the border to be drawn around the text using @var{bordercolor}.
  3234. The default value of @var{borderw} is 0.
  3235. @item bordercolor
  3236. Set the color to be used for drawing border around text. For the syntax of this
  3237. option, check the "Color" section in the ffmpeg-utils manual.
  3238. The default value of @var{bordercolor} is "black".
  3239. @item expansion
  3240. Select how the @var{text} is expanded. Can be either @code{none},
  3241. @code{strftime} (deprecated) or
  3242. @code{normal} (default). See the @ref{drawtext_expansion, Text expansion} section
  3243. below for details.
  3244. @item fix_bounds
  3245. If true, check and fix text coords to avoid clipping.
  3246. @item fontcolor
  3247. The color to be used for drawing fonts. For the syntax of this option, check
  3248. the "Color" section in the ffmpeg-utils manual.
  3249. The default value of @var{fontcolor} is "black".
  3250. @item fontcolor_expr
  3251. String which is expanded the same way as @var{text} to obtain dynamic
  3252. @var{fontcolor} value. By default this option has empty value and is not
  3253. processed. When this option is set, it overrides @var{fontcolor} option.
  3254. @item font
  3255. The font family to be used for drawing text. By default Sans.
  3256. @item fontfile
  3257. The font file to be used for drawing text. The path must be included.
  3258. This parameter is mandatory if the fontconfig support is disabled.
  3259. @item draw
  3260. This option does not exist, please see the timeline system
  3261. @item alpha
  3262. Draw the text applying alpha blending. The value can
  3263. be either a number between 0.0 and 1.0
  3264. The expression accepts the same variables @var{x, y} do.
  3265. The default value is 1.
  3266. Please see fontcolor_expr
  3267. @item fontsize
  3268. The font size to be used for drawing text.
  3269. The default value of @var{fontsize} is 16.
  3270. @item text_shaping
  3271. If set to 1, attempt to shape the text (for example, reverse the order of
  3272. right-to-left text and join Arabic characters) before drawing it.
  3273. Otherwise, just draw the text exactly as given.
  3274. By default 1 (if supported).
  3275. @item ft_load_flags
  3276. The flags to be used for loading the fonts.
  3277. The flags map the corresponding flags supported by libfreetype, and are
  3278. a combination of the following values:
  3279. @table @var
  3280. @item default
  3281. @item no_scale
  3282. @item no_hinting
  3283. @item render
  3284. @item no_bitmap
  3285. @item vertical_layout
  3286. @item force_autohint
  3287. @item crop_bitmap
  3288. @item pedantic
  3289. @item ignore_global_advance_width
  3290. @item no_recurse
  3291. @item ignore_transform
  3292. @item monochrome
  3293. @item linear_design
  3294. @item no_autohint
  3295. @end table
  3296. Default value is "default".
  3297. For more information consult the documentation for the FT_LOAD_*
  3298. libfreetype flags.
  3299. @item shadowcolor
  3300. The color to be used for drawing a shadow behind the drawn text. For the
  3301. syntax of this option, check the "Color" section in the ffmpeg-utils manual.
  3302. The default value of @var{shadowcolor} is "black".
  3303. @item shadowx
  3304. @item shadowy
  3305. The x and y offsets for the text shadow position with respect to the
  3306. position of the text. They can be either positive or negative
  3307. values. The default value for both is "0".
  3308. @item start_number
  3309. The starting frame number for the n/frame_num variable. The default value
  3310. is "0".
  3311. @item tabsize
  3312. The size in number of spaces to use for rendering the tab.
  3313. Default value is 4.
  3314. @item timecode
  3315. Set the initial timecode representation in "hh:mm:ss[:;.]ff"
  3316. format. It can be used with or without text parameter. @var{timecode_rate}
  3317. option must be specified.
  3318. @item timecode_rate, rate, r
  3319. Set the timecode frame rate (timecode only).
  3320. @item text
  3321. The text string to be drawn. The text must be a sequence of UTF-8
  3322. encoded characters.
  3323. This parameter is mandatory if no file is specified with the parameter
  3324. @var{textfile}.
  3325. @item textfile
  3326. A text file containing text to be drawn. The text must be a sequence
  3327. of UTF-8 encoded characters.
  3328. This parameter is mandatory if no text string is specified with the
  3329. parameter @var{text}.
  3330. If both @var{text} and @var{textfile} are specified, an error is thrown.
  3331. @item reload
  3332. If set to 1, the @var{textfile} will be reloaded before each frame.
  3333. Be sure to update it atomically, or it may be read partially, or even fail.
  3334. @item x
  3335. @item y
  3336. The expressions which specify the offsets where text will be drawn
  3337. within the video frame. They are relative to the top/left border of the
  3338. output image.
  3339. The default value of @var{x} and @var{y} is "0".
  3340. See below for the list of accepted constants and functions.
  3341. @end table
  3342. The parameters for @var{x} and @var{y} are expressions containing the
  3343. following constants and functions:
  3344. @table @option
  3345. @item dar
  3346. input display aspect ratio, it is the same as (@var{w} / @var{h}) * @var{sar}
  3347. @item hsub
  3348. @item vsub
  3349. horizontal and vertical chroma subsample values. For example for the
  3350. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  3351. @item line_h, lh
  3352. the height of each text line
  3353. @item main_h, h, H
  3354. the input height
  3355. @item main_w, w, W
  3356. the input width
  3357. @item max_glyph_a, ascent
  3358. the maximum distance from the baseline to the highest/upper grid
  3359. coordinate used to place a glyph outline point, for all the rendered
  3360. glyphs.
  3361. It is a positive value, due to the grid's orientation with the Y axis
  3362. upwards.
  3363. @item max_glyph_d, descent
  3364. the maximum distance from the baseline to the lowest grid coordinate
  3365. used to place a glyph outline point, for all the rendered glyphs.
  3366. This is a negative value, due to the grid's orientation, with the Y axis
  3367. upwards.
  3368. @item max_glyph_h
  3369. maximum glyph height, that is the maximum height for all the glyphs
  3370. contained in the rendered text, it is equivalent to @var{ascent} -
  3371. @var{descent}.
  3372. @item max_glyph_w
  3373. maximum glyph width, that is the maximum width for all the glyphs
  3374. contained in the rendered text
  3375. @item n
  3376. the number of input frame, starting from 0
  3377. @item rand(min, max)
  3378. return a random number included between @var{min} and @var{max}
  3379. @item sar
  3380. The input sample aspect ratio.
  3381. @item t
  3382. timestamp expressed in seconds, NAN if the input timestamp is unknown
  3383. @item text_h, th
  3384. the height of the rendered text
  3385. @item text_w, tw
  3386. the width of the rendered text
  3387. @item x
  3388. @item y
  3389. the x and y offset coordinates where the text is drawn.
  3390. These parameters allow the @var{x} and @var{y} expressions to refer
  3391. each other, so you can for example specify @code{y=x/dar}.
  3392. @end table
  3393. @anchor{drawtext_expansion}
  3394. @subsection Text expansion
  3395. If @option{expansion} is set to @code{strftime},
  3396. the filter recognizes strftime() sequences in the provided text and
  3397. expands them accordingly. Check the documentation of strftime(). This
  3398. feature is deprecated.
  3399. If @option{expansion} is set to @code{none}, the text is printed verbatim.
  3400. If @option{expansion} is set to @code{normal} (which is the default),
  3401. the following expansion mechanism is used.
  3402. The backslash character @samp{\}, followed by any character, always expands to
  3403. the second character.
  3404. Sequence of the form @code{%@{...@}} are expanded. The text between the
  3405. braces is a function name, possibly followed by arguments separated by ':'.
  3406. If the arguments contain special characters or delimiters (':' or '@}'),
  3407. they should be escaped.
  3408. Note that they probably must also be escaped as the value for the
  3409. @option{text} option in the filter argument string and as the filter
  3410. argument in the filtergraph description, and possibly also for the shell,
  3411. that makes up to four levels of escaping; using a text file avoids these
  3412. problems.
  3413. The following functions are available:
  3414. @table @command
  3415. @item expr, e
  3416. The expression evaluation result.
  3417. It must take one argument specifying the expression to be evaluated,
  3418. which accepts the same constants and functions as the @var{x} and
  3419. @var{y} values. Note that not all constants should be used, for
  3420. example the text size is not known when evaluating the expression, so
  3421. the constants @var{text_w} and @var{text_h} will have an undefined
  3422. value.
  3423. @item expr_int_format, eif
  3424. Evaluate the expression's value and output as formatted integer.
  3425. The first argument is the expression to be evaluated, just as for the @var{expr} function.
  3426. The second argument specifies the output format. Allowed values are @samp{x},
  3427. @samp{X}, @samp{d} and @samp{u}. They are treated exactly as in the
  3428. @code{printf} function.
  3429. The third parameter is optional and sets the number of positions taken by the output.
  3430. It can be used to add padding with zeros from the left.
  3431. @item gmtime
  3432. The time at which the filter is running, expressed in UTC.
  3433. It can accept an argument: a strftime() format string.
  3434. @item localtime
  3435. The time at which the filter is running, expressed in the local time zone.
  3436. It can accept an argument: a strftime() format string.
  3437. @item metadata
  3438. Frame metadata. It must take one argument specifying metadata key.
  3439. @item n, frame_num
  3440. The frame number, starting from 0.
  3441. @item pict_type
  3442. A 1 character description of the current picture type.
  3443. @item pts
  3444. The timestamp of the current frame.
  3445. It can take up to two arguments.
  3446. The first argument is the format of the timestamp; it defaults to @code{flt}
  3447. for seconds as a decimal number with microsecond accuracy; @code{hms} stands
  3448. for a formatted @var{[-]HH:MM:SS.mmm} timestamp with millisecond accuracy.
  3449. The second argument is an offset added to the timestamp.
  3450. @end table
  3451. @subsection Examples
  3452. @itemize
  3453. @item
  3454. Draw "Test Text" with font FreeSerif, using the default values for the
  3455. optional parameters.
  3456. @example
  3457. drawtext="fontfile=/usr/share/fonts/truetype/freefont/FreeSerif.ttf: text='Test Text'"
  3458. @end example
  3459. @item
  3460. Draw 'Test Text' with font FreeSerif of size 24 at position x=100
  3461. and y=50 (counting from the top-left corner of the screen), text is
  3462. yellow with a red box around it. Both the text and the box have an
  3463. opacity of 20%.
  3464. @example
  3465. drawtext="fontfile=/usr/share/fonts/truetype/freefont/FreeSerif.ttf: text='Test Text':\
  3466. x=100: y=50: fontsize=24: fontcolor=yellow@@0.2: box=1: boxcolor=red@@0.2"
  3467. @end example
  3468. Note that the double quotes are not necessary if spaces are not used
  3469. within the parameter list.
  3470. @item
  3471. Show the text at the center of the video frame:
  3472. @example
  3473. drawtext="fontsize=30:fontfile=FreeSerif.ttf:text='hello world':x=(w-text_w)/2:y=(h-text_h-line_h)/2"
  3474. @end example
  3475. @item
  3476. Show a text line sliding from right to left in the last row of the video
  3477. frame. The file @file{LONG_LINE} is assumed to contain a single line
  3478. with no newlines.
  3479. @example
  3480. drawtext="fontsize=15:fontfile=FreeSerif.ttf:text=LONG_LINE:y=h-line_h:x=-50*t"
  3481. @end example
  3482. @item
  3483. Show the content of file @file{CREDITS} off the bottom of the frame and scroll up.
  3484. @example
  3485. drawtext="fontsize=20:fontfile=FreeSerif.ttf:textfile=CREDITS:y=h-20*t"
  3486. @end example
  3487. @item
  3488. Draw a single green letter "g", at the center of the input video.
  3489. The glyph baseline is placed at half screen height.
  3490. @example
  3491. drawtext="fontsize=60:fontfile=FreeSerif.ttf:fontcolor=green:text=g:x=(w-max_glyph_w)/2:y=h/2-ascent"
  3492. @end example
  3493. @item
  3494. Show text for 1 second every 3 seconds:
  3495. @example
  3496. drawtext="fontfile=FreeSerif.ttf:fontcolor=white:x=100:y=x/dar:enable=lt(mod(t\,3)\,1):text='blink'"
  3497. @end example
  3498. @item
  3499. Use fontconfig to set the font. Note that the colons need to be escaped.
  3500. @example
  3501. drawtext='fontfile=Linux Libertine O-40\:style=Semibold:text=FFmpeg'
  3502. @end example
  3503. @item
  3504. Print the date of a real-time encoding (see strftime(3)):
  3505. @example
  3506. drawtext='fontfile=FreeSans.ttf:text=%@{localtime\:%a %b %d %Y@}'
  3507. @end example
  3508. @item
  3509. Show text fading in and out (appearing/disappearing):
  3510. @example
  3511. #!/bin/sh
  3512. DS=1.0 # display start
  3513. DE=10.0 # display end
  3514. FID=1.5 # fade in duration
  3515. FOD=5 # fade out duration
  3516. ffplay -f lavfi "color,drawtext=text=TEST:fontsize=50:fontfile=FreeSerif.ttf:fontcolor_expr=ff0000%@{eif\\\\: clip(255*(1*between(t\\, $DS + $FID\\, $DE - $FOD) + ((t - $DS)/$FID)*between(t\\, $DS\\, $DS + $FID) + (-(t - $DE)/$FOD)*between(t\\, $DE - $FOD\\, $DE) )\\, 0\\, 255) \\\\: x\\\\: 2 @}"
  3517. @end example
  3518. @end itemize
  3519. For more information about libfreetype, check:
  3520. @url{http://www.freetype.org/}.
  3521. For more information about fontconfig, check:
  3522. @url{http://freedesktop.org/software/fontconfig/fontconfig-user.html}.
  3523. For more information about libfribidi, check:
  3524. @url{http://fribidi.org/}.
  3525. @section edgedetect
  3526. Detect and draw edges. The filter uses the Canny Edge Detection algorithm.
  3527. The filter accepts the following options:
  3528. @table @option
  3529. @item low
  3530. @item high
  3531. Set low and high threshold values used by the Canny thresholding
  3532. algorithm.
  3533. The high threshold selects the "strong" edge pixels, which are then
  3534. connected through 8-connectivity with the "weak" edge pixels selected
  3535. by the low threshold.
  3536. @var{low} and @var{high} threshold values must be chosen in the range
  3537. [0,1], and @var{low} should be lesser or equal to @var{high}.
  3538. Default value for @var{low} is @code{20/255}, and default value for @var{high}
  3539. is @code{50/255}.
  3540. @item mode
  3541. Define the drawing mode.
  3542. @table @samp
  3543. @item wires
  3544. Draw white/gray wires on black background.
  3545. @item colormix
  3546. Mix the colors to create a paint/cartoon effect.
  3547. @end table
  3548. Default value is @var{wires}.
  3549. @end table
  3550. @subsection Examples
  3551. @itemize
  3552. @item
  3553. Standard edge detection with custom values for the hysteresis thresholding:
  3554. @example
  3555. edgedetect=low=0.1:high=0.4
  3556. @end example
  3557. @item
  3558. Painting effect without thresholding:
  3559. @example
  3560. edgedetect=mode=colormix:high=0
  3561. @end example
  3562. @end itemize
  3563. @section eq
  3564. Set brightness, contrast, saturation and approximate gamma adjustment.
  3565. The filter accepts the following options:
  3566. @table @option
  3567. @item contrast
  3568. Set the contrast expression. The value must be a float value in range
  3569. @code{-2.0} to @code{2.0}. The default value is "0".
  3570. @item brightness
  3571. Set the brightness expression. The value must be a float value in
  3572. range @code{-1.0} to @code{1.0}. The default value is "0".
  3573. @item saturation
  3574. Set the saturation expression. The value must be a float in
  3575. range @code{0.0} to @code{3.0}. The default value is "1".
  3576. @item gamma
  3577. Set the gamma expression. The value must be a float in range
  3578. @code{0.1} to @code{10.0}. The default value is "1".
  3579. @item gamma_r
  3580. Set the gamma expression for red. The value must be a float in
  3581. range @code{0.1} to @code{10.0}. The default value is "1".
  3582. @item gamma_g
  3583. Set the gamma expression for green. The value must be a float in range
  3584. @code{0.1} to @code{10.0}. The default value is "1".
  3585. @item gamma_b
  3586. Set the gamma expression for blue. The value must be a float in range
  3587. @code{0.1} to @code{10.0}. The default value is "1".
  3588. @item gamma_weight
  3589. Set the gamma weight expression. It can be used to reduce the effect
  3590. of a high gamma value on bright image areas, e.g. keep them from
  3591. getting overamplified and just plain white. The value must be a float
  3592. in range @code{0.0} to @code{1.0}. A value of @code{0.0} turns the
  3593. gamma correction all the way down while @code{1.0} leaves it at its
  3594. full strength. Default is "1".
  3595. @item eval
  3596. Set when the expressions for brightness, contrast, saturation and
  3597. gamma expressions are evaluated.
  3598. It accepts the following values:
  3599. @table @samp
  3600. @item init
  3601. only evaluate expressions once during the filter initialization or
  3602. when a command is processed
  3603. @item frame
  3604. evaluate expressions for each incoming frame
  3605. @end table
  3606. Default value is @samp{init}.
  3607. @end table
  3608. The expressions accept the following parameters:
  3609. @table @option
  3610. @item n
  3611. frame count of the input frame starting from 0
  3612. @item pos
  3613. byte position of the corresponding packet in the input file, NAN if
  3614. unspecified
  3615. @item r
  3616. frame rate of the input video, NAN if the input frame rate is unknown
  3617. @item t
  3618. timestamp expressed in seconds, NAN if the input timestamp is unknown
  3619. @end table
  3620. @subsection Commands
  3621. The filter supports the following commands:
  3622. @table @option
  3623. @item contrast
  3624. Set the contrast expression.
  3625. @item brightness
  3626. Set the brightness expression.
  3627. @item saturation
  3628. Set the saturation expression.
  3629. @item gamma
  3630. Set the gamma expression.
  3631. @item gamma_r
  3632. Set the gamma_r expression.
  3633. @item gamma_g
  3634. Set gamma_g expression.
  3635. @item gamma_b
  3636. Set gamma_b expression.
  3637. @item gamma_weight
  3638. Set gamma_weight expression.
  3639. The command accepts the same syntax of the corresponding option.
  3640. If the specified expression is not valid, it is kept at its current
  3641. value.
  3642. @end table
  3643. @section extractplanes
  3644. Extract color channel components from input video stream into
  3645. separate grayscale video streams.
  3646. The filter accepts the following option:
  3647. @table @option
  3648. @item planes
  3649. Set plane(s) to extract.
  3650. Available values for planes are:
  3651. @table @samp
  3652. @item y
  3653. @item u
  3654. @item v
  3655. @item a
  3656. @item r
  3657. @item g
  3658. @item b
  3659. @end table
  3660. Choosing planes not available in the input will result in an error.
  3661. That means you cannot select @code{r}, @code{g}, @code{b} planes
  3662. with @code{y}, @code{u}, @code{v} planes at same time.
  3663. @end table
  3664. @subsection Examples
  3665. @itemize
  3666. @item
  3667. Extract luma, u and v color channel component from input video frame
  3668. into 3 grayscale outputs:
  3669. @example
  3670. ffmpeg -i video.avi -filter_complex 'extractplanes=y+u+v[y][u][v]' -map '[y]' y.avi -map '[u]' u.avi -map '[v]' v.avi
  3671. @end example
  3672. @end itemize
  3673. @section elbg
  3674. Apply a posterize effect using the ELBG (Enhanced LBG) algorithm.
  3675. For each input image, the filter will compute the optimal mapping from
  3676. the input to the output given the codebook length, that is the number
  3677. of distinct output colors.
  3678. This filter accepts the following options.
  3679. @table @option
  3680. @item codebook_length, l
  3681. Set codebook length. The value must be a positive integer, and
  3682. represents the number of distinct output colors. Default value is 256.
  3683. @item nb_steps, n
  3684. Set the maximum number of iterations to apply for computing the optimal
  3685. mapping. The higher the value the better the result and the higher the
  3686. computation time. Default value is 1.
  3687. @item seed, s
  3688. Set a random seed, must be an integer included between 0 and
  3689. UINT32_MAX. If not specified, or if explicitly set to -1, the filter
  3690. will try to use a good random seed on a best effort basis.
  3691. @end table
  3692. @section fade
  3693. Apply a fade-in/out effect to the input video.
  3694. It accepts the following parameters:
  3695. @table @option
  3696. @item type, t
  3697. The effect type can be either "in" for a fade-in, or "out" for a fade-out
  3698. effect.
  3699. Default is @code{in}.
  3700. @item start_frame, s
  3701. Specify the number of the frame to start applying the fade
  3702. effect at. Default is 0.
  3703. @item nb_frames, n
  3704. The number of frames that the fade effect lasts. At the end of the
  3705. fade-in effect, the output video will have the same intensity as the input video.
  3706. At the end of the fade-out transition, the output video will be filled with the
  3707. selected @option{color}.
  3708. Default is 25.
  3709. @item alpha
  3710. If set to 1, fade only alpha channel, if one exists on the input.
  3711. Default value is 0.
  3712. @item start_time, st
  3713. Specify the timestamp (in seconds) of the frame to start to apply the fade
  3714. effect. If both start_frame and start_time are specified, the fade will start at
  3715. whichever comes last. Default is 0.
  3716. @item duration, d
  3717. The number of seconds for which the fade effect has to last. At the end of the
  3718. fade-in effect the output video will have the same intensity as the input video,
  3719. at the end of the fade-out transition the output video will be filled with the
  3720. selected @option{color}.
  3721. If both duration and nb_frames are specified, duration is used. Default is 0
  3722. (nb_frames is used by default).
  3723. @item color, c
  3724. Specify the color of the fade. Default is "black".
  3725. @end table
  3726. @subsection Examples
  3727. @itemize
  3728. @item
  3729. Fade in the first 30 frames of video:
  3730. @example
  3731. fade=in:0:30
  3732. @end example
  3733. The command above is equivalent to:
  3734. @example
  3735. fade=t=in:s=0:n=30
  3736. @end example
  3737. @item
  3738. Fade out the last 45 frames of a 200-frame video:
  3739. @example
  3740. fade=out:155:45
  3741. fade=type=out:start_frame=155:nb_frames=45
  3742. @end example
  3743. @item
  3744. Fade in the first 25 frames and fade out the last 25 frames of a 1000-frame video:
  3745. @example
  3746. fade=in:0:25, fade=out:975:25
  3747. @end example
  3748. @item
  3749. Make the first 5 frames yellow, then fade in from frame 5-24:
  3750. @example
  3751. fade=in:5:20:color=yellow
  3752. @end example
  3753. @item
  3754. Fade in alpha over first 25 frames of video:
  3755. @example
  3756. fade=in:0:25:alpha=1
  3757. @end example
  3758. @item
  3759. Make the first 5.5 seconds black, then fade in for 0.5 seconds:
  3760. @example
  3761. fade=t=in:st=5.5:d=0.5
  3762. @end example
  3763. @end itemize
  3764. @section fftfilt
  3765. Apply arbitrary expressions to samples in frequency domain
  3766. @table @option
  3767. @item dc_Y
  3768. Adjust the dc value (gain) of the luma plane of the image. The filter
  3769. accepts an integer value in range @code{0} to @code{1000}. The default
  3770. value is set to @code{0}.
  3771. @item dc_U
  3772. Adjust the dc value (gain) of the 1st chroma plane of the image. The
  3773. filter accepts an integer value in range @code{0} to @code{1000}. The
  3774. default value is set to @code{0}.
  3775. @item dc_V
  3776. Adjust the dc value (gain) of the 2nd chroma plane of the image. The
  3777. filter accepts an integer value in range @code{0} to @code{1000}. The
  3778. default value is set to @code{0}.
  3779. @item weight_Y
  3780. Set the frequency domain weight expression for the luma plane.
  3781. @item weight_U
  3782. Set the frequency domain weight expression for the 1st chroma plane.
  3783. @item weight_V
  3784. Set the frequency domain weight expression for the 2nd chroma plane.
  3785. The filter accepts the following variables:
  3786. @item X
  3787. @item Y
  3788. The coordinates of the current sample.
  3789. @item W
  3790. @item H
  3791. The width and height of the image.
  3792. @end table
  3793. @subsection Examples
  3794. @itemize
  3795. @item
  3796. High-pass:
  3797. @example
  3798. fftfilt=dc_Y=128:weight_Y='squish(1-(Y+X)/100)'
  3799. @end example
  3800. @item
  3801. Low-pass:
  3802. @example
  3803. fftfilt=dc_Y=0:weight_Y='squish((Y+X)/100-1)'
  3804. @end example
  3805. @item
  3806. Sharpen:
  3807. @example
  3808. fftfilt=dc_Y=0:weight_Y='1+squish(1-(Y+X)/100)'
  3809. @end example
  3810. @end itemize
  3811. @section field
  3812. Extract a single field from an interlaced image using stride
  3813. arithmetic to avoid wasting CPU time. The output frames are marked as
  3814. non-interlaced.
  3815. The filter accepts the following options:
  3816. @table @option
  3817. @item type
  3818. Specify whether to extract the top (if the value is @code{0} or
  3819. @code{top}) or the bottom field (if the value is @code{1} or
  3820. @code{bottom}).
  3821. @end table
  3822. @section fieldmatch
  3823. Field matching filter for inverse telecine. It is meant to reconstruct the
  3824. progressive frames from a telecined stream. The filter does not drop duplicated
  3825. frames, so to achieve a complete inverse telecine @code{fieldmatch} needs to be
  3826. followed by a decimation filter such as @ref{decimate} in the filtergraph.
  3827. The separation of the field matching and the decimation is notably motivated by
  3828. the possibility of inserting a de-interlacing filter fallback between the two.
  3829. If the source has mixed telecined and real interlaced content,
  3830. @code{fieldmatch} will not be able to match fields for the interlaced parts.
  3831. But these remaining combed frames will be marked as interlaced, and thus can be
  3832. de-interlaced by a later filter such as @ref{yadif} before decimation.
  3833. In addition to the various configuration options, @code{fieldmatch} can take an
  3834. optional second stream, activated through the @option{ppsrc} option. If
  3835. enabled, the frames reconstruction will be based on the fields and frames from
  3836. this second stream. This allows the first input to be pre-processed in order to
  3837. help the various algorithms of the filter, while keeping the output lossless
  3838. (assuming the fields are matched properly). Typically, a field-aware denoiser,
  3839. or brightness/contrast adjustments can help.
  3840. Note that this filter uses the same algorithms as TIVTC/TFM (AviSynth project)
  3841. and VIVTC/VFM (VapourSynth project). The later is a light clone of TFM from
  3842. which @code{fieldmatch} is based on. While the semantic and usage are very
  3843. close, some behaviour and options names can differ.
  3844. The @ref{decimate} filter currently only works for constant frame rate input.
  3845. Do not use @code{fieldmatch} and @ref{decimate} if your input has mixed
  3846. telecined and progressive content with changing framerate.
  3847. The filter accepts the following options:
  3848. @table @option
  3849. @item order
  3850. Specify the assumed field order of the input stream. Available values are:
  3851. @table @samp
  3852. @item auto
  3853. Auto detect parity (use FFmpeg's internal parity value).
  3854. @item bff
  3855. Assume bottom field first.
  3856. @item tff
  3857. Assume top field first.
  3858. @end table
  3859. Note that it is sometimes recommended not to trust the parity announced by the
  3860. stream.
  3861. Default value is @var{auto}.
  3862. @item mode
  3863. Set the matching mode or strategy to use. @option{pc} mode is the safest in the
  3864. sense that it won't risk creating jerkiness due to duplicate frames when
  3865. possible, but if there are bad edits or blended fields it will end up
  3866. outputting combed frames when a good match might actually exist. On the other
  3867. hand, @option{pcn_ub} mode is the most risky in terms of creating jerkiness,
  3868. but will almost always find a good frame if there is one. The other values are
  3869. all somewhere in between @option{pc} and @option{pcn_ub} in terms of risking
  3870. jerkiness and creating duplicate frames versus finding good matches in sections
  3871. with bad edits, orphaned fields, blended fields, etc.
  3872. More details about p/c/n/u/b are available in @ref{p/c/n/u/b meaning} section.
  3873. Available values are:
  3874. @table @samp
  3875. @item pc
  3876. 2-way matching (p/c)
  3877. @item pc_n
  3878. 2-way matching, and trying 3rd match if still combed (p/c + n)
  3879. @item pc_u
  3880. 2-way matching, and trying 3rd match (same order) if still combed (p/c + u)
  3881. @item pc_n_ub
  3882. 2-way matching, trying 3rd match if still combed, and trying 4th/5th matches if
  3883. still combed (p/c + n + u/b)
  3884. @item pcn
  3885. 3-way matching (p/c/n)
  3886. @item pcn_ub
  3887. 3-way matching, and trying 4th/5th matches if all 3 of the original matches are
  3888. detected as combed (p/c/n + u/b)
  3889. @end table
  3890. The parenthesis at the end indicate the matches that would be used for that
  3891. mode assuming @option{order}=@var{tff} (and @option{field} on @var{auto} or
  3892. @var{top}).
  3893. In terms of speed @option{pc} mode is by far the fastest and @option{pcn_ub} is
  3894. the slowest.
  3895. Default value is @var{pc_n}.
  3896. @item ppsrc
  3897. Mark the main input stream as a pre-processed input, and enable the secondary
  3898. input stream as the clean source to pick the fields from. See the filter
  3899. introduction for more details. It is similar to the @option{clip2} feature from
  3900. VFM/TFM.
  3901. Default value is @code{0} (disabled).
  3902. @item field
  3903. Set the field to match from. It is recommended to set this to the same value as
  3904. @option{order} unless you experience matching failures with that setting. In
  3905. certain circumstances changing the field that is used to match from can have a
  3906. large impact on matching performance. Available values are:
  3907. @table @samp
  3908. @item auto
  3909. Automatic (same value as @option{order}).
  3910. @item bottom
  3911. Match from the bottom field.
  3912. @item top
  3913. Match from the top field.
  3914. @end table
  3915. Default value is @var{auto}.
  3916. @item mchroma
  3917. Set whether or not chroma is included during the match comparisons. In most
  3918. cases it is recommended to leave this enabled. You should set this to @code{0}
  3919. only if your clip has bad chroma problems such as heavy rainbowing or other
  3920. artifacts. Setting this to @code{0} could also be used to speed things up at
  3921. the cost of some accuracy.
  3922. Default value is @code{1}.
  3923. @item y0
  3924. @item y1
  3925. These define an exclusion band which excludes the lines between @option{y0} and
  3926. @option{y1} from being included in the field matching decision. An exclusion
  3927. band can be used to ignore subtitles, a logo, or other things that may
  3928. interfere with the matching. @option{y0} sets the starting scan line and
  3929. @option{y1} sets the ending line; all lines in between @option{y0} and
  3930. @option{y1} (including @option{y0} and @option{y1}) will be ignored. Setting
  3931. @option{y0} and @option{y1} to the same value will disable the feature.
  3932. @option{y0} and @option{y1} defaults to @code{0}.
  3933. @item scthresh
  3934. Set the scene change detection threshold as a percentage of maximum change on
  3935. the luma plane. Good values are in the @code{[8.0, 14.0]} range. Scene change
  3936. detection is only relevant in case @option{combmatch}=@var{sc}. The range for
  3937. @option{scthresh} is @code{[0.0, 100.0]}.
  3938. Default value is @code{12.0}.
  3939. @item combmatch
  3940. When @option{combatch} is not @var{none}, @code{fieldmatch} will take into
  3941. account the combed scores of matches when deciding what match to use as the
  3942. final match. Available values are:
  3943. @table @samp
  3944. @item none
  3945. No final matching based on combed scores.
  3946. @item sc
  3947. Combed scores are only used when a scene change is detected.
  3948. @item full
  3949. Use combed scores all the time.
  3950. @end table
  3951. Default is @var{sc}.
  3952. @item combdbg
  3953. Force @code{fieldmatch} to calculate the combed metrics for certain matches and
  3954. print them. This setting is known as @option{micout} in TFM/VFM vocabulary.
  3955. Available values are:
  3956. @table @samp
  3957. @item none
  3958. No forced calculation.
  3959. @item pcn
  3960. Force p/c/n calculations.
  3961. @item pcnub
  3962. Force p/c/n/u/b calculations.
  3963. @end table
  3964. Default value is @var{none}.
  3965. @item cthresh
  3966. This is the area combing threshold used for combed frame detection. This
  3967. essentially controls how "strong" or "visible" combing must be to be detected.
  3968. Larger values mean combing must be more visible and smaller values mean combing
  3969. can be less visible or strong and still be detected. Valid settings are from
  3970. @code{-1} (every pixel will be detected as combed) to @code{255} (no pixel will
  3971. be detected as combed). This is basically a pixel difference value. A good
  3972. range is @code{[8, 12]}.
  3973. Default value is @code{9}.
  3974. @item chroma
  3975. Sets whether or not chroma is considered in the combed frame decision. Only
  3976. disable this if your source has chroma problems (rainbowing, etc.) that are
  3977. causing problems for the combed frame detection with chroma enabled. Actually,
  3978. using @option{chroma}=@var{0} is usually more reliable, except for the case
  3979. where there is chroma only combing in the source.
  3980. Default value is @code{0}.
  3981. @item blockx
  3982. @item blocky
  3983. Respectively set the x-axis and y-axis size of the window used during combed
  3984. frame detection. This has to do with the size of the area in which
  3985. @option{combpel} pixels are required to be detected as combed for a frame to be
  3986. declared combed. See the @option{combpel} parameter description for more info.
  3987. Possible values are any number that is a power of 2 starting at 4 and going up
  3988. to 512.
  3989. Default value is @code{16}.
  3990. @item combpel
  3991. The number of combed pixels inside any of the @option{blocky} by
  3992. @option{blockx} size blocks on the frame for the frame to be detected as
  3993. combed. While @option{cthresh} controls how "visible" the combing must be, this
  3994. setting controls "how much" combing there must be in any localized area (a
  3995. window defined by the @option{blockx} and @option{blocky} settings) on the
  3996. frame. Minimum value is @code{0} and maximum is @code{blocky x blockx} (at
  3997. which point no frames will ever be detected as combed). This setting is known
  3998. as @option{MI} in TFM/VFM vocabulary.
  3999. Default value is @code{80}.
  4000. @end table
  4001. @anchor{p/c/n/u/b meaning}
  4002. @subsection p/c/n/u/b meaning
  4003. @subsubsection p/c/n
  4004. We assume the following telecined stream:
  4005. @example
  4006. Top fields: 1 2 2 3 4
  4007. Bottom fields: 1 2 3 4 4
  4008. @end example
  4009. The numbers correspond to the progressive frame the fields relate to. Here, the
  4010. first two frames are progressive, the 3rd and 4th are combed, and so on.
  4011. When @code{fieldmatch} is configured to run a matching from bottom
  4012. (@option{field}=@var{bottom}) this is how this input stream get transformed:
  4013. @example
  4014. Input stream:
  4015. T 1 2 2 3 4
  4016. B 1 2 3 4 4 <-- matching reference
  4017. Matches: c c n n c
  4018. Output stream:
  4019. T 1 2 3 4 4
  4020. B 1 2 3 4 4
  4021. @end example
  4022. As a result of the field matching, we can see that some frames get duplicated.
  4023. To perform a complete inverse telecine, you need to rely on a decimation filter
  4024. after this operation. See for instance the @ref{decimate} filter.
  4025. The same operation now matching from top fields (@option{field}=@var{top})
  4026. looks like this:
  4027. @example
  4028. Input stream:
  4029. T 1 2 2 3 4 <-- matching reference
  4030. B 1 2 3 4 4
  4031. Matches: c c p p c
  4032. Output stream:
  4033. T 1 2 2 3 4
  4034. B 1 2 2 3 4
  4035. @end example
  4036. In these examples, we can see what @var{p}, @var{c} and @var{n} mean;
  4037. basically, they refer to the frame and field of the opposite parity:
  4038. @itemize
  4039. @item @var{p} matches the field of the opposite parity in the previous frame
  4040. @item @var{c} matches the field of the opposite parity in the current frame
  4041. @item @var{n} matches the field of the opposite parity in the next frame
  4042. @end itemize
  4043. @subsubsection u/b
  4044. The @var{u} and @var{b} matching are a bit special in the sense that they match
  4045. from the opposite parity flag. In the following examples, we assume that we are
  4046. currently matching the 2nd frame (Top:2, bottom:2). According to the match, a
  4047. 'x' is placed above and below each matched fields.
  4048. With bottom matching (@option{field}=@var{bottom}):
  4049. @example
  4050. Match: c p n b u
  4051. x x x x x
  4052. Top 1 2 2 1 2 2 1 2 2 1 2 2 1 2 2
  4053. Bottom 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3
  4054. x x x x x
  4055. Output frames:
  4056. 2 1 2 2 2
  4057. 2 2 2 1 3
  4058. @end example
  4059. With top matching (@option{field}=@var{top}):
  4060. @example
  4061. Match: c p n b u
  4062. x x x x x
  4063. Top 1 2 2 1 2 2 1 2 2 1 2 2 1 2 2
  4064. Bottom 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3
  4065. x x x x x
  4066. Output frames:
  4067. 2 2 2 1 2
  4068. 2 1 3 2 2
  4069. @end example
  4070. @subsection Examples
  4071. Simple IVTC of a top field first telecined stream:
  4072. @example
  4073. fieldmatch=order=tff:combmatch=none, decimate
  4074. @end example
  4075. Advanced IVTC, with fallback on @ref{yadif} for still combed frames:
  4076. @example
  4077. fieldmatch=order=tff:combmatch=full, yadif=deint=interlaced, decimate
  4078. @end example
  4079. @section fieldorder
  4080. Transform the field order of the input video.
  4081. It accepts the following parameters:
  4082. @table @option
  4083. @item order
  4084. The output field order. Valid values are @var{tff} for top field first or @var{bff}
  4085. for bottom field first.
  4086. @end table
  4087. The default value is @samp{tff}.
  4088. The transformation is done by shifting the picture content up or down
  4089. by one line, and filling the remaining line with appropriate picture content.
  4090. This method is consistent with most broadcast field order converters.
  4091. If the input video is not flagged as being interlaced, or it is already
  4092. flagged as being of the required output field order, then this filter does
  4093. not alter the incoming video.
  4094. It is very useful when converting to or from PAL DV material,
  4095. which is bottom field first.
  4096. For example:
  4097. @example
  4098. ffmpeg -i in.vob -vf "fieldorder=bff" out.dv
  4099. @end example
  4100. @section fifo
  4101. Buffer input images and send them when they are requested.
  4102. It is mainly useful when auto-inserted by the libavfilter
  4103. framework.
  4104. It does not take parameters.
  4105. @section find_rect
  4106. Find a rectangular object
  4107. It accepts the following options:
  4108. @table @option
  4109. @item object
  4110. Filepath of the object image, needs to be in gray8.
  4111. @item threshold
  4112. Detection threshold, default is 0.5.
  4113. @item mipmaps
  4114. Number of mipmaps, default is 3.
  4115. @item xmin, ymin, xmax, ymax
  4116. Specifies the rectangle in which to search.
  4117. @end table
  4118. @subsection Examples
  4119. @itemize
  4120. @item
  4121. Generate a representative palette of a given video using @command{ffmpeg}:
  4122. @example
  4123. ffmpeg -i file.ts -vf find_rect=newref.pgm,cover_rect=cover.jpg:mode=cover new.mkv
  4124. @end example
  4125. @end itemize
  4126. @section cover_rect
  4127. Cover a rectangular object
  4128. It accepts the following options:
  4129. @table @option
  4130. @item cover
  4131. Filepath of the optional cover image, needs to be in yuv420.
  4132. @item mode
  4133. Set covering mode.
  4134. It accepts the following values:
  4135. @table @samp
  4136. @item cover
  4137. cover it by the supplied image
  4138. @item blur
  4139. cover it by interpolating the surrounding pixels
  4140. @end table
  4141. Default value is @var{blur}.
  4142. @end table
  4143. @subsection Examples
  4144. @itemize
  4145. @item
  4146. Generate a representative palette of a given video using @command{ffmpeg}:
  4147. @example
  4148. ffmpeg -i file.ts -vf find_rect=newref.pgm,cover_rect=cover.jpg:mode=cover new.mkv
  4149. @end example
  4150. @end itemize
  4151. @anchor{format}
  4152. @section format
  4153. Convert the input video to one of the specified pixel formats.
  4154. Libavfilter will try to pick one that is suitable as input to
  4155. the next filter.
  4156. It accepts the following parameters:
  4157. @table @option
  4158. @item pix_fmts
  4159. A '|'-separated list of pixel format names, such as
  4160. "pix_fmts=yuv420p|monow|rgb24".
  4161. @end table
  4162. @subsection Examples
  4163. @itemize
  4164. @item
  4165. Convert the input video to the @var{yuv420p} format
  4166. @example
  4167. format=pix_fmts=yuv420p
  4168. @end example
  4169. Convert the input video to any of the formats in the list
  4170. @example
  4171. format=pix_fmts=yuv420p|yuv444p|yuv410p
  4172. @end example
  4173. @end itemize
  4174. @anchor{fps}
  4175. @section fps
  4176. Convert the video to specified constant frame rate by duplicating or dropping
  4177. frames as necessary.
  4178. It accepts the following parameters:
  4179. @table @option
  4180. @item fps
  4181. The desired output frame rate. The default is @code{25}.
  4182. @item round
  4183. Rounding method.
  4184. Possible values are:
  4185. @table @option
  4186. @item zero
  4187. zero round towards 0
  4188. @item inf
  4189. round away from 0
  4190. @item down
  4191. round towards -infinity
  4192. @item up
  4193. round towards +infinity
  4194. @item near
  4195. round to nearest
  4196. @end table
  4197. The default is @code{near}.
  4198. @item start_time
  4199. Assume the first PTS should be the given value, in seconds. This allows for
  4200. padding/trimming at the start of stream. By default, no assumption is made
  4201. about the first frame's expected PTS, so no padding or trimming is done.
  4202. For example, this could be set to 0 to pad the beginning with duplicates of
  4203. the first frame if a video stream starts after the audio stream or to trim any
  4204. frames with a negative PTS.
  4205. @end table
  4206. Alternatively, the options can be specified as a flat string:
  4207. @var{fps}[:@var{round}].
  4208. See also the @ref{setpts} filter.
  4209. @subsection Examples
  4210. @itemize
  4211. @item
  4212. A typical usage in order to set the fps to 25:
  4213. @example
  4214. fps=fps=25
  4215. @end example
  4216. @item
  4217. Sets the fps to 24, using abbreviation and rounding method to round to nearest:
  4218. @example
  4219. fps=fps=film:round=near
  4220. @end example
  4221. @end itemize
  4222. @section framepack
  4223. Pack two different video streams into a stereoscopic video, setting proper
  4224. metadata on supported codecs. The two views should have the same size and
  4225. framerate and processing will stop when the shorter video ends. Please note
  4226. that you may conveniently adjust view properties with the @ref{scale} and
  4227. @ref{fps} filters.
  4228. It accepts the following parameters:
  4229. @table @option
  4230. @item format
  4231. The desired packing format. Supported values are:
  4232. @table @option
  4233. @item sbs
  4234. The views are next to each other (default).
  4235. @item tab
  4236. The views are on top of each other.
  4237. @item lines
  4238. The views are packed by line.
  4239. @item columns
  4240. The views are packed by column.
  4241. @item frameseq
  4242. The views are temporally interleaved.
  4243. @end table
  4244. @end table
  4245. Some examples:
  4246. @example
  4247. # Convert left and right views into a frame-sequential video
  4248. ffmpeg -i LEFT -i RIGHT -filter_complex framepack=frameseq OUTPUT
  4249. # Convert views into a side-by-side video with the same output resolution as the input
  4250. ffmpeg -i LEFT -i RIGHT -filter_complex [0:v]scale=w=iw/2[left],[1:v]scale=w=iw/2[right],[left][right]framepack=sbs OUTPUT
  4251. @end example
  4252. @section framestep
  4253. Select one frame every N-th frame.
  4254. This filter accepts the following option:
  4255. @table @option
  4256. @item step
  4257. Select frame after every @code{step} frames.
  4258. Allowed values are positive integers higher than 0. Default value is @code{1}.
  4259. @end table
  4260. @anchor{frei0r}
  4261. @section frei0r
  4262. Apply a frei0r effect to the input video.
  4263. To enable the compilation of this filter, you need to install the frei0r
  4264. header and configure FFmpeg with @code{--enable-frei0r}.
  4265. It accepts the following parameters:
  4266. @table @option
  4267. @item filter_name
  4268. The name of the frei0r effect to load. If the environment variable
  4269. @env{FREI0R_PATH} is defined, the frei0r effect is searched for in each of the
  4270. directories specified by the colon-separated list in @env{FREIOR_PATH}.
  4271. Otherwise, the standard frei0r paths are searched, in this order:
  4272. @file{HOME/.frei0r-1/lib/}, @file{/usr/local/lib/frei0r-1/},
  4273. @file{/usr/lib/frei0r-1/}.
  4274. @item filter_params
  4275. A '|'-separated list of parameters to pass to the frei0r effect.
  4276. @end table
  4277. A frei0r effect parameter can be a boolean (its value is either
  4278. "y" or "n"), a double, a color (specified as
  4279. @var{R}/@var{G}/@var{B}, where @var{R}, @var{G}, and @var{B} are floating point
  4280. numbers between 0.0 and 1.0, inclusive) or by a color description specified in the "Color"
  4281. section in the ffmpeg-utils manual), a position (specified as @var{X}/@var{Y}, where
  4282. @var{X} and @var{Y} are floating point numbers) and/or a string.
  4283. The number and types of parameters depend on the loaded effect. If an
  4284. effect parameter is not specified, the default value is set.
  4285. @subsection Examples
  4286. @itemize
  4287. @item
  4288. Apply the distort0r effect, setting the first two double parameters:
  4289. @example
  4290. frei0r=filter_name=distort0r:filter_params=0.5|0.01
  4291. @end example
  4292. @item
  4293. Apply the colordistance effect, taking a color as the first parameter:
  4294. @example
  4295. frei0r=colordistance:0.2/0.3/0.4
  4296. frei0r=colordistance:violet
  4297. frei0r=colordistance:0x112233
  4298. @end example
  4299. @item
  4300. Apply the perspective effect, specifying the top left and top right image
  4301. positions:
  4302. @example
  4303. frei0r=perspective:0.2/0.2|0.8/0.2
  4304. @end example
  4305. @end itemize
  4306. For more information, see
  4307. @url{http://frei0r.dyne.org}
  4308. @section fspp
  4309. Apply fast and simple postprocessing. It is a faster version of @ref{spp}.
  4310. It splits (I)DCT into horizontal/vertical passes. Unlike the simple post-
  4311. processing filter, one of them is performed once per block, not per pixel.
  4312. This allows for much higher speed.
  4313. The filter accepts the following options:
  4314. @table @option
  4315. @item quality
  4316. Set quality. This option defines the number of levels for averaging. It accepts
  4317. an integer in the range 4-5. Default value is @code{4}.
  4318. @item qp
  4319. Force a constant quantization parameter. It accepts an integer in range 0-63.
  4320. If not set, the filter will use the QP from the video stream (if available).
  4321. @item strength
  4322. Set filter strength. It accepts an integer in range -15 to 32. Lower values mean
  4323. more details but also more artifacts, while higher values make the image smoother
  4324. but also blurrier. Default value is @code{0} − PSNR optimal.
  4325. @item use_bframe_qp
  4326. Enable the use of the QP from the B-Frames if set to @code{1}. Using this
  4327. option may cause flicker since the B-Frames have often larger QP. Default is
  4328. @code{0} (not enabled).
  4329. @end table
  4330. @section geq
  4331. The filter accepts the following options:
  4332. @table @option
  4333. @item lum_expr, lum
  4334. Set the luminance expression.
  4335. @item cb_expr, cb
  4336. Set the chrominance blue expression.
  4337. @item cr_expr, cr
  4338. Set the chrominance red expression.
  4339. @item alpha_expr, a
  4340. Set the alpha expression.
  4341. @item red_expr, r
  4342. Set the red expression.
  4343. @item green_expr, g
  4344. Set the green expression.
  4345. @item blue_expr, b
  4346. Set the blue expression.
  4347. @end table
  4348. The colorspace is selected according to the specified options. If one
  4349. of the @option{lum_expr}, @option{cb_expr}, or @option{cr_expr}
  4350. options is specified, the filter will automatically select a YCbCr
  4351. colorspace. If one of the @option{red_expr}, @option{green_expr}, or
  4352. @option{blue_expr} options is specified, it will select an RGB
  4353. colorspace.
  4354. If one of the chrominance expression is not defined, it falls back on the other
  4355. one. If no alpha expression is specified it will evaluate to opaque value.
  4356. If none of chrominance expressions are specified, they will evaluate
  4357. to the luminance expression.
  4358. The expressions can use the following variables and functions:
  4359. @table @option
  4360. @item N
  4361. The sequential number of the filtered frame, starting from @code{0}.
  4362. @item X
  4363. @item Y
  4364. The coordinates of the current sample.
  4365. @item W
  4366. @item H
  4367. The width and height of the image.
  4368. @item SW
  4369. @item SH
  4370. Width and height scale depending on the currently filtered plane. It is the
  4371. ratio between the corresponding luma plane number of pixels and the current
  4372. plane ones. E.g. for YUV4:2:0 the values are @code{1,1} for the luma plane, and
  4373. @code{0.5,0.5} for chroma planes.
  4374. @item T
  4375. Time of the current frame, expressed in seconds.
  4376. @item p(x, y)
  4377. Return the value of the pixel at location (@var{x},@var{y}) of the current
  4378. plane.
  4379. @item lum(x, y)
  4380. Return the value of the pixel at location (@var{x},@var{y}) of the luminance
  4381. plane.
  4382. @item cb(x, y)
  4383. Return the value of the pixel at location (@var{x},@var{y}) of the
  4384. blue-difference chroma plane. Return 0 if there is no such plane.
  4385. @item cr(x, y)
  4386. Return the value of the pixel at location (@var{x},@var{y}) of the
  4387. red-difference chroma plane. Return 0 if there is no such plane.
  4388. @item r(x, y)
  4389. @item g(x, y)
  4390. @item b(x, y)
  4391. Return the value of the pixel at location (@var{x},@var{y}) of the
  4392. red/green/blue component. Return 0 if there is no such component.
  4393. @item alpha(x, y)
  4394. Return the value of the pixel at location (@var{x},@var{y}) of the alpha
  4395. plane. Return 0 if there is no such plane.
  4396. @end table
  4397. For functions, if @var{x} and @var{y} are outside the area, the value will be
  4398. automatically clipped to the closer edge.
  4399. @subsection Examples
  4400. @itemize
  4401. @item
  4402. Flip the image horizontally:
  4403. @example
  4404. geq=p(W-X\,Y)
  4405. @end example
  4406. @item
  4407. Generate a bidimensional sine wave, with angle @code{PI/3} and a
  4408. wavelength of 100 pixels:
  4409. @example
  4410. geq=128 + 100*sin(2*(PI/100)*(cos(PI/3)*(X-50*T) + sin(PI/3)*Y)):128:128
  4411. @end example
  4412. @item
  4413. Generate a fancy enigmatic moving light:
  4414. @example
  4415. nullsrc=s=256x256,geq=random(1)/hypot(X-cos(N*0.07)*W/2-W/2\,Y-sin(N*0.09)*H/2-H/2)^2*1000000*sin(N*0.02):128:128
  4416. @end example
  4417. @item
  4418. Generate a quick emboss effect:
  4419. @example
  4420. format=gray,geq=lum_expr='(p(X,Y)+(256-p(X-4,Y-4)))/2'
  4421. @end example
  4422. @item
  4423. Modify RGB components depending on pixel position:
  4424. @example
  4425. geq=r='X/W*r(X,Y)':g='(1-X/W)*g(X,Y)':b='(H-Y)/H*b(X,Y)'
  4426. @end example
  4427. @item
  4428. Create a radial gradient that is the same size as the input (also see
  4429. the @ref{vignette} filter):
  4430. @example
  4431. geq=lum=255*gauss((X/W-0.5)*3)*gauss((Y/H-0.5)*3)/gauss(0)/gauss(0),format=gray
  4432. @end example
  4433. @item
  4434. Create a linear gradient to use as a mask for another filter, then
  4435. compose with @ref{overlay}. In this example the video will gradually
  4436. become more blurry from the top to the bottom of the y-axis as defined
  4437. by the linear gradient:
  4438. @example
  4439. ffmpeg -i input.mp4 -filter_complex "geq=lum=255*(Y/H),format=gray[grad];[0:v]boxblur=4[blur];[blur][grad]alphamerge[alpha];[0:v][alpha]overlay" output.mp4
  4440. @end example
  4441. @end itemize
  4442. @section gradfun
  4443. Fix the banding artifacts that are sometimes introduced into nearly flat
  4444. regions by truncation to 8bit color depth.
  4445. Interpolate the gradients that should go where the bands are, and
  4446. dither them.
  4447. It is designed for playback only. Do not use it prior to
  4448. lossy compression, because compression tends to lose the dither and
  4449. bring back the bands.
  4450. It accepts the following parameters:
  4451. @table @option
  4452. @item strength
  4453. The maximum amount by which the filter will change any one pixel. This is also
  4454. the threshold for detecting nearly flat regions. Acceptable values range from
  4455. .51 to 64; the default value is 1.2. Out-of-range values will be clipped to the
  4456. valid range.
  4457. @item radius
  4458. The neighborhood to fit the gradient to. A larger radius makes for smoother
  4459. gradients, but also prevents the filter from modifying the pixels near detailed
  4460. regions. Acceptable values are 8-32; the default value is 16. Out-of-range
  4461. values will be clipped to the valid range.
  4462. @end table
  4463. Alternatively, the options can be specified as a flat string:
  4464. @var{strength}[:@var{radius}]
  4465. @subsection Examples
  4466. @itemize
  4467. @item
  4468. Apply the filter with a @code{3.5} strength and radius of @code{8}:
  4469. @example
  4470. gradfun=3.5:8
  4471. @end example
  4472. @item
  4473. Specify radius, omitting the strength (which will fall-back to the default
  4474. value):
  4475. @example
  4476. gradfun=radius=8
  4477. @end example
  4478. @end itemize
  4479. @anchor{haldclut}
  4480. @section haldclut
  4481. Apply a Hald CLUT to a video stream.
  4482. First input is the video stream to process, and second one is the Hald CLUT.
  4483. The Hald CLUT input can be a simple picture or a complete video stream.
  4484. The filter accepts the following options:
  4485. @table @option
  4486. @item shortest
  4487. Force termination when the shortest input terminates. Default is @code{0}.
  4488. @item repeatlast
  4489. Continue applying the last CLUT after the end of the stream. A value of
  4490. @code{0} disable the filter after the last frame of the CLUT is reached.
  4491. Default is @code{1}.
  4492. @end table
  4493. @code{haldclut} also has the same interpolation options as @ref{lut3d} (both
  4494. filters share the same internals).
  4495. More information about the Hald CLUT can be found on Eskil Steenberg's website
  4496. (Hald CLUT author) at @url{http://www.quelsolaar.com/technology/clut.html}.
  4497. @subsection Workflow examples
  4498. @subsubsection Hald CLUT video stream
  4499. Generate an identity Hald CLUT stream altered with various effects:
  4500. @example
  4501. ffmpeg -f lavfi -i @ref{haldclutsrc}=8 -vf "hue=H=2*PI*t:s=sin(2*PI*t)+1, curves=cross_process" -t 10 -c:v ffv1 clut.nut
  4502. @end example
  4503. Note: make sure you use a lossless codec.
  4504. Then use it with @code{haldclut} to apply it on some random stream:
  4505. @example
  4506. ffmpeg -f lavfi -i mandelbrot -i clut.nut -filter_complex '[0][1] haldclut' -t 20 mandelclut.mkv
  4507. @end example
  4508. The Hald CLUT will be applied to the 10 first seconds (duration of
  4509. @file{clut.nut}), then the latest picture of that CLUT stream will be applied
  4510. to the remaining frames of the @code{mandelbrot} stream.
  4511. @subsubsection Hald CLUT with preview
  4512. A Hald CLUT is supposed to be a squared image of @code{Level*Level*Level} by
  4513. @code{Level*Level*Level} pixels. For a given Hald CLUT, FFmpeg will select the
  4514. biggest possible square starting at the top left of the picture. The remaining
  4515. padding pixels (bottom or right) will be ignored. This area can be used to add
  4516. a preview of the Hald CLUT.
  4517. Typically, the following generated Hald CLUT will be supported by the
  4518. @code{haldclut} filter:
  4519. @example
  4520. ffmpeg -f lavfi -i @ref{haldclutsrc}=8 -vf "
  4521. pad=iw+320 [padded_clut];
  4522. smptebars=s=320x256, split [a][b];
  4523. [padded_clut][a] overlay=W-320:h, curves=color_negative [main];
  4524. [main][b] overlay=W-320" -frames:v 1 clut.png
  4525. @end example
  4526. It contains the original and a preview of the effect of the CLUT: SMPTE color
  4527. bars are displayed on the right-top, and below the same color bars processed by
  4528. the color changes.
  4529. Then, the effect of this Hald CLUT can be visualized with:
  4530. @example
  4531. ffplay input.mkv -vf "movie=clut.png, [in] haldclut"
  4532. @end example
  4533. @section hflip
  4534. Flip the input video horizontally.
  4535. For example, to horizontally flip the input video with @command{ffmpeg}:
  4536. @example
  4537. ffmpeg -i in.avi -vf "hflip" out.avi
  4538. @end example
  4539. @section histeq
  4540. This filter applies a global color histogram equalization on a
  4541. per-frame basis.
  4542. It can be used to correct video that has a compressed range of pixel
  4543. intensities. The filter redistributes the pixel intensities to
  4544. equalize their distribution across the intensity range. It may be
  4545. viewed as an "automatically adjusting contrast filter". This filter is
  4546. useful only for correcting degraded or poorly captured source
  4547. video.
  4548. The filter accepts the following options:
  4549. @table @option
  4550. @item strength
  4551. Determine the amount of equalization to be applied. As the strength
  4552. is reduced, the distribution of pixel intensities more-and-more
  4553. approaches that of the input frame. The value must be a float number
  4554. in the range [0,1] and defaults to 0.200.
  4555. @item intensity
  4556. Set the maximum intensity that can generated and scale the output
  4557. values appropriately. The strength should be set as desired and then
  4558. the intensity can be limited if needed to avoid washing-out. The value
  4559. must be a float number in the range [0,1] and defaults to 0.210.
  4560. @item antibanding
  4561. Set the antibanding level. If enabled the filter will randomly vary
  4562. the luminance of output pixels by a small amount to avoid banding of
  4563. the histogram. Possible values are @code{none}, @code{weak} or
  4564. @code{strong}. It defaults to @code{none}.
  4565. @end table
  4566. @section histogram
  4567. Compute and draw a color distribution histogram for the input video.
  4568. The computed histogram is a representation of the color component
  4569. distribution in an image.
  4570. The filter accepts the following options:
  4571. @table @option
  4572. @item mode
  4573. Set histogram mode.
  4574. It accepts the following values:
  4575. @table @samp
  4576. @item levels
  4577. Standard histogram that displays the color components distribution in an
  4578. image. Displays color graph for each color component. Shows distribution of
  4579. the Y, U, V, A or R, G, B components, depending on input format, in the
  4580. current frame. Below each graph a color component scale meter is shown.
  4581. @item color
  4582. Displays chroma values (U/V color placement) in a two dimensional
  4583. graph (which is called a vectorscope). The brighter a pixel in the
  4584. vectorscope, the more pixels of the input frame correspond to that pixel
  4585. (i.e., more pixels have this chroma value). The V component is displayed on
  4586. the horizontal (X) axis, with the leftmost side being V = 0 and the rightmost
  4587. side being V = 255. The U component is displayed on the vertical (Y) axis,
  4588. with the top representing U = 0 and the bottom representing U = 255.
  4589. The position of a white pixel in the graph corresponds to the chroma value of
  4590. a pixel of the input clip. The graph can therefore be used to read the hue
  4591. (color flavor) and the saturation (the dominance of the hue in the color). As
  4592. the hue of a color changes, it moves around the square. At the center of the
  4593. square the saturation is zero, which means that the corresponding pixel has no
  4594. color. If the amount of a specific color is increased (while leaving the other
  4595. colors unchanged) the saturation increases, and the indicator moves towards
  4596. the edge of the square.
  4597. @item color2
  4598. Chroma values in vectorscope, similar as @code{color} but actual chroma values
  4599. are displayed.
  4600. @item waveform
  4601. Per row/column color component graph. In row mode, the graph on the left side
  4602. represents color component value 0 and the right side represents value = 255.
  4603. In column mode, the top side represents color component value = 0 and bottom
  4604. side represents value = 255.
  4605. @end table
  4606. Default value is @code{levels}.
  4607. @item level_height
  4608. Set height of level in @code{levels}. Default value is @code{200}.
  4609. Allowed range is [50, 2048].
  4610. @item scale_height
  4611. Set height of color scale in @code{levels}. Default value is @code{12}.
  4612. Allowed range is [0, 40].
  4613. @item step
  4614. Set step for @code{waveform} mode. Smaller values are useful to find out how
  4615. many values of the same luminance are distributed across input rows/columns.
  4616. Default value is @code{10}. Allowed range is [1, 255].
  4617. @item waveform_mode
  4618. Set mode for @code{waveform}. Can be either @code{row}, or @code{column}.
  4619. Default is @code{row}.
  4620. @item waveform_mirror
  4621. Set mirroring mode for @code{waveform}. @code{0} means unmirrored, @code{1}
  4622. means mirrored. In mirrored mode, higher values will be represented on the left
  4623. side for @code{row} mode and at the top for @code{column} mode. Default is
  4624. @code{0} (unmirrored).
  4625. @item display_mode
  4626. Set display mode for @code{waveform} and @code{levels}.
  4627. It accepts the following values:
  4628. @table @samp
  4629. @item parade
  4630. Display separate graph for the color components side by side in
  4631. @code{row} waveform mode or one below the other in @code{column} waveform mode
  4632. for @code{waveform} histogram mode. For @code{levels} histogram mode,
  4633. per color component graphs are placed below each other.
  4634. Using this display mode in @code{waveform} histogram mode makes it easy to
  4635. spot color casts in the highlights and shadows of an image, by comparing the
  4636. contours of the top and the bottom graphs of each waveform. Since whites,
  4637. grays, and blacks are characterized by exactly equal amounts of red, green,
  4638. and blue, neutral areas of the picture should display three waveforms of
  4639. roughly equal width/height. If not, the correction is easy to perform by
  4640. making level adjustments the three waveforms.
  4641. @item overlay
  4642. Presents information identical to that in the @code{parade}, except
  4643. that the graphs representing color components are superimposed directly
  4644. over one another.
  4645. This display mode in @code{waveform} histogram mode makes it easier to spot
  4646. relative differences or similarities in overlapping areas of the color
  4647. components that are supposed to be identical, such as neutral whites, grays,
  4648. or blacks.
  4649. @end table
  4650. Default is @code{parade}.
  4651. @item levels_mode
  4652. Set mode for @code{levels}. Can be either @code{linear}, or @code{logarithmic}.
  4653. Default is @code{linear}.
  4654. @end table
  4655. @subsection Examples
  4656. @itemize
  4657. @item
  4658. Calculate and draw histogram:
  4659. @example
  4660. ffplay -i input -vf histogram
  4661. @end example
  4662. @end itemize
  4663. @anchor{hqdn3d}
  4664. @section hqdn3d
  4665. This is a high precision/quality 3d denoise filter. It aims to reduce
  4666. image noise, producing smooth images and making still images really
  4667. still. It should enhance compressibility.
  4668. It accepts the following optional parameters:
  4669. @table @option
  4670. @item luma_spatial
  4671. A non-negative floating point number which specifies spatial luma strength.
  4672. It defaults to 4.0.
  4673. @item chroma_spatial
  4674. A non-negative floating point number which specifies spatial chroma strength.
  4675. It defaults to 3.0*@var{luma_spatial}/4.0.
  4676. @item luma_tmp
  4677. A floating point number which specifies luma temporal strength. It defaults to
  4678. 6.0*@var{luma_spatial}/4.0.
  4679. @item chroma_tmp
  4680. A floating point number which specifies chroma temporal strength. It defaults to
  4681. @var{luma_tmp}*@var{chroma_spatial}/@var{luma_spatial}.
  4682. @end table
  4683. @section hqx
  4684. Apply a high-quality magnification filter designed for pixel art. This filter
  4685. was originally created by Maxim Stepin.
  4686. It accepts the following option:
  4687. @table @option
  4688. @item n
  4689. Set the scaling dimension: @code{2} for @code{hq2x}, @code{3} for
  4690. @code{hq3x} and @code{4} for @code{hq4x}.
  4691. Default is @code{3}.
  4692. @end table
  4693. @section hue
  4694. Modify the hue and/or the saturation of the input.
  4695. It accepts the following parameters:
  4696. @table @option
  4697. @item h
  4698. Specify the hue angle as a number of degrees. It accepts an expression,
  4699. and defaults to "0".
  4700. @item s
  4701. Specify the saturation in the [-10,10] range. It accepts an expression and
  4702. defaults to "1".
  4703. @item H
  4704. Specify the hue angle as a number of radians. It accepts an
  4705. expression, and defaults to "0".
  4706. @item b
  4707. Specify the brightness in the [-10,10] range. It accepts an expression and
  4708. defaults to "0".
  4709. @end table
  4710. @option{h} and @option{H} are mutually exclusive, and can't be
  4711. specified at the same time.
  4712. The @option{b}, @option{h}, @option{H} and @option{s} option values are
  4713. expressions containing the following constants:
  4714. @table @option
  4715. @item n
  4716. frame count of the input frame starting from 0
  4717. @item pts
  4718. presentation timestamp of the input frame expressed in time base units
  4719. @item r
  4720. frame rate of the input video, NAN if the input frame rate is unknown
  4721. @item t
  4722. timestamp expressed in seconds, NAN if the input timestamp is unknown
  4723. @item tb
  4724. time base of the input video
  4725. @end table
  4726. @subsection Examples
  4727. @itemize
  4728. @item
  4729. Set the hue to 90 degrees and the saturation to 1.0:
  4730. @example
  4731. hue=h=90:s=1
  4732. @end example
  4733. @item
  4734. Same command but expressing the hue in radians:
  4735. @example
  4736. hue=H=PI/2:s=1
  4737. @end example
  4738. @item
  4739. Rotate hue and make the saturation swing between 0
  4740. and 2 over a period of 1 second:
  4741. @example
  4742. hue="H=2*PI*t: s=sin(2*PI*t)+1"
  4743. @end example
  4744. @item
  4745. Apply a 3 seconds saturation fade-in effect starting at 0:
  4746. @example
  4747. hue="s=min(t/3\,1)"
  4748. @end example
  4749. The general fade-in expression can be written as:
  4750. @example
  4751. hue="s=min(0\, max((t-START)/DURATION\, 1))"
  4752. @end example
  4753. @item
  4754. Apply a 3 seconds saturation fade-out effect starting at 5 seconds:
  4755. @example
  4756. hue="s=max(0\, min(1\, (8-t)/3))"
  4757. @end example
  4758. The general fade-out expression can be written as:
  4759. @example
  4760. hue="s=max(0\, min(1\, (START+DURATION-t)/DURATION))"
  4761. @end example
  4762. @end itemize
  4763. @subsection Commands
  4764. This filter supports the following commands:
  4765. @table @option
  4766. @item b
  4767. @item s
  4768. @item h
  4769. @item H
  4770. Modify the hue and/or the saturation and/or brightness of the input video.
  4771. The command accepts the same syntax of the corresponding option.
  4772. If the specified expression is not valid, it is kept at its current
  4773. value.
  4774. @end table
  4775. @section idet
  4776. Detect video interlacing type.
  4777. This filter tries to detect if the input frames as interlaced, progressive,
  4778. top or bottom field first. It will also try and detect fields that are
  4779. repeated between adjacent frames (a sign of telecine).
  4780. Single frame detection considers only immediately adjacent frames when classifying each frame.
  4781. Multiple frame detection incorporates the classification history of previous frames.
  4782. The filter will log these metadata values:
  4783. @table @option
  4784. @item single.current_frame
  4785. Detected type of current frame using single-frame detection. One of:
  4786. ``tff'' (top field first), ``bff'' (bottom field first),
  4787. ``progressive'', or ``undetermined''
  4788. @item single.tff
  4789. Cumulative number of frames detected as top field first using single-frame detection.
  4790. @item multiple.tff
  4791. Cumulative number of frames detected as top field first using multiple-frame detection.
  4792. @item single.bff
  4793. Cumulative number of frames detected as bottom field first using single-frame detection.
  4794. @item multiple.current_frame
  4795. Detected type of current frame using multiple-frame detection. One of:
  4796. ``tff'' (top field first), ``bff'' (bottom field first),
  4797. ``progressive'', or ``undetermined''
  4798. @item multiple.bff
  4799. Cumulative number of frames detected as bottom field first using multiple-frame detection.
  4800. @item single.progressive
  4801. Cumulative number of frames detected as progressive using single-frame detection.
  4802. @item multiple.progressive
  4803. Cumulative number of frames detected as progressive using multiple-frame detection.
  4804. @item single.undetermined
  4805. Cumulative number of frames that could not be classified using single-frame detection.
  4806. @item multiple.undetermined
  4807. Cumulative number of frames that could not be classified using multiple-frame detection.
  4808. @item repeated.current_frame
  4809. Which field in the current frame is repeated from the last. One of ``neither'', ``top'', or ``bottom''.
  4810. @item repeated.neither
  4811. Cumulative number of frames with no repeated field.
  4812. @item repeated.top
  4813. Cumulative number of frames with the top field repeated from the previous frame's top field.
  4814. @item repeated.bottom
  4815. Cumulative number of frames with the bottom field repeated from the previous frame's bottom field.
  4816. @end table
  4817. The filter accepts the following options:
  4818. @table @option
  4819. @item intl_thres
  4820. Set interlacing threshold.
  4821. @item prog_thres
  4822. Set progressive threshold.
  4823. @item repeat_thres
  4824. Threshold for repeated field detection.
  4825. @item half_life
  4826. Number of frames after which a given frame's contribution to the
  4827. statistics is halved (i.e., it contributes only 0.5 to it's
  4828. classification). The default of 0 means that all frames seen are given
  4829. full weight of 1.0 forever.
  4830. @item analyze_interlaced_flag
  4831. When this is not 0 then idet will use the specified number of frames to determine
  4832. if the interlaced flag is accurate, it will not count undetermined frames.
  4833. If the flag is found to be accurate it will be used without any further
  4834. computations, if it is found to be inaccurate it will be cleared without any
  4835. further computations. This allows inserting the idet filter as a low computational
  4836. method to clean up the interlaced flag
  4837. @end table
  4838. @section il
  4839. Deinterleave or interleave fields.
  4840. This filter allows one to process interlaced images fields without
  4841. deinterlacing them. Deinterleaving splits the input frame into 2
  4842. fields (so called half pictures). Odd lines are moved to the top
  4843. half of the output image, even lines to the bottom half.
  4844. You can process (filter) them independently and then re-interleave them.
  4845. The filter accepts the following options:
  4846. @table @option
  4847. @item luma_mode, l
  4848. @item chroma_mode, c
  4849. @item alpha_mode, a
  4850. Available values for @var{luma_mode}, @var{chroma_mode} and
  4851. @var{alpha_mode} are:
  4852. @table @samp
  4853. @item none
  4854. Do nothing.
  4855. @item deinterleave, d
  4856. Deinterleave fields, placing one above the other.
  4857. @item interleave, i
  4858. Interleave fields. Reverse the effect of deinterleaving.
  4859. @end table
  4860. Default value is @code{none}.
  4861. @item luma_swap, ls
  4862. @item chroma_swap, cs
  4863. @item alpha_swap, as
  4864. Swap luma/chroma/alpha fields. Exchange even & odd lines. Default value is @code{0}.
  4865. @end table
  4866. @section interlace
  4867. Simple interlacing filter from progressive contents. This interleaves upper (or
  4868. lower) lines from odd frames with lower (or upper) lines from even frames,
  4869. halving the frame rate and preserving image height.
  4870. @example
  4871. Original Original New Frame
  4872. Frame 'j' Frame 'j+1' (tff)
  4873. ========== =========== ==================
  4874. Line 0 --------------------> Frame 'j' Line 0
  4875. Line 1 Line 1 ----> Frame 'j+1' Line 1
  4876. Line 2 ---------------------> Frame 'j' Line 2
  4877. Line 3 Line 3 ----> Frame 'j+1' Line 3
  4878. ... ... ...
  4879. New Frame + 1 will be generated by Frame 'j+2' and Frame 'j+3' and so on
  4880. @end example
  4881. It accepts the following optional parameters:
  4882. @table @option
  4883. @item scan
  4884. This determines whether the interlaced frame is taken from the even
  4885. (tff - default) or odd (bff) lines of the progressive frame.
  4886. @item lowpass
  4887. Enable (default) or disable the vertical lowpass filter to avoid twitter
  4888. interlacing and reduce moire patterns.
  4889. @end table
  4890. @section kerndeint
  4891. Deinterlace input video by applying Donald Graft's adaptive kernel
  4892. deinterling. Work on interlaced parts of a video to produce
  4893. progressive frames.
  4894. The description of the accepted parameters follows.
  4895. @table @option
  4896. @item thresh
  4897. Set the threshold which affects the filter's tolerance when
  4898. determining if a pixel line must be processed. It must be an integer
  4899. in the range [0,255] and defaults to 10. A value of 0 will result in
  4900. applying the process on every pixels.
  4901. @item map
  4902. Paint pixels exceeding the threshold value to white if set to 1.
  4903. Default is 0.
  4904. @item order
  4905. Set the fields order. Swap fields if set to 1, leave fields alone if
  4906. 0. Default is 0.
  4907. @item sharp
  4908. Enable additional sharpening if set to 1. Default is 0.
  4909. @item twoway
  4910. Enable twoway sharpening if set to 1. Default is 0.
  4911. @end table
  4912. @subsection Examples
  4913. @itemize
  4914. @item
  4915. Apply default values:
  4916. @example
  4917. kerndeint=thresh=10:map=0:order=0:sharp=0:twoway=0
  4918. @end example
  4919. @item
  4920. Enable additional sharpening:
  4921. @example
  4922. kerndeint=sharp=1
  4923. @end example
  4924. @item
  4925. Paint processed pixels in white:
  4926. @example
  4927. kerndeint=map=1
  4928. @end example
  4929. @end itemize
  4930. @section lenscorrection
  4931. Correct radial lens distortion
  4932. This filter can be used to correct for radial distortion as can result from the use
  4933. of wide angle lenses, and thereby re-rectify the image. To find the right parameters
  4934. one can use tools available for example as part of opencv or simply trial-and-error.
  4935. To use opencv use the calibration sample (under samples/cpp) from the opencv sources
  4936. and extract the k1 and k2 coefficients from the resulting matrix.
  4937. Note that effectively the same filter is available in the open-source tools Krita and
  4938. Digikam from the KDE project.
  4939. In contrast to the @ref{vignette} filter, which can also be used to compensate lens errors,
  4940. this filter corrects the distortion of the image, whereas @ref{vignette} corrects the
  4941. brightness distribution, so you may want to use both filters together in certain
  4942. cases, though you will have to take care of ordering, i.e. whether vignetting should
  4943. be applied before or after lens correction.
  4944. @subsection Options
  4945. The filter accepts the following options:
  4946. @table @option
  4947. @item cx
  4948. Relative x-coordinate of the focal point of the image, and thereby the center of the
  4949. distortion. This value has a range [0,1] and is expressed as fractions of the image
  4950. width.
  4951. @item cy
  4952. Relative y-coordinate of the focal point of the image, and thereby the center of the
  4953. distortion. This value has a range [0,1] and is expressed as fractions of the image
  4954. height.
  4955. @item k1
  4956. Coefficient of the quadratic correction term. 0.5 means no correction.
  4957. @item k2
  4958. Coefficient of the double quadratic correction term. 0.5 means no correction.
  4959. @end table
  4960. The formula that generates the correction is:
  4961. @var{r_src} = @var{r_tgt} * (1 + @var{k1} * (@var{r_tgt} / @var{r_0})^2 + @var{k2} * (@var{r_tgt} / @var{r_0})^4)
  4962. where @var{r_0} is halve of the image diagonal and @var{r_src} and @var{r_tgt} are the
  4963. distances from the focal point in the source and target images, respectively.
  4964. @anchor{lut3d}
  4965. @section lut3d
  4966. Apply a 3D LUT to an input video.
  4967. The filter accepts the following options:
  4968. @table @option
  4969. @item file
  4970. Set the 3D LUT file name.
  4971. Currently supported formats:
  4972. @table @samp
  4973. @item 3dl
  4974. AfterEffects
  4975. @item cube
  4976. Iridas
  4977. @item dat
  4978. DaVinci
  4979. @item m3d
  4980. Pandora
  4981. @end table
  4982. @item interp
  4983. Select interpolation mode.
  4984. Available values are:
  4985. @table @samp
  4986. @item nearest
  4987. Use values from the nearest defined point.
  4988. @item trilinear
  4989. Interpolate values using the 8 points defining a cube.
  4990. @item tetrahedral
  4991. Interpolate values using a tetrahedron.
  4992. @end table
  4993. @end table
  4994. @section lut, lutrgb, lutyuv
  4995. Compute a look-up table for binding each pixel component input value
  4996. to an output value, and apply it to the input video.
  4997. @var{lutyuv} applies a lookup table to a YUV input video, @var{lutrgb}
  4998. to an RGB input video.
  4999. These filters accept the following parameters:
  5000. @table @option
  5001. @item c0
  5002. set first pixel component expression
  5003. @item c1
  5004. set second pixel component expression
  5005. @item c2
  5006. set third pixel component expression
  5007. @item c3
  5008. set fourth pixel component expression, corresponds to the alpha component
  5009. @item r
  5010. set red component expression
  5011. @item g
  5012. set green component expression
  5013. @item b
  5014. set blue component expression
  5015. @item a
  5016. alpha component expression
  5017. @item y
  5018. set Y/luminance component expression
  5019. @item u
  5020. set U/Cb component expression
  5021. @item v
  5022. set V/Cr component expression
  5023. @end table
  5024. Each of them specifies the expression to use for computing the lookup table for
  5025. the corresponding pixel component values.
  5026. The exact component associated to each of the @var{c*} options depends on the
  5027. format in input.
  5028. The @var{lut} filter requires either YUV or RGB pixel formats in input,
  5029. @var{lutrgb} requires RGB pixel formats in input, and @var{lutyuv} requires YUV.
  5030. The expressions can contain the following constants and functions:
  5031. @table @option
  5032. @item w
  5033. @item h
  5034. The input width and height.
  5035. @item val
  5036. The input value for the pixel component.
  5037. @item clipval
  5038. The input value, clipped to the @var{minval}-@var{maxval} range.
  5039. @item maxval
  5040. The maximum value for the pixel component.
  5041. @item minval
  5042. The minimum value for the pixel component.
  5043. @item negval
  5044. The negated value for the pixel component value, clipped to the
  5045. @var{minval}-@var{maxval} range; it corresponds to the expression
  5046. "maxval-clipval+minval".
  5047. @item clip(val)
  5048. The computed value in @var{val}, clipped to the
  5049. @var{minval}-@var{maxval} range.
  5050. @item gammaval(gamma)
  5051. The computed gamma correction value of the pixel component value,
  5052. clipped to the @var{minval}-@var{maxval} range. It corresponds to the
  5053. expression
  5054. "pow((clipval-minval)/(maxval-minval)\,@var{gamma})*(maxval-minval)+minval"
  5055. @end table
  5056. All expressions default to "val".
  5057. @subsection Examples
  5058. @itemize
  5059. @item
  5060. Negate input video:
  5061. @example
  5062. lutrgb="r=maxval+minval-val:g=maxval+minval-val:b=maxval+minval-val"
  5063. lutyuv="y=maxval+minval-val:u=maxval+minval-val:v=maxval+minval-val"
  5064. @end example
  5065. The above is the same as:
  5066. @example
  5067. lutrgb="r=negval:g=negval:b=negval"
  5068. lutyuv="y=negval:u=negval:v=negval"
  5069. @end example
  5070. @item
  5071. Negate luminance:
  5072. @example
  5073. lutyuv=y=negval
  5074. @end example
  5075. @item
  5076. Remove chroma components, turning the video into a graytone image:
  5077. @example
  5078. lutyuv="u=128:v=128"
  5079. @end example
  5080. @item
  5081. Apply a luma burning effect:
  5082. @example
  5083. lutyuv="y=2*val"
  5084. @end example
  5085. @item
  5086. Remove green and blue components:
  5087. @example
  5088. lutrgb="g=0:b=0"
  5089. @end example
  5090. @item
  5091. Set a constant alpha channel value on input:
  5092. @example
  5093. format=rgba,lutrgb=a="maxval-minval/2"
  5094. @end example
  5095. @item
  5096. Correct luminance gamma by a factor of 0.5:
  5097. @example
  5098. lutyuv=y=gammaval(0.5)
  5099. @end example
  5100. @item
  5101. Discard least significant bits of luma:
  5102. @example
  5103. lutyuv=y='bitand(val, 128+64+32)'
  5104. @end example
  5105. @end itemize
  5106. @section mergeplanes
  5107. Merge color channel components from several video streams.
  5108. The filter accepts up to 4 input streams, and merge selected input
  5109. planes to the output video.
  5110. This filter accepts the following options:
  5111. @table @option
  5112. @item mapping
  5113. Set input to output plane mapping. Default is @code{0}.
  5114. The mappings is specified as a bitmap. It should be specified as a
  5115. hexadecimal number in the form 0xAa[Bb[Cc[Dd]]]. 'Aa' describes the
  5116. mapping for the first plane of the output stream. 'A' sets the number of
  5117. the input stream to use (from 0 to 3), and 'a' the plane number of the
  5118. corresponding input to use (from 0 to 3). The rest of the mappings is
  5119. similar, 'Bb' describes the mapping for the output stream second
  5120. plane, 'Cc' describes the mapping for the output stream third plane and
  5121. 'Dd' describes the mapping for the output stream fourth plane.
  5122. @item format
  5123. Set output pixel format. Default is @code{yuva444p}.
  5124. @end table
  5125. @subsection Examples
  5126. @itemize
  5127. @item
  5128. Merge three gray video streams of same width and height into single video stream:
  5129. @example
  5130. [a0][a1][a2]mergeplanes=0x001020:yuv444p
  5131. @end example
  5132. @item
  5133. Merge 1st yuv444p stream and 2nd gray video stream into yuva444p video stream:
  5134. @example
  5135. [a0][a1]mergeplanes=0x00010210:yuva444p
  5136. @end example
  5137. @item
  5138. Swap Y and A plane in yuva444p stream:
  5139. @example
  5140. format=yuva444p,mergeplanes=0x03010200:yuva444p
  5141. @end example
  5142. @item
  5143. Swap U and V plane in yuv420p stream:
  5144. @example
  5145. format=yuv420p,mergeplanes=0x000201:yuv420p
  5146. @end example
  5147. @item
  5148. Cast a rgb24 clip to yuv444p:
  5149. @example
  5150. format=rgb24,mergeplanes=0x000102:yuv444p
  5151. @end example
  5152. @end itemize
  5153. @section mcdeint
  5154. Apply motion-compensation deinterlacing.
  5155. It needs one field per frame as input and must thus be used together
  5156. with yadif=1/3 or equivalent.
  5157. This filter accepts the following options:
  5158. @table @option
  5159. @item mode
  5160. Set the deinterlacing mode.
  5161. It accepts one of the following values:
  5162. @table @samp
  5163. @item fast
  5164. @item medium
  5165. @item slow
  5166. use iterative motion estimation
  5167. @item extra_slow
  5168. like @samp{slow}, but use multiple reference frames.
  5169. @end table
  5170. Default value is @samp{fast}.
  5171. @item parity
  5172. Set the picture field parity assumed for the input video. It must be
  5173. one of the following values:
  5174. @table @samp
  5175. @item 0, tff
  5176. assume top field first
  5177. @item 1, bff
  5178. assume bottom field first
  5179. @end table
  5180. Default value is @samp{bff}.
  5181. @item qp
  5182. Set per-block quantization parameter (QP) used by the internal
  5183. encoder.
  5184. Higher values should result in a smoother motion vector field but less
  5185. optimal individual vectors. Default value is 1.
  5186. @end table
  5187. @section mpdecimate
  5188. Drop frames that do not differ greatly from the previous frame in
  5189. order to reduce frame rate.
  5190. The main use of this filter is for very-low-bitrate encoding
  5191. (e.g. streaming over dialup modem), but it could in theory be used for
  5192. fixing movies that were inverse-telecined incorrectly.
  5193. A description of the accepted options follows.
  5194. @table @option
  5195. @item max
  5196. Set the maximum number of consecutive frames which can be dropped (if
  5197. positive), or the minimum interval between dropped frames (if
  5198. negative). If the value is 0, the frame is dropped unregarding the
  5199. number of previous sequentially dropped frames.
  5200. Default value is 0.
  5201. @item hi
  5202. @item lo
  5203. @item frac
  5204. Set the dropping threshold values.
  5205. Values for @option{hi} and @option{lo} are for 8x8 pixel blocks and
  5206. represent actual pixel value differences, so a threshold of 64
  5207. corresponds to 1 unit of difference for each pixel, or the same spread
  5208. out differently over the block.
  5209. A frame is a candidate for dropping if no 8x8 blocks differ by more
  5210. than a threshold of @option{hi}, and if no more than @option{frac} blocks (1
  5211. meaning the whole image) differ by more than a threshold of @option{lo}.
  5212. Default value for @option{hi} is 64*12, default value for @option{lo} is
  5213. 64*5, and default value for @option{frac} is 0.33.
  5214. @end table
  5215. @section negate
  5216. Negate input video.
  5217. It accepts an integer in input; if non-zero it negates the
  5218. alpha component (if available). The default value in input is 0.
  5219. @section noformat
  5220. Force libavfilter not to use any of the specified pixel formats for the
  5221. input to the next filter.
  5222. It accepts the following parameters:
  5223. @table @option
  5224. @item pix_fmts
  5225. A '|'-separated list of pixel format names, such as
  5226. apix_fmts=yuv420p|monow|rgb24".
  5227. @end table
  5228. @subsection Examples
  5229. @itemize
  5230. @item
  5231. Force libavfilter to use a format different from @var{yuv420p} for the
  5232. input to the vflip filter:
  5233. @example
  5234. noformat=pix_fmts=yuv420p,vflip
  5235. @end example
  5236. @item
  5237. Convert the input video to any of the formats not contained in the list:
  5238. @example
  5239. noformat=yuv420p|yuv444p|yuv410p
  5240. @end example
  5241. @end itemize
  5242. @section noise
  5243. Add noise on video input frame.
  5244. The filter accepts the following options:
  5245. @table @option
  5246. @item all_seed
  5247. @item c0_seed
  5248. @item c1_seed
  5249. @item c2_seed
  5250. @item c3_seed
  5251. Set noise seed for specific pixel component or all pixel components in case
  5252. of @var{all_seed}. Default value is @code{123457}.
  5253. @item all_strength, alls
  5254. @item c0_strength, c0s
  5255. @item c1_strength, c1s
  5256. @item c2_strength, c2s
  5257. @item c3_strength, c3s
  5258. Set noise strength for specific pixel component or all pixel components in case
  5259. @var{all_strength}. Default value is @code{0}. Allowed range is [0, 100].
  5260. @item all_flags, allf
  5261. @item c0_flags, c0f
  5262. @item c1_flags, c1f
  5263. @item c2_flags, c2f
  5264. @item c3_flags, c3f
  5265. Set pixel component flags or set flags for all components if @var{all_flags}.
  5266. Available values for component flags are:
  5267. @table @samp
  5268. @item a
  5269. averaged temporal noise (smoother)
  5270. @item p
  5271. mix random noise with a (semi)regular pattern
  5272. @item t
  5273. temporal noise (noise pattern changes between frames)
  5274. @item u
  5275. uniform noise (gaussian otherwise)
  5276. @end table
  5277. @end table
  5278. @subsection Examples
  5279. Add temporal and uniform noise to input video:
  5280. @example
  5281. noise=alls=20:allf=t+u
  5282. @end example
  5283. @section null
  5284. Pass the video source unchanged to the output.
  5285. @section ocv
  5286. Apply a video transform using libopencv.
  5287. To enable this filter, install the libopencv library and headers and
  5288. configure FFmpeg with @code{--enable-libopencv}.
  5289. It accepts the following parameters:
  5290. @table @option
  5291. @item filter_name
  5292. The name of the libopencv filter to apply.
  5293. @item filter_params
  5294. The parameters to pass to the libopencv filter. If not specified, the default
  5295. values are assumed.
  5296. @end table
  5297. Refer to the official libopencv documentation for more precise
  5298. information:
  5299. @url{http://docs.opencv.org/master/modules/imgproc/doc/filtering.html}
  5300. Several libopencv filters are supported; see the following subsections.
  5301. @anchor{dilate}
  5302. @subsection dilate
  5303. Dilate an image by using a specific structuring element.
  5304. It corresponds to the libopencv function @code{cvDilate}.
  5305. It accepts the parameters: @var{struct_el}|@var{nb_iterations}.
  5306. @var{struct_el} represents a structuring element, and has the syntax:
  5307. @var{cols}x@var{rows}+@var{anchor_x}x@var{anchor_y}/@var{shape}
  5308. @var{cols} and @var{rows} represent the number of columns and rows of
  5309. the structuring element, @var{anchor_x} and @var{anchor_y} the anchor
  5310. point, and @var{shape} the shape for the structuring element. @var{shape}
  5311. must be "rect", "cross", "ellipse", or "custom".
  5312. If the value for @var{shape} is "custom", it must be followed by a
  5313. string of the form "=@var{filename}". The file with name
  5314. @var{filename} is assumed to represent a binary image, with each
  5315. printable character corresponding to a bright pixel. When a custom
  5316. @var{shape} is used, @var{cols} and @var{rows} are ignored, the number
  5317. or columns and rows of the read file are assumed instead.
  5318. The default value for @var{struct_el} is "3x3+0x0/rect".
  5319. @var{nb_iterations} specifies the number of times the transform is
  5320. applied to the image, and defaults to 1.
  5321. Some examples:
  5322. @example
  5323. # Use the default values
  5324. ocv=dilate
  5325. # Dilate using a structuring element with a 5x5 cross, iterating two times
  5326. ocv=filter_name=dilate:filter_params=5x5+2x2/cross|2
  5327. # Read the shape from the file diamond.shape, iterating two times.
  5328. # The file diamond.shape may contain a pattern of characters like this
  5329. # *
  5330. # ***
  5331. # *****
  5332. # ***
  5333. # *
  5334. # The specified columns and rows are ignored
  5335. # but the anchor point coordinates are not
  5336. ocv=dilate:0x0+2x2/custom=diamond.shape|2
  5337. @end example
  5338. @subsection erode
  5339. Erode an image by using a specific structuring element.
  5340. It corresponds to the libopencv function @code{cvErode}.
  5341. It accepts the parameters: @var{struct_el}:@var{nb_iterations},
  5342. with the same syntax and semantics as the @ref{dilate} filter.
  5343. @subsection smooth
  5344. Smooth the input video.
  5345. The filter takes the following parameters:
  5346. @var{type}|@var{param1}|@var{param2}|@var{param3}|@var{param4}.
  5347. @var{type} is the type of smooth filter to apply, and must be one of
  5348. the following values: "blur", "blur_no_scale", "median", "gaussian",
  5349. or "bilateral". The default value is "gaussian".
  5350. The meaning of @var{param1}, @var{param2}, @var{param3}, and @var{param4}
  5351. depend on the smooth type. @var{param1} and
  5352. @var{param2} accept integer positive values or 0. @var{param3} and
  5353. @var{param4} accept floating point values.
  5354. The default value for @var{param1} is 3. The default value for the
  5355. other parameters is 0.
  5356. These parameters correspond to the parameters assigned to the
  5357. libopencv function @code{cvSmooth}.
  5358. @anchor{overlay}
  5359. @section overlay
  5360. Overlay one video on top of another.
  5361. It takes two inputs and has one output. The first input is the "main"
  5362. video on which the second input is overlaid.
  5363. It accepts the following parameters:
  5364. A description of the accepted options follows.
  5365. @table @option
  5366. @item x
  5367. @item y
  5368. Set the expression for the x and y coordinates of the overlaid video
  5369. on the main video. Default value is "0" for both expressions. In case
  5370. the expression is invalid, it is set to a huge value (meaning that the
  5371. overlay will not be displayed within the output visible area).
  5372. @item eof_action
  5373. The action to take when EOF is encountered on the secondary input; it accepts
  5374. one of the following values:
  5375. @table @option
  5376. @item repeat
  5377. Repeat the last frame (the default).
  5378. @item endall
  5379. End both streams.
  5380. @item pass
  5381. Pass the main input through.
  5382. @end table
  5383. @item eval
  5384. Set when the expressions for @option{x}, and @option{y} are evaluated.
  5385. It accepts the following values:
  5386. @table @samp
  5387. @item init
  5388. only evaluate expressions once during the filter initialization or
  5389. when a command is processed
  5390. @item frame
  5391. evaluate expressions for each incoming frame
  5392. @end table
  5393. Default value is @samp{frame}.
  5394. @item shortest
  5395. If set to 1, force the output to terminate when the shortest input
  5396. terminates. Default value is 0.
  5397. @item format
  5398. Set the format for the output video.
  5399. It accepts the following values:
  5400. @table @samp
  5401. @item yuv420
  5402. force YUV420 output
  5403. @item yuv422
  5404. force YUV422 output
  5405. @item yuv444
  5406. force YUV444 output
  5407. @item rgb
  5408. force RGB output
  5409. @end table
  5410. Default value is @samp{yuv420}.
  5411. @item rgb @emph{(deprecated)}
  5412. If set to 1, force the filter to accept inputs in the RGB
  5413. color space. Default value is 0. This option is deprecated, use
  5414. @option{format} instead.
  5415. @item repeatlast
  5416. If set to 1, force the filter to draw the last overlay frame over the
  5417. main input until the end of the stream. A value of 0 disables this
  5418. behavior. Default value is 1.
  5419. @end table
  5420. The @option{x}, and @option{y} expressions can contain the following
  5421. parameters.
  5422. @table @option
  5423. @item main_w, W
  5424. @item main_h, H
  5425. The main input width and height.
  5426. @item overlay_w, w
  5427. @item overlay_h, h
  5428. The overlay input width and height.
  5429. @item x
  5430. @item y
  5431. The computed values for @var{x} and @var{y}. They are evaluated for
  5432. each new frame.
  5433. @item hsub
  5434. @item vsub
  5435. horizontal and vertical chroma subsample values of the output
  5436. format. For example for the pixel format "yuv422p" @var{hsub} is 2 and
  5437. @var{vsub} is 1.
  5438. @item n
  5439. the number of input frame, starting from 0
  5440. @item pos
  5441. the position in the file of the input frame, NAN if unknown
  5442. @item t
  5443. The timestamp, expressed in seconds. It's NAN if the input timestamp is unknown.
  5444. @end table
  5445. Note that the @var{n}, @var{pos}, @var{t} variables are available only
  5446. when evaluation is done @emph{per frame}, and will evaluate to NAN
  5447. when @option{eval} is set to @samp{init}.
  5448. Be aware that frames are taken from each input video in timestamp
  5449. order, hence, if their initial timestamps differ, it is a good idea
  5450. to pass the two inputs through a @var{setpts=PTS-STARTPTS} filter to
  5451. have them begin in the same zero timestamp, as the example for
  5452. the @var{movie} filter does.
  5453. You can chain together more overlays but you should test the
  5454. efficiency of such approach.
  5455. @subsection Commands
  5456. This filter supports the following commands:
  5457. @table @option
  5458. @item x
  5459. @item y
  5460. Modify the x and y of the overlay input.
  5461. The command accepts the same syntax of the corresponding option.
  5462. If the specified expression is not valid, it is kept at its current
  5463. value.
  5464. @end table
  5465. @subsection Examples
  5466. @itemize
  5467. @item
  5468. Draw the overlay at 10 pixels from the bottom right corner of the main
  5469. video:
  5470. @example
  5471. overlay=main_w-overlay_w-10:main_h-overlay_h-10
  5472. @end example
  5473. Using named options the example above becomes:
  5474. @example
  5475. overlay=x=main_w-overlay_w-10:y=main_h-overlay_h-10
  5476. @end example
  5477. @item
  5478. Insert a transparent PNG logo in the bottom left corner of the input,
  5479. using the @command{ffmpeg} tool with the @code{-filter_complex} option:
  5480. @example
  5481. ffmpeg -i input -i logo -filter_complex 'overlay=10:main_h-overlay_h-10' output
  5482. @end example
  5483. @item
  5484. Insert 2 different transparent PNG logos (second logo on bottom
  5485. right corner) using the @command{ffmpeg} tool:
  5486. @example
  5487. ffmpeg -i input -i logo1 -i logo2 -filter_complex 'overlay=x=10:y=H-h-10,overlay=x=W-w-10:y=H-h-10' output
  5488. @end example
  5489. @item
  5490. Add a transparent color layer on top of the main video; @code{WxH}
  5491. must specify the size of the main input to the overlay filter:
  5492. @example
  5493. color=color=red@@.3:size=WxH [over]; [in][over] overlay [out]
  5494. @end example
  5495. @item
  5496. Play an original video and a filtered version (here with the deshake
  5497. filter) side by side using the @command{ffplay} tool:
  5498. @example
  5499. ffplay input.avi -vf 'split[a][b]; [a]pad=iw*2:ih[src]; [b]deshake[filt]; [src][filt]overlay=w'
  5500. @end example
  5501. The above command is the same as:
  5502. @example
  5503. ffplay input.avi -vf 'split[b], pad=iw*2[src], [b]deshake, [src]overlay=w'
  5504. @end example
  5505. @item
  5506. Make a sliding overlay appearing from the left to the right top part of the
  5507. screen starting since time 2:
  5508. @example
  5509. overlay=x='if(gte(t,2), -w+(t-2)*20, NAN)':y=0
  5510. @end example
  5511. @item
  5512. Compose output by putting two input videos side to side:
  5513. @example
  5514. ffmpeg -i left.avi -i right.avi -filter_complex "
  5515. nullsrc=size=200x100 [background];
  5516. [0:v] setpts=PTS-STARTPTS, scale=100x100 [left];
  5517. [1:v] setpts=PTS-STARTPTS, scale=100x100 [right];
  5518. [background][left] overlay=shortest=1 [background+left];
  5519. [background+left][right] overlay=shortest=1:x=100 [left+right]
  5520. "
  5521. @end example
  5522. @item
  5523. Mask 10-20 seconds of a video by applying the delogo filter to a section
  5524. @example
  5525. ffmpeg -i test.avi -codec:v:0 wmv2 -ar 11025 -b:v 9000k
  5526. -vf '[in]split[split_main][split_delogo];[split_delogo]trim=start=360:end=371,delogo=0:0:640:480[delogoed];[split_main][delogoed]overlay=eof_action=pass[out]'
  5527. masked.avi
  5528. @end example
  5529. @item
  5530. Chain several overlays in cascade:
  5531. @example
  5532. nullsrc=s=200x200 [bg];
  5533. testsrc=s=100x100, split=4 [in0][in1][in2][in3];
  5534. [in0] lutrgb=r=0, [bg] overlay=0:0 [mid0];
  5535. [in1] lutrgb=g=0, [mid0] overlay=100:0 [mid1];
  5536. [in2] lutrgb=b=0, [mid1] overlay=0:100 [mid2];
  5537. [in3] null, [mid2] overlay=100:100 [out0]
  5538. @end example
  5539. @end itemize
  5540. @section owdenoise
  5541. Apply Overcomplete Wavelet denoiser.
  5542. The filter accepts the following options:
  5543. @table @option
  5544. @item depth
  5545. Set depth.
  5546. Larger depth values will denoise lower frequency components more, but
  5547. slow down filtering.
  5548. Must be an int in the range 8-16, default is @code{8}.
  5549. @item luma_strength, ls
  5550. Set luma strength.
  5551. Must be a double value in the range 0-1000, default is @code{1.0}.
  5552. @item chroma_strength, cs
  5553. Set chroma strength.
  5554. Must be a double value in the range 0-1000, default is @code{1.0}.
  5555. @end table
  5556. @section pad
  5557. Add paddings to the input image, and place the original input at the
  5558. provided @var{x}, @var{y} coordinates.
  5559. It accepts the following parameters:
  5560. @table @option
  5561. @item width, w
  5562. @item height, h
  5563. Specify an expression for the size of the output image with the
  5564. paddings added. If the value for @var{width} or @var{height} is 0, the
  5565. corresponding input size is used for the output.
  5566. The @var{width} expression can reference the value set by the
  5567. @var{height} expression, and vice versa.
  5568. The default value of @var{width} and @var{height} is 0.
  5569. @item x
  5570. @item y
  5571. Specify the offsets to place the input image at within the padded area,
  5572. with respect to the top/left border of the output image.
  5573. The @var{x} expression can reference the value set by the @var{y}
  5574. expression, and vice versa.
  5575. The default value of @var{x} and @var{y} is 0.
  5576. @item color
  5577. Specify the color of the padded area. For the syntax of this option,
  5578. check the "Color" section in the ffmpeg-utils manual.
  5579. The default value of @var{color} is "black".
  5580. @end table
  5581. The value for the @var{width}, @var{height}, @var{x}, and @var{y}
  5582. options are expressions containing the following constants:
  5583. @table @option
  5584. @item in_w
  5585. @item in_h
  5586. The input video width and height.
  5587. @item iw
  5588. @item ih
  5589. These are the same as @var{in_w} and @var{in_h}.
  5590. @item out_w
  5591. @item out_h
  5592. The output width and height (the size of the padded area), as
  5593. specified by the @var{width} and @var{height} expressions.
  5594. @item ow
  5595. @item oh
  5596. These are the same as @var{out_w} and @var{out_h}.
  5597. @item x
  5598. @item y
  5599. The x and y offsets as specified by the @var{x} and @var{y}
  5600. expressions, or NAN if not yet specified.
  5601. @item a
  5602. same as @var{iw} / @var{ih}
  5603. @item sar
  5604. input sample aspect ratio
  5605. @item dar
  5606. input display aspect ratio, it is the same as (@var{iw} / @var{ih}) * @var{sar}
  5607. @item hsub
  5608. @item vsub
  5609. The horizontal and vertical chroma subsample values. For example for the
  5610. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  5611. @end table
  5612. @subsection Examples
  5613. @itemize
  5614. @item
  5615. Add paddings with the color "violet" to the input video. The output video
  5616. size is 640x480, and the top-left corner of the input video is placed at
  5617. column 0, row 40
  5618. @example
  5619. pad=640:480:0:40:violet
  5620. @end example
  5621. The example above is equivalent to the following command:
  5622. @example
  5623. pad=width=640:height=480:x=0:y=40:color=violet
  5624. @end example
  5625. @item
  5626. Pad the input to get an output with dimensions increased by 3/2,
  5627. and put the input video at the center of the padded area:
  5628. @example
  5629. pad="3/2*iw:3/2*ih:(ow-iw)/2:(oh-ih)/2"
  5630. @end example
  5631. @item
  5632. Pad the input to get a squared output with size equal to the maximum
  5633. value between the input width and height, and put the input video at
  5634. the center of the padded area:
  5635. @example
  5636. pad="max(iw\,ih):ow:(ow-iw)/2:(oh-ih)/2"
  5637. @end example
  5638. @item
  5639. Pad the input to get a final w/h ratio of 16:9:
  5640. @example
  5641. pad="ih*16/9:ih:(ow-iw)/2:(oh-ih)/2"
  5642. @end example
  5643. @item
  5644. In case of anamorphic video, in order to set the output display aspect
  5645. correctly, it is necessary to use @var{sar} in the expression,
  5646. according to the relation:
  5647. @example
  5648. (ih * X / ih) * sar = output_dar
  5649. X = output_dar / sar
  5650. @end example
  5651. Thus the previous example needs to be modified to:
  5652. @example
  5653. pad="ih*16/9/sar:ih:(ow-iw)/2:(oh-ih)/2"
  5654. @end example
  5655. @item
  5656. Double the output size and put the input video in the bottom-right
  5657. corner of the output padded area:
  5658. @example
  5659. pad="2*iw:2*ih:ow-iw:oh-ih"
  5660. @end example
  5661. @end itemize
  5662. @anchor{palettegen}
  5663. @section palettegen
  5664. Generate one palette for a whole video stream.
  5665. It accepts the following options:
  5666. @table @option
  5667. @item max_colors
  5668. Set the maximum number of colors to quantize in the palette.
  5669. Note: the palette will still contain 256 colors; the unused palette entries
  5670. will be black.
  5671. @item reserve_transparent
  5672. Create a palette of 255 colors maximum and reserve the last one for
  5673. transparency. Reserving the transparency color is useful for GIF optimization.
  5674. If not set, the maximum of colors in the palette will be 256. You probably want
  5675. to disable this option for a standalone image.
  5676. Set by default.
  5677. @item stats_mode
  5678. Set statistics mode.
  5679. It accepts the following values:
  5680. @table @samp
  5681. @item full
  5682. Compute full frame histograms.
  5683. @item diff
  5684. Compute histograms only for the part that differs from previous frame. This
  5685. might be relevant to give more importance to the moving part of your input if
  5686. the background is static.
  5687. @end table
  5688. Default value is @var{full}.
  5689. @end table
  5690. The filter also exports the frame metadata @code{lavfi.color_quant_ratio}
  5691. (@code{nb_color_in / nb_color_out}) which you can use to evaluate the degree of
  5692. color quantization of the palette. This information is also visible at
  5693. @var{info} logging level.
  5694. @subsection Examples
  5695. @itemize
  5696. @item
  5697. Generate a representative palette of a given video using @command{ffmpeg}:
  5698. @example
  5699. ffmpeg -i input.mkv -vf palettegen palette.png
  5700. @end example
  5701. @end itemize
  5702. @section paletteuse
  5703. Use a palette to downsample an input video stream.
  5704. The filter takes two inputs: one video stream and a palette. The palette must
  5705. be a 256 pixels image.
  5706. It accepts the following options:
  5707. @table @option
  5708. @item dither
  5709. Select dithering mode. Available algorithms are:
  5710. @table @samp
  5711. @item bayer
  5712. Ordered 8x8 bayer dithering (deterministic)
  5713. @item heckbert
  5714. Dithering as defined by Paul Heckbert in 1982 (simple error diffusion).
  5715. Note: this dithering is sometimes considered "wrong" and is included as a
  5716. reference.
  5717. @item floyd_steinberg
  5718. Floyd and Steingberg dithering (error diffusion)
  5719. @item sierra2
  5720. Frankie Sierra dithering v2 (error diffusion)
  5721. @item sierra2_4a
  5722. Frankie Sierra dithering v2 "Lite" (error diffusion)
  5723. @end table
  5724. Default is @var{sierra2_4a}.
  5725. @item bayer_scale
  5726. When @var{bayer} dithering is selected, this option defines the scale of the
  5727. pattern (how much the crosshatch pattern is visible). A low value means more
  5728. visible pattern for less banding, and higher value means less visible pattern
  5729. at the cost of more banding.
  5730. The option must be an integer value in the range [0,5]. Default is @var{2}.
  5731. @item diff_mode
  5732. If set, define the zone to process
  5733. @table @samp
  5734. @item rectangle
  5735. Only the changing rectangle will be reprocessed. This is similar to GIF
  5736. cropping/offsetting compression mechanism. This option can be useful for speed
  5737. if only a part of the image is changing, and has use cases such as limiting the
  5738. scope of the error diffusal @option{dither} to the rectangle that bounds the
  5739. moving scene (it leads to more deterministic output if the scene doesn't change
  5740. much, and as a result less moving noise and better GIF compression).
  5741. @end table
  5742. Default is @var{none}.
  5743. @end table
  5744. @subsection Examples
  5745. @itemize
  5746. @item
  5747. Use a palette (generated for example with @ref{palettegen}) to encode a GIF
  5748. using @command{ffmpeg}:
  5749. @example
  5750. ffmpeg -i input.mkv -i palette.png -lavfi paletteuse output.gif
  5751. @end example
  5752. @end itemize
  5753. @section perspective
  5754. Correct perspective of video not recorded perpendicular to the screen.
  5755. A description of the accepted parameters follows.
  5756. @table @option
  5757. @item x0
  5758. @item y0
  5759. @item x1
  5760. @item y1
  5761. @item x2
  5762. @item y2
  5763. @item x3
  5764. @item y3
  5765. Set coordinates expression for top left, top right, bottom left and bottom right corners.
  5766. Default values are @code{0:0:W:0:0:H:W:H} with which perspective will remain unchanged.
  5767. If the @code{sense} option is set to @code{source}, then the specified points will be sent
  5768. to the corners of the destination. If the @code{sense} option is set to @code{destination},
  5769. then the corners of the source will be sent to the specified coordinates.
  5770. The expressions can use the following variables:
  5771. @table @option
  5772. @item W
  5773. @item H
  5774. the width and height of video frame.
  5775. @end table
  5776. @item interpolation
  5777. Set interpolation for perspective correction.
  5778. It accepts the following values:
  5779. @table @samp
  5780. @item linear
  5781. @item cubic
  5782. @end table
  5783. Default value is @samp{linear}.
  5784. @item sense
  5785. Set interpretation of coordinate options.
  5786. It accepts the following values:
  5787. @table @samp
  5788. @item 0, source
  5789. Send point in the source specified by the given coordinates to
  5790. the corners of the destination.
  5791. @item 1, destination
  5792. Send the corners of the source to the point in the destination specified
  5793. by the given coordinates.
  5794. Default value is @samp{source}.
  5795. @end table
  5796. @end table
  5797. @section phase
  5798. Delay interlaced video by one field time so that the field order changes.
  5799. The intended use is to fix PAL movies that have been captured with the
  5800. opposite field order to the film-to-video transfer.
  5801. A description of the accepted parameters follows.
  5802. @table @option
  5803. @item mode
  5804. Set phase mode.
  5805. It accepts the following values:
  5806. @table @samp
  5807. @item t
  5808. Capture field order top-first, transfer bottom-first.
  5809. Filter will delay the bottom field.
  5810. @item b
  5811. Capture field order bottom-first, transfer top-first.
  5812. Filter will delay the top field.
  5813. @item p
  5814. Capture and transfer with the same field order. This mode only exists
  5815. for the documentation of the other options to refer to, but if you
  5816. actually select it, the filter will faithfully do nothing.
  5817. @item a
  5818. Capture field order determined automatically by field flags, transfer
  5819. opposite.
  5820. Filter selects among @samp{t} and @samp{b} modes on a frame by frame
  5821. basis using field flags. If no field information is available,
  5822. then this works just like @samp{u}.
  5823. @item u
  5824. Capture unknown or varying, transfer opposite.
  5825. Filter selects among @samp{t} and @samp{b} on a frame by frame basis by
  5826. analyzing the images and selecting the alternative that produces best
  5827. match between the fields.
  5828. @item T
  5829. Capture top-first, transfer unknown or varying.
  5830. Filter selects among @samp{t} and @samp{p} using image analysis.
  5831. @item B
  5832. Capture bottom-first, transfer unknown or varying.
  5833. Filter selects among @samp{b} and @samp{p} using image analysis.
  5834. @item A
  5835. Capture determined by field flags, transfer unknown or varying.
  5836. Filter selects among @samp{t}, @samp{b} and @samp{p} using field flags and
  5837. image analysis. If no field information is available, then this works just
  5838. like @samp{U}. This is the default mode.
  5839. @item U
  5840. Both capture and transfer unknown or varying.
  5841. Filter selects among @samp{t}, @samp{b} and @samp{p} using image analysis only.
  5842. @end table
  5843. @end table
  5844. @section pixdesctest
  5845. Pixel format descriptor test filter, mainly useful for internal
  5846. testing. The output video should be equal to the input video.
  5847. For example:
  5848. @example
  5849. format=monow, pixdesctest
  5850. @end example
  5851. can be used to test the monowhite pixel format descriptor definition.
  5852. @section pp
  5853. Enable the specified chain of postprocessing subfilters using libpostproc. This
  5854. library should be automatically selected with a GPL build (@code{--enable-gpl}).
  5855. Subfilters must be separated by '/' and can be disabled by prepending a '-'.
  5856. Each subfilter and some options have a short and a long name that can be used
  5857. interchangeably, i.e. dr/dering are the same.
  5858. The filters accept the following options:
  5859. @table @option
  5860. @item subfilters
  5861. Set postprocessing subfilters string.
  5862. @end table
  5863. All subfilters share common options to determine their scope:
  5864. @table @option
  5865. @item a/autoq
  5866. Honor the quality commands for this subfilter.
  5867. @item c/chrom
  5868. Do chrominance filtering, too (default).
  5869. @item y/nochrom
  5870. Do luminance filtering only (no chrominance).
  5871. @item n/noluma
  5872. Do chrominance filtering only (no luminance).
  5873. @end table
  5874. These options can be appended after the subfilter name, separated by a '|'.
  5875. Available subfilters are:
  5876. @table @option
  5877. @item hb/hdeblock[|difference[|flatness]]
  5878. Horizontal deblocking filter
  5879. @table @option
  5880. @item difference
  5881. Difference factor where higher values mean more deblocking (default: @code{32}).
  5882. @item flatness
  5883. Flatness threshold where lower values mean more deblocking (default: @code{39}).
  5884. @end table
  5885. @item vb/vdeblock[|difference[|flatness]]
  5886. Vertical deblocking filter
  5887. @table @option
  5888. @item difference
  5889. Difference factor where higher values mean more deblocking (default: @code{32}).
  5890. @item flatness
  5891. Flatness threshold where lower values mean more deblocking (default: @code{39}).
  5892. @end table
  5893. @item ha/hadeblock[|difference[|flatness]]
  5894. Accurate horizontal deblocking filter
  5895. @table @option
  5896. @item difference
  5897. Difference factor where higher values mean more deblocking (default: @code{32}).
  5898. @item flatness
  5899. Flatness threshold where lower values mean more deblocking (default: @code{39}).
  5900. @end table
  5901. @item va/vadeblock[|difference[|flatness]]
  5902. Accurate vertical deblocking filter
  5903. @table @option
  5904. @item difference
  5905. Difference factor where higher values mean more deblocking (default: @code{32}).
  5906. @item flatness
  5907. Flatness threshold where lower values mean more deblocking (default: @code{39}).
  5908. @end table
  5909. @end table
  5910. The horizontal and vertical deblocking filters share the difference and
  5911. flatness values so you cannot set different horizontal and vertical
  5912. thresholds.
  5913. @table @option
  5914. @item h1/x1hdeblock
  5915. Experimental horizontal deblocking filter
  5916. @item v1/x1vdeblock
  5917. Experimental vertical deblocking filter
  5918. @item dr/dering
  5919. Deringing filter
  5920. @item tn/tmpnoise[|threshold1[|threshold2[|threshold3]]], temporal noise reducer
  5921. @table @option
  5922. @item threshold1
  5923. larger -> stronger filtering
  5924. @item threshold2
  5925. larger -> stronger filtering
  5926. @item threshold3
  5927. larger -> stronger filtering
  5928. @end table
  5929. @item al/autolevels[:f/fullyrange], automatic brightness / contrast correction
  5930. @table @option
  5931. @item f/fullyrange
  5932. Stretch luminance to @code{0-255}.
  5933. @end table
  5934. @item lb/linblenddeint
  5935. Linear blend deinterlacing filter that deinterlaces the given block by
  5936. filtering all lines with a @code{(1 2 1)} filter.
  5937. @item li/linipoldeint
  5938. Linear interpolating deinterlacing filter that deinterlaces the given block by
  5939. linearly interpolating every second line.
  5940. @item ci/cubicipoldeint
  5941. Cubic interpolating deinterlacing filter deinterlaces the given block by
  5942. cubically interpolating every second line.
  5943. @item md/mediandeint
  5944. Median deinterlacing filter that deinterlaces the given block by applying a
  5945. median filter to every second line.
  5946. @item fd/ffmpegdeint
  5947. FFmpeg deinterlacing filter that deinterlaces the given block by filtering every
  5948. second line with a @code{(-1 4 2 4 -1)} filter.
  5949. @item l5/lowpass5
  5950. Vertically applied FIR lowpass deinterlacing filter that deinterlaces the given
  5951. block by filtering all lines with a @code{(-1 2 6 2 -1)} filter.
  5952. @item fq/forceQuant[|quantizer]
  5953. Overrides the quantizer table from the input with the constant quantizer you
  5954. specify.
  5955. @table @option
  5956. @item quantizer
  5957. Quantizer to use
  5958. @end table
  5959. @item de/default
  5960. Default pp filter combination (@code{hb|a,vb|a,dr|a})
  5961. @item fa/fast
  5962. Fast pp filter combination (@code{h1|a,v1|a,dr|a})
  5963. @item ac
  5964. High quality pp filter combination (@code{ha|a|128|7,va|a,dr|a})
  5965. @end table
  5966. @subsection Examples
  5967. @itemize
  5968. @item
  5969. Apply horizontal and vertical deblocking, deringing and automatic
  5970. brightness/contrast:
  5971. @example
  5972. pp=hb/vb/dr/al
  5973. @end example
  5974. @item
  5975. Apply default filters without brightness/contrast correction:
  5976. @example
  5977. pp=de/-al
  5978. @end example
  5979. @item
  5980. Apply default filters and temporal denoiser:
  5981. @example
  5982. pp=default/tmpnoise|1|2|3
  5983. @end example
  5984. @item
  5985. Apply deblocking on luminance only, and switch vertical deblocking on or off
  5986. automatically depending on available CPU time:
  5987. @example
  5988. pp=hb|y/vb|a
  5989. @end example
  5990. @end itemize
  5991. @section pp7
  5992. Apply Postprocessing filter 7. It is variant of the @ref{spp} filter,
  5993. similar to spp = 6 with 7 point DCT, where only the center sample is
  5994. used after IDCT.
  5995. The filter accepts the following options:
  5996. @table @option
  5997. @item qp
  5998. Force a constant quantization parameter. It accepts an integer in range
  5999. 0 to 63. If not set, the filter will use the QP from the video stream
  6000. (if available).
  6001. @item mode
  6002. Set thresholding mode. Available modes are:
  6003. @table @samp
  6004. @item hard
  6005. Set hard thresholding.
  6006. @item soft
  6007. Set soft thresholding (better de-ringing effect, but likely blurrier).
  6008. @item medium
  6009. Set medium thresholding (good results, default).
  6010. @end table
  6011. @end table
  6012. @section psnr
  6013. Obtain the average, maximum and minimum PSNR (Peak Signal to Noise
  6014. Ratio) between two input videos.
  6015. This filter takes in input two input videos, the first input is
  6016. considered the "main" source and is passed unchanged to the
  6017. output. The second input is used as a "reference" video for computing
  6018. the PSNR.
  6019. Both video inputs must have the same resolution and pixel format for
  6020. this filter to work correctly. Also it assumes that both inputs
  6021. have the same number of frames, which are compared one by one.
  6022. The obtained average PSNR is printed through the logging system.
  6023. The filter stores the accumulated MSE (mean squared error) of each
  6024. frame, and at the end of the processing it is averaged across all frames
  6025. equally, and the following formula is applied to obtain the PSNR:
  6026. @example
  6027. PSNR = 10*log10(MAX^2/MSE)
  6028. @end example
  6029. Where MAX is the average of the maximum values of each component of the
  6030. image.
  6031. The description of the accepted parameters follows.
  6032. @table @option
  6033. @item stats_file, f
  6034. If specified the filter will use the named file to save the PSNR of
  6035. each individual frame.
  6036. @end table
  6037. The file printed if @var{stats_file} is selected, contains a sequence of
  6038. key/value pairs of the form @var{key}:@var{value} for each compared
  6039. couple of frames.
  6040. A description of each shown parameter follows:
  6041. @table @option
  6042. @item n
  6043. sequential number of the input frame, starting from 1
  6044. @item mse_avg
  6045. Mean Square Error pixel-by-pixel average difference of the compared
  6046. frames, averaged over all the image components.
  6047. @item mse_y, mse_u, mse_v, mse_r, mse_g, mse_g, mse_a
  6048. Mean Square Error pixel-by-pixel average difference of the compared
  6049. frames for the component specified by the suffix.
  6050. @item psnr_y, psnr_u, psnr_v, psnr_r, psnr_g, psnr_b, psnr_a
  6051. Peak Signal to Noise ratio of the compared frames for the component
  6052. specified by the suffix.
  6053. @end table
  6054. For example:
  6055. @example
  6056. movie=ref_movie.mpg, setpts=PTS-STARTPTS [main];
  6057. [main][ref] psnr="stats_file=stats.log" [out]
  6058. @end example
  6059. On this example the input file being processed is compared with the
  6060. reference file @file{ref_movie.mpg}. The PSNR of each individual frame
  6061. is stored in @file{stats.log}.
  6062. @anchor{pullup}
  6063. @section pullup
  6064. Pulldown reversal (inverse telecine) filter, capable of handling mixed
  6065. hard-telecine, 24000/1001 fps progressive, and 30000/1001 fps progressive
  6066. content.
  6067. The pullup filter is designed to take advantage of future context in making
  6068. its decisions. This filter is stateless in the sense that it does not lock
  6069. onto a pattern to follow, but it instead looks forward to the following
  6070. fields in order to identify matches and rebuild progressive frames.
  6071. To produce content with an even framerate, insert the fps filter after
  6072. pullup, use @code{fps=24000/1001} if the input frame rate is 29.97fps,
  6073. @code{fps=24} for 30fps and the (rare) telecined 25fps input.
  6074. The filter accepts the following options:
  6075. @table @option
  6076. @item jl
  6077. @item jr
  6078. @item jt
  6079. @item jb
  6080. These options set the amount of "junk" to ignore at the left, right, top, and
  6081. bottom of the image, respectively. Left and right are in units of 8 pixels,
  6082. while top and bottom are in units of 2 lines.
  6083. The default is 8 pixels on each side.
  6084. @item sb
  6085. Set the strict breaks. Setting this option to 1 will reduce the chances of
  6086. filter generating an occasional mismatched frame, but it may also cause an
  6087. excessive number of frames to be dropped during high motion sequences.
  6088. Conversely, setting it to -1 will make filter match fields more easily.
  6089. This may help processing of video where there is slight blurring between
  6090. the fields, but may also cause there to be interlaced frames in the output.
  6091. Default value is @code{0}.
  6092. @item mp
  6093. Set the metric plane to use. It accepts the following values:
  6094. @table @samp
  6095. @item l
  6096. Use luma plane.
  6097. @item u
  6098. Use chroma blue plane.
  6099. @item v
  6100. Use chroma red plane.
  6101. @end table
  6102. This option may be set to use chroma plane instead of the default luma plane
  6103. for doing filter's computations. This may improve accuracy on very clean
  6104. source material, but more likely will decrease accuracy, especially if there
  6105. is chroma noise (rainbow effect) or any grayscale video.
  6106. The main purpose of setting @option{mp} to a chroma plane is to reduce CPU
  6107. load and make pullup usable in realtime on slow machines.
  6108. @end table
  6109. For best results (without duplicated frames in the output file) it is
  6110. necessary to change the output frame rate. For example, to inverse
  6111. telecine NTSC input:
  6112. @example
  6113. ffmpeg -i input -vf pullup -r 24000/1001 ...
  6114. @end example
  6115. @section qp
  6116. Change video quantization parameters (QP).
  6117. The filter accepts the following option:
  6118. @table @option
  6119. @item qp
  6120. Set expression for quantization parameter.
  6121. @end table
  6122. The expression is evaluated through the eval API and can contain, among others,
  6123. the following constants:
  6124. @table @var
  6125. @item known
  6126. 1 if index is not 129, 0 otherwise.
  6127. @item qp
  6128. Sequentional index starting from -129 to 128.
  6129. @end table
  6130. @subsection Examples
  6131. @itemize
  6132. @item
  6133. Some equation like:
  6134. @example
  6135. qp=2+2*sin(PI*qp)
  6136. @end example
  6137. @end itemize
  6138. @section removegrain
  6139. The removegrain filter is a spatial denoiser for progressive video.
  6140. @table @option
  6141. @item m0
  6142. Set mode for the first plane.
  6143. @item m1
  6144. Set mode for the second plane.
  6145. @item m2
  6146. Set mode for the third plane.
  6147. @item m3
  6148. Set mode for the fourth plane.
  6149. @end table
  6150. Range of mode is from 0 to 24. Description of each mode follows:
  6151. @table @var
  6152. @item 0
  6153. Leave input plane unchanged. Default.
  6154. @item 1
  6155. Clips the pixel with the minimum and maximum of the 8 neighbour pixels.
  6156. @item 2
  6157. Clips the pixel with the second minimum and maximum of the 8 neighbour pixels.
  6158. @item 3
  6159. Clips the pixel with the third minimum and maximum of the 8 neighbour pixels.
  6160. @item 4
  6161. Clips the pixel with the fourth minimum and maximum of the 8 neighbour pixels.
  6162. This is equivalent to a median filter.
  6163. @item 5
  6164. Line-sensitive clipping giving the minimal change.
  6165. @item 6
  6166. Line-sensitive clipping, intermediate.
  6167. @item 7
  6168. Line-sensitive clipping, intermediate.
  6169. @item 8
  6170. Line-sensitive clipping, intermediate.
  6171. @item 9
  6172. Line-sensitive clipping on a line where the neighbours pixels are the closest.
  6173. @item 10
  6174. Replaces the target pixel with the closest neighbour.
  6175. @item 11
  6176. [1 2 1] horizontal and vertical kernel blur.
  6177. @item 12
  6178. Same as mode 11.
  6179. @item 13
  6180. Bob mode, interpolates top field from the line where the neighbours
  6181. pixels are the closest.
  6182. @item 14
  6183. Bob mode, interpolates bottom field from the line where the neighbours
  6184. pixels are the closest.
  6185. @item 15
  6186. Bob mode, interpolates top field. Same as 13 but with a more complicated
  6187. interpolation formula.
  6188. @item 16
  6189. Bob mode, interpolates bottom field. Same as 14 but with a more complicated
  6190. interpolation formula.
  6191. @item 17
  6192. Clips the pixel with the minimum and maximum of respectively the maximum and
  6193. minimum of each pair of opposite neighbour pixels.
  6194. @item 18
  6195. Line-sensitive clipping using opposite neighbours whose greatest distance from
  6196. the current pixel is minimal.
  6197. @item 19
  6198. Replaces the pixel with the average of its 8 neighbours.
  6199. @item 20
  6200. Averages the 9 pixels ([1 1 1] horizontal and vertical blur).
  6201. @item 21
  6202. Clips pixels using the averages of opposite neighbour.
  6203. @item 22
  6204. Same as mode 21 but simpler and faster.
  6205. @item 23
  6206. Small edge and halo removal, but reputed useless.
  6207. @item 24
  6208. Similar as 23.
  6209. @end table
  6210. @section removelogo
  6211. Suppress a TV station logo, using an image file to determine which
  6212. pixels comprise the logo. It works by filling in the pixels that
  6213. comprise the logo with neighboring pixels.
  6214. The filter accepts the following options:
  6215. @table @option
  6216. @item filename, f
  6217. Set the filter bitmap file, which can be any image format supported by
  6218. libavformat. The width and height of the image file must match those of the
  6219. video stream being processed.
  6220. @end table
  6221. Pixels in the provided bitmap image with a value of zero are not
  6222. considered part of the logo, non-zero pixels are considered part of
  6223. the logo. If you use white (255) for the logo and black (0) for the
  6224. rest, you will be safe. For making the filter bitmap, it is
  6225. recommended to take a screen capture of a black frame with the logo
  6226. visible, and then using a threshold filter followed by the erode
  6227. filter once or twice.
  6228. If needed, little splotches can be fixed manually. Remember that if
  6229. logo pixels are not covered, the filter quality will be much
  6230. reduced. Marking too many pixels as part of the logo does not hurt as
  6231. much, but it will increase the amount of blurring needed to cover over
  6232. the image and will destroy more information than necessary, and extra
  6233. pixels will slow things down on a large logo.
  6234. @section repeatfields
  6235. This filter uses the repeat_field flag from the Video ES headers and hard repeats
  6236. fields based on its value.
  6237. @section rotate
  6238. Rotate video by an arbitrary angle expressed in radians.
  6239. The filter accepts the following options:
  6240. A description of the optional parameters follows.
  6241. @table @option
  6242. @item angle, a
  6243. Set an expression for the angle by which to rotate the input video
  6244. clockwise, expressed as a number of radians. A negative value will
  6245. result in a counter-clockwise rotation. By default it is set to "0".
  6246. This expression is evaluated for each frame.
  6247. @item out_w, ow
  6248. Set the output width expression, default value is "iw".
  6249. This expression is evaluated just once during configuration.
  6250. @item out_h, oh
  6251. Set the output height expression, default value is "ih".
  6252. This expression is evaluated just once during configuration.
  6253. @item bilinear
  6254. Enable bilinear interpolation if set to 1, a value of 0 disables
  6255. it. Default value is 1.
  6256. @item fillcolor, c
  6257. Set the color used to fill the output area not covered by the rotated
  6258. image. For the general syntax of this option, check the "Color" section in the
  6259. ffmpeg-utils manual. If the special value "none" is selected then no
  6260. background is printed (useful for example if the background is never shown).
  6261. Default value is "black".
  6262. @end table
  6263. The expressions for the angle and the output size can contain the
  6264. following constants and functions:
  6265. @table @option
  6266. @item n
  6267. sequential number of the input frame, starting from 0. It is always NAN
  6268. before the first frame is filtered.
  6269. @item t
  6270. time in seconds of the input frame, it is set to 0 when the filter is
  6271. configured. It is always NAN before the first frame is filtered.
  6272. @item hsub
  6273. @item vsub
  6274. horizontal and vertical chroma subsample values. For example for the
  6275. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  6276. @item in_w, iw
  6277. @item in_h, ih
  6278. the input video width and height
  6279. @item out_w, ow
  6280. @item out_h, oh
  6281. the output width and height, that is the size of the padded area as
  6282. specified by the @var{width} and @var{height} expressions
  6283. @item rotw(a)
  6284. @item roth(a)
  6285. the minimal width/height required for completely containing the input
  6286. video rotated by @var{a} radians.
  6287. These are only available when computing the @option{out_w} and
  6288. @option{out_h} expressions.
  6289. @end table
  6290. @subsection Examples
  6291. @itemize
  6292. @item
  6293. Rotate the input by PI/6 radians clockwise:
  6294. @example
  6295. rotate=PI/6
  6296. @end example
  6297. @item
  6298. Rotate the input by PI/6 radians counter-clockwise:
  6299. @example
  6300. rotate=-PI/6
  6301. @end example
  6302. @item
  6303. Rotate the input by 45 degrees clockwise:
  6304. @example
  6305. rotate=45*PI/180
  6306. @end example
  6307. @item
  6308. Apply a constant rotation with period T, starting from an angle of PI/3:
  6309. @example
  6310. rotate=PI/3+2*PI*t/T
  6311. @end example
  6312. @item
  6313. Make the input video rotation oscillating with a period of T
  6314. seconds and an amplitude of A radians:
  6315. @example
  6316. rotate=A*sin(2*PI/T*t)
  6317. @end example
  6318. @item
  6319. Rotate the video, output size is chosen so that the whole rotating
  6320. input video is always completely contained in the output:
  6321. @example
  6322. rotate='2*PI*t:ow=hypot(iw,ih):oh=ow'
  6323. @end example
  6324. @item
  6325. Rotate the video, reduce the output size so that no background is ever
  6326. shown:
  6327. @example
  6328. rotate=2*PI*t:ow='min(iw,ih)/sqrt(2)':oh=ow:c=none
  6329. @end example
  6330. @end itemize
  6331. @subsection Commands
  6332. The filter supports the following commands:
  6333. @table @option
  6334. @item a, angle
  6335. Set the angle expression.
  6336. The command accepts the same syntax of the corresponding option.
  6337. If the specified expression is not valid, it is kept at its current
  6338. value.
  6339. @end table
  6340. @section sab
  6341. Apply Shape Adaptive Blur.
  6342. The filter accepts the following options:
  6343. @table @option
  6344. @item luma_radius, lr
  6345. Set luma blur filter strength, must be a value in range 0.1-4.0, default
  6346. value is 1.0. A greater value will result in a more blurred image, and
  6347. in slower processing.
  6348. @item luma_pre_filter_radius, lpfr
  6349. Set luma pre-filter radius, must be a value in the 0.1-2.0 range, default
  6350. value is 1.0.
  6351. @item luma_strength, ls
  6352. Set luma maximum difference between pixels to still be considered, must
  6353. be a value in the 0.1-100.0 range, default value is 1.0.
  6354. @item chroma_radius, cr
  6355. Set chroma blur filter strength, must be a value in range 0.1-4.0. A
  6356. greater value will result in a more blurred image, and in slower
  6357. processing.
  6358. @item chroma_pre_filter_radius, cpfr
  6359. Set chroma pre-filter radius, must be a value in the 0.1-2.0 range.
  6360. @item chroma_strength, cs
  6361. Set chroma maximum difference between pixels to still be considered,
  6362. must be a value in the 0.1-100.0 range.
  6363. @end table
  6364. Each chroma option value, if not explicitly specified, is set to the
  6365. corresponding luma option value.
  6366. @anchor{scale}
  6367. @section scale
  6368. Scale (resize) the input video, using the libswscale library.
  6369. The scale filter forces the output display aspect ratio to be the same
  6370. of the input, by changing the output sample aspect ratio.
  6371. If the input image format is different from the format requested by
  6372. the next filter, the scale filter will convert the input to the
  6373. requested format.
  6374. @subsection Options
  6375. The filter accepts the following options, or any of the options
  6376. supported by the libswscale scaler.
  6377. See @ref{scaler_options,,the ffmpeg-scaler manual,ffmpeg-scaler} for
  6378. the complete list of scaler options.
  6379. @table @option
  6380. @item width, w
  6381. @item height, h
  6382. Set the output video dimension expression. Default value is the input
  6383. dimension.
  6384. If the value is 0, the input width is used for the output.
  6385. If one of the values is -1, the scale filter will use a value that
  6386. maintains the aspect ratio of the input image, calculated from the
  6387. other specified dimension. If both of them are -1, the input size is
  6388. used
  6389. If one of the values is -n with n > 1, the scale filter will also use a value
  6390. that maintains the aspect ratio of the input image, calculated from the other
  6391. specified dimension. After that it will, however, make sure that the calculated
  6392. dimension is divisible by n and adjust the value if necessary.
  6393. See below for the list of accepted constants for use in the dimension
  6394. expression.
  6395. @item interl
  6396. Set the interlacing mode. It accepts the following values:
  6397. @table @samp
  6398. @item 1
  6399. Force interlaced aware scaling.
  6400. @item 0
  6401. Do not apply interlaced scaling.
  6402. @item -1
  6403. Select interlaced aware scaling depending on whether the source frames
  6404. are flagged as interlaced or not.
  6405. @end table
  6406. Default value is @samp{0}.
  6407. @item flags
  6408. Set libswscale scaling flags. See
  6409. @ref{sws_flags,,the ffmpeg-scaler manual,ffmpeg-scaler} for the
  6410. complete list of values. If not explicitly specified the filter applies
  6411. the default flags.
  6412. @item size, s
  6413. Set the video size. For the syntax of this option, check the
  6414. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  6415. @item in_color_matrix
  6416. @item out_color_matrix
  6417. Set in/output YCbCr color space type.
  6418. This allows the autodetected value to be overridden as well as allows forcing
  6419. a specific value used for the output and encoder.
  6420. If not specified, the color space type depends on the pixel format.
  6421. Possible values:
  6422. @table @samp
  6423. @item auto
  6424. Choose automatically.
  6425. @item bt709
  6426. Format conforming to International Telecommunication Union (ITU)
  6427. Recommendation BT.709.
  6428. @item fcc
  6429. Set color space conforming to the United States Federal Communications
  6430. Commission (FCC) Code of Federal Regulations (CFR) Title 47 (2003) 73.682 (a).
  6431. @item bt601
  6432. Set color space conforming to:
  6433. @itemize
  6434. @item
  6435. ITU Radiocommunication Sector (ITU-R) Recommendation BT.601
  6436. @item
  6437. ITU-R Rec. BT.470-6 (1998) Systems B, B1, and G
  6438. @item
  6439. Society of Motion Picture and Television Engineers (SMPTE) ST 170:2004
  6440. @end itemize
  6441. @item smpte240m
  6442. Set color space conforming to SMPTE ST 240:1999.
  6443. @end table
  6444. @item in_range
  6445. @item out_range
  6446. Set in/output YCbCr sample range.
  6447. This allows the autodetected value to be overridden as well as allows forcing
  6448. a specific value used for the output and encoder. If not specified, the
  6449. range depends on the pixel format. Possible values:
  6450. @table @samp
  6451. @item auto
  6452. Choose automatically.
  6453. @item jpeg/full/pc
  6454. Set full range (0-255 in case of 8-bit luma).
  6455. @item mpeg/tv
  6456. Set "MPEG" range (16-235 in case of 8-bit luma).
  6457. @end table
  6458. @item force_original_aspect_ratio
  6459. Enable decreasing or increasing output video width or height if necessary to
  6460. keep the original aspect ratio. Possible values:
  6461. @table @samp
  6462. @item disable
  6463. Scale the video as specified and disable this feature.
  6464. @item decrease
  6465. The output video dimensions will automatically be decreased if needed.
  6466. @item increase
  6467. The output video dimensions will automatically be increased if needed.
  6468. @end table
  6469. One useful instance of this option is that when you know a specific device's
  6470. maximum allowed resolution, you can use this to limit the output video to
  6471. that, while retaining the aspect ratio. For example, device A allows
  6472. 1280x720 playback, and your video is 1920x800. Using this option (set it to
  6473. decrease) and specifying 1280x720 to the command line makes the output
  6474. 1280x533.
  6475. Please note that this is a different thing than specifying -1 for @option{w}
  6476. or @option{h}, you still need to specify the output resolution for this option
  6477. to work.
  6478. @end table
  6479. The values of the @option{w} and @option{h} options are expressions
  6480. containing the following constants:
  6481. @table @var
  6482. @item in_w
  6483. @item in_h
  6484. The input width and height
  6485. @item iw
  6486. @item ih
  6487. These are the same as @var{in_w} and @var{in_h}.
  6488. @item out_w
  6489. @item out_h
  6490. The output (scaled) width and height
  6491. @item ow
  6492. @item oh
  6493. These are the same as @var{out_w} and @var{out_h}
  6494. @item a
  6495. The same as @var{iw} / @var{ih}
  6496. @item sar
  6497. input sample aspect ratio
  6498. @item dar
  6499. The input display aspect ratio. Calculated from @code{(iw / ih) * sar}.
  6500. @item hsub
  6501. @item vsub
  6502. horizontal and vertical input chroma subsample values. For example for the
  6503. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  6504. @item ohsub
  6505. @item ovsub
  6506. horizontal and vertical output chroma subsample values. For example for the
  6507. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  6508. @end table
  6509. @subsection Examples
  6510. @itemize
  6511. @item
  6512. Scale the input video to a size of 200x100
  6513. @example
  6514. scale=w=200:h=100
  6515. @end example
  6516. This is equivalent to:
  6517. @example
  6518. scale=200:100
  6519. @end example
  6520. or:
  6521. @example
  6522. scale=200x100
  6523. @end example
  6524. @item
  6525. Specify a size abbreviation for the output size:
  6526. @example
  6527. scale=qcif
  6528. @end example
  6529. which can also be written as:
  6530. @example
  6531. scale=size=qcif
  6532. @end example
  6533. @item
  6534. Scale the input to 2x:
  6535. @example
  6536. scale=w=2*iw:h=2*ih
  6537. @end example
  6538. @item
  6539. The above is the same as:
  6540. @example
  6541. scale=2*in_w:2*in_h
  6542. @end example
  6543. @item
  6544. Scale the input to 2x with forced interlaced scaling:
  6545. @example
  6546. scale=2*iw:2*ih:interl=1
  6547. @end example
  6548. @item
  6549. Scale the input to half size:
  6550. @example
  6551. scale=w=iw/2:h=ih/2
  6552. @end example
  6553. @item
  6554. Increase the width, and set the height to the same size:
  6555. @example
  6556. scale=3/2*iw:ow
  6557. @end example
  6558. @item
  6559. Seek Greek harmony:
  6560. @example
  6561. scale=iw:1/PHI*iw
  6562. scale=ih*PHI:ih
  6563. @end example
  6564. @item
  6565. Increase the height, and set the width to 3/2 of the height:
  6566. @example
  6567. scale=w=3/2*oh:h=3/5*ih
  6568. @end example
  6569. @item
  6570. Increase the size, making the size a multiple of the chroma
  6571. subsample values:
  6572. @example
  6573. scale="trunc(3/2*iw/hsub)*hsub:trunc(3/2*ih/vsub)*vsub"
  6574. @end example
  6575. @item
  6576. Increase the width to a maximum of 500 pixels,
  6577. keeping the same aspect ratio as the input:
  6578. @example
  6579. scale=w='min(500\, iw*3/2):h=-1'
  6580. @end example
  6581. @end itemize
  6582. @section separatefields
  6583. The @code{separatefields} takes a frame-based video input and splits
  6584. each frame into its components fields, producing a new half height clip
  6585. with twice the frame rate and twice the frame count.
  6586. This filter use field-dominance information in frame to decide which
  6587. of each pair of fields to place first in the output.
  6588. If it gets it wrong use @ref{setfield} filter before @code{separatefields} filter.
  6589. @section setdar, setsar
  6590. The @code{setdar} filter sets the Display Aspect Ratio for the filter
  6591. output video.
  6592. This is done by changing the specified Sample (aka Pixel) Aspect
  6593. Ratio, according to the following equation:
  6594. @example
  6595. @var{DAR} = @var{HORIZONTAL_RESOLUTION} / @var{VERTICAL_RESOLUTION} * @var{SAR}
  6596. @end example
  6597. Keep in mind that the @code{setdar} filter does not modify the pixel
  6598. dimensions of the video frame. Also, the display aspect ratio set by
  6599. this filter may be changed by later filters in the filterchain,
  6600. e.g. in case of scaling or if another "setdar" or a "setsar" filter is
  6601. applied.
  6602. The @code{setsar} filter sets the Sample (aka Pixel) Aspect Ratio for
  6603. the filter output video.
  6604. Note that as a consequence of the application of this filter, the
  6605. output display aspect ratio will change according to the equation
  6606. above.
  6607. Keep in mind that the sample aspect ratio set by the @code{setsar}
  6608. filter may be changed by later filters in the filterchain, e.g. if
  6609. another "setsar" or a "setdar" filter is applied.
  6610. It accepts the following parameters:
  6611. @table @option
  6612. @item r, ratio, dar (@code{setdar} only), sar (@code{setsar} only)
  6613. Set the aspect ratio used by the filter.
  6614. The parameter can be a floating point number string, an expression, or
  6615. a string of the form @var{num}:@var{den}, where @var{num} and
  6616. @var{den} are the numerator and denominator of the aspect ratio. If
  6617. the parameter is not specified, it is assumed the value "0".
  6618. In case the form "@var{num}:@var{den}" is used, the @code{:} character
  6619. should be escaped.
  6620. @item max
  6621. Set the maximum integer value to use for expressing numerator and
  6622. denominator when reducing the expressed aspect ratio to a rational.
  6623. Default value is @code{100}.
  6624. @end table
  6625. The parameter @var{sar} is an expression containing
  6626. the following constants:
  6627. @table @option
  6628. @item E, PI, PHI
  6629. These are approximated values for the mathematical constants e
  6630. (Euler's number), pi (Greek pi), and phi (the golden ratio).
  6631. @item w, h
  6632. The input width and height.
  6633. @item a
  6634. These are the same as @var{w} / @var{h}.
  6635. @item sar
  6636. The input sample aspect ratio.
  6637. @item dar
  6638. The input display aspect ratio. It is the same as
  6639. (@var{w} / @var{h}) * @var{sar}.
  6640. @item hsub, vsub
  6641. Horizontal and vertical chroma subsample values. For example, for the
  6642. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  6643. @end table
  6644. @subsection Examples
  6645. @itemize
  6646. @item
  6647. To change the display aspect ratio to 16:9, specify one of the following:
  6648. @example
  6649. setdar=dar=1.77777
  6650. setdar=dar=16/9
  6651. setdar=dar=1.77777
  6652. @end example
  6653. @item
  6654. To change the sample aspect ratio to 10:11, specify:
  6655. @example
  6656. setsar=sar=10/11
  6657. @end example
  6658. @item
  6659. To set a display aspect ratio of 16:9, and specify a maximum integer value of
  6660. 1000 in the aspect ratio reduction, use the command:
  6661. @example
  6662. setdar=ratio=16/9:max=1000
  6663. @end example
  6664. @end itemize
  6665. @anchor{setfield}
  6666. @section setfield
  6667. Force field for the output video frame.
  6668. The @code{setfield} filter marks the interlace type field for the
  6669. output frames. It does not change the input frame, but only sets the
  6670. corresponding property, which affects how the frame is treated by
  6671. following filters (e.g. @code{fieldorder} or @code{yadif}).
  6672. The filter accepts the following options:
  6673. @table @option
  6674. @item mode
  6675. Available values are:
  6676. @table @samp
  6677. @item auto
  6678. Keep the same field property.
  6679. @item bff
  6680. Mark the frame as bottom-field-first.
  6681. @item tff
  6682. Mark the frame as top-field-first.
  6683. @item prog
  6684. Mark the frame as progressive.
  6685. @end table
  6686. @end table
  6687. @section showinfo
  6688. Show a line containing various information for each input video frame.
  6689. The input video is not modified.
  6690. The shown line contains a sequence of key/value pairs of the form
  6691. @var{key}:@var{value}.
  6692. The following values are shown in the output:
  6693. @table @option
  6694. @item n
  6695. The (sequential) number of the input frame, starting from 0.
  6696. @item pts
  6697. The Presentation TimeStamp of the input frame, expressed as a number of
  6698. time base units. The time base unit depends on the filter input pad.
  6699. @item pts_time
  6700. The Presentation TimeStamp of the input frame, expressed as a number of
  6701. seconds.
  6702. @item pos
  6703. The position of the frame in the input stream, or -1 if this information is
  6704. unavailable and/or meaningless (for example in case of synthetic video).
  6705. @item fmt
  6706. The pixel format name.
  6707. @item sar
  6708. The sample aspect ratio of the input frame, expressed in the form
  6709. @var{num}/@var{den}.
  6710. @item s
  6711. The size of the input frame. For the syntax of this option, check the
  6712. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  6713. @item i
  6714. The type of interlaced mode ("P" for "progressive", "T" for top field first, "B"
  6715. for bottom field first).
  6716. @item iskey
  6717. This is 1 if the frame is a key frame, 0 otherwise.
  6718. @item type
  6719. The picture type of the input frame ("I" for an I-frame, "P" for a
  6720. P-frame, "B" for a B-frame, or "?" for an unknown type).
  6721. Also refer to the documentation of the @code{AVPictureType} enum and of
  6722. the @code{av_get_picture_type_char} function defined in
  6723. @file{libavutil/avutil.h}.
  6724. @item checksum
  6725. The Adler-32 checksum (printed in hexadecimal) of all the planes of the input frame.
  6726. @item plane_checksum
  6727. The Adler-32 checksum (printed in hexadecimal) of each plane of the input frame,
  6728. expressed in the form "[@var{c0} @var{c1} @var{c2} @var{c3}]".
  6729. @end table
  6730. @section showpalette
  6731. Displays the 256 colors palette of each frame. This filter is only relevant for
  6732. @var{pal8} pixel format frames.
  6733. It accepts the following option:
  6734. @table @option
  6735. @item s
  6736. Set the size of the box used to represent one palette color entry. Default is
  6737. @code{30} (for a @code{30x30} pixel box).
  6738. @end table
  6739. @section shuffleplanes
  6740. Reorder and/or duplicate video planes.
  6741. It accepts the following parameters:
  6742. @table @option
  6743. @item map0
  6744. The index of the input plane to be used as the first output plane.
  6745. @item map1
  6746. The index of the input plane to be used as the second output plane.
  6747. @item map2
  6748. The index of the input plane to be used as the third output plane.
  6749. @item map3
  6750. The index of the input plane to be used as the fourth output plane.
  6751. @end table
  6752. The first plane has the index 0. The default is to keep the input unchanged.
  6753. Swap the second and third planes of the input:
  6754. @example
  6755. ffmpeg -i INPUT -vf shuffleplanes=0:2:1:3 OUTPUT
  6756. @end example
  6757. @anchor{signalstats}
  6758. @section signalstats
  6759. Evaluate various visual metrics that assist in determining issues associated
  6760. with the digitization of analog video media.
  6761. By default the filter will log these metadata values:
  6762. @table @option
  6763. @item YMIN
  6764. Display the minimal Y value contained within the input frame. Expressed in
  6765. range of [0-255].
  6766. @item YLOW
  6767. Display the Y value at the 10% percentile within the input frame. Expressed in
  6768. range of [0-255].
  6769. @item YAVG
  6770. Display the average Y value within the input frame. Expressed in range of
  6771. [0-255].
  6772. @item YHIGH
  6773. Display the Y value at the 90% percentile within the input frame. Expressed in
  6774. range of [0-255].
  6775. @item YMAX
  6776. Display the maximum Y value contained within the input frame. Expressed in
  6777. range of [0-255].
  6778. @item UMIN
  6779. Display the minimal U value contained within the input frame. Expressed in
  6780. range of [0-255].
  6781. @item ULOW
  6782. Display the U value at the 10% percentile within the input frame. Expressed in
  6783. range of [0-255].
  6784. @item UAVG
  6785. Display the average U value within the input frame. Expressed in range of
  6786. [0-255].
  6787. @item UHIGH
  6788. Display the U value at the 90% percentile within the input frame. Expressed in
  6789. range of [0-255].
  6790. @item UMAX
  6791. Display the maximum U value contained within the input frame. Expressed in
  6792. range of [0-255].
  6793. @item VMIN
  6794. Display the minimal V value contained within the input frame. Expressed in
  6795. range of [0-255].
  6796. @item VLOW
  6797. Display the V value at the 10% percentile within the input frame. Expressed in
  6798. range of [0-255].
  6799. @item VAVG
  6800. Display the average V value within the input frame. Expressed in range of
  6801. [0-255].
  6802. @item VHIGH
  6803. Display the V value at the 90% percentile within the input frame. Expressed in
  6804. range of [0-255].
  6805. @item VMAX
  6806. Display the maximum V value contained within the input frame. Expressed in
  6807. range of [0-255].
  6808. @item SATMIN
  6809. Display the minimal saturation value contained within the input frame.
  6810. Expressed in range of [0-~181.02].
  6811. @item SATLOW
  6812. Display the saturation value at the 10% percentile within the input frame.
  6813. Expressed in range of [0-~181.02].
  6814. @item SATAVG
  6815. Display the average saturation value within the input frame. Expressed in range
  6816. of [0-~181.02].
  6817. @item SATHIGH
  6818. Display the saturation value at the 90% percentile within the input frame.
  6819. Expressed in range of [0-~181.02].
  6820. @item SATMAX
  6821. Display the maximum saturation value contained within the input frame.
  6822. Expressed in range of [0-~181.02].
  6823. @item HUEMED
  6824. Display the median value for hue within the input frame. Expressed in range of
  6825. [0-360].
  6826. @item HUEAVG
  6827. Display the average value for hue within the input frame. Expressed in range of
  6828. [0-360].
  6829. @item YDIF
  6830. Display the average of sample value difference between all values of the Y
  6831. plane in the current frame and corresponding values of the previous input frame.
  6832. Expressed in range of [0-255].
  6833. @item UDIF
  6834. Display the average of sample value difference between all values of the U
  6835. plane in the current frame and corresponding values of the previous input frame.
  6836. Expressed in range of [0-255].
  6837. @item VDIF
  6838. Display the average of sample value difference between all values of the V
  6839. plane in the current frame and corresponding values of the previous input frame.
  6840. Expressed in range of [0-255].
  6841. @end table
  6842. The filter accepts the following options:
  6843. @table @option
  6844. @item stat
  6845. @item out
  6846. @option{stat} specify an additional form of image analysis.
  6847. @option{out} output video with the specified type of pixel highlighted.
  6848. Both options accept the following values:
  6849. @table @samp
  6850. @item tout
  6851. Identify @var{temporal outliers} pixels. A @var{temporal outlier} is a pixel
  6852. unlike the neighboring pixels of the same field. Examples of temporal outliers
  6853. include the results of video dropouts, head clogs, or tape tracking issues.
  6854. @item vrep
  6855. Identify @var{vertical line repetition}. Vertical line repetition includes
  6856. similar rows of pixels within a frame. In born-digital video vertical line
  6857. repetition is common, but this pattern is uncommon in video digitized from an
  6858. analog source. When it occurs in video that results from the digitization of an
  6859. analog source it can indicate concealment from a dropout compensator.
  6860. @item brng
  6861. Identify pixels that fall outside of legal broadcast range.
  6862. @end table
  6863. @item color, c
  6864. Set the highlight color for the @option{out} option. The default color is
  6865. yellow.
  6866. @end table
  6867. @subsection Examples
  6868. @itemize
  6869. @item
  6870. Output data of various video metrics:
  6871. @example
  6872. ffprobe -f lavfi movie=example.mov,signalstats="stat=tout+vrep+brng" -show_frames
  6873. @end example
  6874. @item
  6875. Output specific data about the minimum and maximum values of the Y plane per frame:
  6876. @example
  6877. ffprobe -f lavfi movie=example.mov,signalstats -show_entries frame_tags=lavfi.signalstats.YMAX,lavfi.signalstats.YMIN
  6878. @end example
  6879. @item
  6880. Playback video while highlighting pixels that are outside of broadcast range in red.
  6881. @example
  6882. ffplay example.mov -vf signalstats="out=brng:color=red"
  6883. @end example
  6884. @item
  6885. Playback video with signalstats metadata drawn over the frame.
  6886. @example
  6887. ffplay example.mov -vf signalstats=stat=brng+vrep+tout,drawtext=fontfile=FreeSerif.ttf:textfile=signalstat_drawtext.txt
  6888. @end example
  6889. The contents of signalstat_drawtext.txt used in the command are:
  6890. @example
  6891. time %@{pts:hms@}
  6892. Y (%@{metadata:lavfi.signalstats.YMIN@}-%@{metadata:lavfi.signalstats.YMAX@})
  6893. U (%@{metadata:lavfi.signalstats.UMIN@}-%@{metadata:lavfi.signalstats.UMAX@})
  6894. V (%@{metadata:lavfi.signalstats.VMIN@}-%@{metadata:lavfi.signalstats.VMAX@})
  6895. saturation maximum: %@{metadata:lavfi.signalstats.SATMAX@}
  6896. @end example
  6897. @end itemize
  6898. @anchor{smartblur}
  6899. @section smartblur
  6900. Blur the input video without impacting the outlines.
  6901. It accepts the following options:
  6902. @table @option
  6903. @item luma_radius, lr
  6904. Set the luma radius. The option value must be a float number in
  6905. the range [0.1,5.0] that specifies the variance of the gaussian filter
  6906. used to blur the image (slower if larger). Default value is 1.0.
  6907. @item luma_strength, ls
  6908. Set the luma strength. The option value must be a float number
  6909. in the range [-1.0,1.0] that configures the blurring. A value included
  6910. in [0.0,1.0] will blur the image whereas a value included in
  6911. [-1.0,0.0] will sharpen the image. Default value is 1.0.
  6912. @item luma_threshold, lt
  6913. Set the luma threshold used as a coefficient to determine
  6914. whether a pixel should be blurred or not. The option value must be an
  6915. integer in the range [-30,30]. A value of 0 will filter all the image,
  6916. a value included in [0,30] will filter flat areas and a value included
  6917. in [-30,0] will filter edges. Default value is 0.
  6918. @item chroma_radius, cr
  6919. Set the chroma radius. The option value must be a float number in
  6920. the range [0.1,5.0] that specifies the variance of the gaussian filter
  6921. used to blur the image (slower if larger). Default value is 1.0.
  6922. @item chroma_strength, cs
  6923. Set the chroma strength. The option value must be a float number
  6924. in the range [-1.0,1.0] that configures the blurring. A value included
  6925. in [0.0,1.0] will blur the image whereas a value included in
  6926. [-1.0,0.0] will sharpen the image. Default value is 1.0.
  6927. @item chroma_threshold, ct
  6928. Set the chroma threshold used as a coefficient to determine
  6929. whether a pixel should be blurred or not. The option value must be an
  6930. integer in the range [-30,30]. A value of 0 will filter all the image,
  6931. a value included in [0,30] will filter flat areas and a value included
  6932. in [-30,0] will filter edges. Default value is 0.
  6933. @end table
  6934. If a chroma option is not explicitly set, the corresponding luma value
  6935. is set.
  6936. @section ssim
  6937. Obtain the SSIM (Structural SImilarity Metric) between two input videos.
  6938. This filter takes in input two input videos, the first input is
  6939. considered the "main" source and is passed unchanged to the
  6940. output. The second input is used as a "reference" video for computing
  6941. the SSIM.
  6942. Both video inputs must have the same resolution and pixel format for
  6943. this filter to work correctly. Also it assumes that both inputs
  6944. have the same number of frames, which are compared one by one.
  6945. The filter stores the calculated SSIM of each frame.
  6946. The description of the accepted parameters follows.
  6947. @table @option
  6948. @item stats_file, f
  6949. If specified the filter will use the named file to save the SSIM of
  6950. each individual frame.
  6951. @end table
  6952. The file printed if @var{stats_file} is selected, contains a sequence of
  6953. key/value pairs of the form @var{key}:@var{value} for each compared
  6954. couple of frames.
  6955. A description of each shown parameter follows:
  6956. @table @option
  6957. @item n
  6958. sequential number of the input frame, starting from 1
  6959. @item Y, U, V, R, G, B
  6960. SSIM of the compared frames for the component specified by the suffix.
  6961. @item All
  6962. SSIM of the compared frames for the whole frame.
  6963. @item dB
  6964. Same as above but in dB representation.
  6965. @end table
  6966. For example:
  6967. @example
  6968. movie=ref_movie.mpg, setpts=PTS-STARTPTS [main];
  6969. [main][ref] ssim="stats_file=stats.log" [out]
  6970. @end example
  6971. On this example the input file being processed is compared with the
  6972. reference file @file{ref_movie.mpg}. The SSIM of each individual frame
  6973. is stored in @file{stats.log}.
  6974. Another example with both psnr and ssim at same time:
  6975. @example
  6976. ffmpeg -i main.mpg -i ref.mpg -lavfi "ssim;[0:v][1:v]psnr" -f null -
  6977. @end example
  6978. @section stereo3d
  6979. Convert between different stereoscopic image formats.
  6980. The filters accept the following options:
  6981. @table @option
  6982. @item in
  6983. Set stereoscopic image format of input.
  6984. Available values for input image formats are:
  6985. @table @samp
  6986. @item sbsl
  6987. side by side parallel (left eye left, right eye right)
  6988. @item sbsr
  6989. side by side crosseye (right eye left, left eye right)
  6990. @item sbs2l
  6991. side by side parallel with half width resolution
  6992. (left eye left, right eye right)
  6993. @item sbs2r
  6994. side by side crosseye with half width resolution
  6995. (right eye left, left eye right)
  6996. @item abl
  6997. above-below (left eye above, right eye below)
  6998. @item abr
  6999. above-below (right eye above, left eye below)
  7000. @item ab2l
  7001. above-below with half height resolution
  7002. (left eye above, right eye below)
  7003. @item ab2r
  7004. above-below with half height resolution
  7005. (right eye above, left eye below)
  7006. @item al
  7007. alternating frames (left eye first, right eye second)
  7008. @item ar
  7009. alternating frames (right eye first, left eye second)
  7010. Default value is @samp{sbsl}.
  7011. @end table
  7012. @item out
  7013. Set stereoscopic image format of output.
  7014. Available values for output image formats are all the input formats as well as:
  7015. @table @samp
  7016. @item arbg
  7017. anaglyph red/blue gray
  7018. (red filter on left eye, blue filter on right eye)
  7019. @item argg
  7020. anaglyph red/green gray
  7021. (red filter on left eye, green filter on right eye)
  7022. @item arcg
  7023. anaglyph red/cyan gray
  7024. (red filter on left eye, cyan filter on right eye)
  7025. @item arch
  7026. anaglyph red/cyan half colored
  7027. (red filter on left eye, cyan filter on right eye)
  7028. @item arcc
  7029. anaglyph red/cyan color
  7030. (red filter on left eye, cyan filter on right eye)
  7031. @item arcd
  7032. anaglyph red/cyan color optimized with the least squares projection of dubois
  7033. (red filter on left eye, cyan filter on right eye)
  7034. @item agmg
  7035. anaglyph green/magenta gray
  7036. (green filter on left eye, magenta filter on right eye)
  7037. @item agmh
  7038. anaglyph green/magenta half colored
  7039. (green filter on left eye, magenta filter on right eye)
  7040. @item agmc
  7041. anaglyph green/magenta colored
  7042. (green filter on left eye, magenta filter on right eye)
  7043. @item agmd
  7044. anaglyph green/magenta color optimized with the least squares projection of dubois
  7045. (green filter on left eye, magenta filter on right eye)
  7046. @item aybg
  7047. anaglyph yellow/blue gray
  7048. (yellow filter on left eye, blue filter on right eye)
  7049. @item aybh
  7050. anaglyph yellow/blue half colored
  7051. (yellow filter on left eye, blue filter on right eye)
  7052. @item aybc
  7053. anaglyph yellow/blue colored
  7054. (yellow filter on left eye, blue filter on right eye)
  7055. @item aybd
  7056. anaglyph yellow/blue color optimized with the least squares projection of dubois
  7057. (yellow filter on left eye, blue filter on right eye)
  7058. @item irl
  7059. interleaved rows (left eye has top row, right eye starts on next row)
  7060. @item irr
  7061. interleaved rows (right eye has top row, left eye starts on next row)
  7062. @item ml
  7063. mono output (left eye only)
  7064. @item mr
  7065. mono output (right eye only)
  7066. @end table
  7067. Default value is @samp{arcd}.
  7068. @end table
  7069. @subsection Examples
  7070. @itemize
  7071. @item
  7072. Convert input video from side by side parallel to anaglyph yellow/blue dubois:
  7073. @example
  7074. stereo3d=sbsl:aybd
  7075. @end example
  7076. @item
  7077. Convert input video from above bellow (left eye above, right eye below) to side by side crosseye.
  7078. @example
  7079. stereo3d=abl:sbsr
  7080. @end example
  7081. @end itemize
  7082. @anchor{spp}
  7083. @section spp
  7084. Apply a simple postprocessing filter that compresses and decompresses the image
  7085. at several (or - in the case of @option{quality} level @code{6} - all) shifts
  7086. and average the results.
  7087. The filter accepts the following options:
  7088. @table @option
  7089. @item quality
  7090. Set quality. This option defines the number of levels for averaging. It accepts
  7091. an integer in the range 0-6. If set to @code{0}, the filter will have no
  7092. effect. A value of @code{6} means the higher quality. For each increment of
  7093. that value the speed drops by a factor of approximately 2. Default value is
  7094. @code{3}.
  7095. @item qp
  7096. Force a constant quantization parameter. If not set, the filter will use the QP
  7097. from the video stream (if available).
  7098. @item mode
  7099. Set thresholding mode. Available modes are:
  7100. @table @samp
  7101. @item hard
  7102. Set hard thresholding (default).
  7103. @item soft
  7104. Set soft thresholding (better de-ringing effect, but likely blurrier).
  7105. @end table
  7106. @item use_bframe_qp
  7107. Enable the use of the QP from the B-Frames if set to @code{1}. Using this
  7108. option may cause flicker since the B-Frames have often larger QP. Default is
  7109. @code{0} (not enabled).
  7110. @end table
  7111. @anchor{subtitles}
  7112. @section subtitles
  7113. Draw subtitles on top of input video using the libass library.
  7114. To enable compilation of this filter you need to configure FFmpeg with
  7115. @code{--enable-libass}. This filter also requires a build with libavcodec and
  7116. libavformat to convert the passed subtitles file to ASS (Advanced Substation
  7117. Alpha) subtitles format.
  7118. The filter accepts the following options:
  7119. @table @option
  7120. @item filename, f
  7121. Set the filename of the subtitle file to read. It must be specified.
  7122. @item original_size
  7123. Specify the size of the original video, the video for which the ASS file
  7124. was composed. For the syntax of this option, check the
  7125. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  7126. Due to a misdesign in ASS aspect ratio arithmetic, this is necessary to
  7127. correctly scale the fonts if the aspect ratio has been changed.
  7128. @item charenc
  7129. Set subtitles input character encoding. @code{subtitles} filter only. Only
  7130. useful if not UTF-8.
  7131. @item stream_index, si
  7132. Set subtitles stream index. @code{subtitles} filter only.
  7133. @item force_style
  7134. Override default style or script info parameters of the subtitles. It accepts a
  7135. string containing ASS style format @code{KEY=VALUE} couples separated by ",".
  7136. @end table
  7137. If the first key is not specified, it is assumed that the first value
  7138. specifies the @option{filename}.
  7139. For example, to render the file @file{sub.srt} on top of the input
  7140. video, use the command:
  7141. @example
  7142. subtitles=sub.srt
  7143. @end example
  7144. which is equivalent to:
  7145. @example
  7146. subtitles=filename=sub.srt
  7147. @end example
  7148. To render the default subtitles stream from file @file{video.mkv}, use:
  7149. @example
  7150. subtitles=video.mkv
  7151. @end example
  7152. To render the second subtitles stream from that file, use:
  7153. @example
  7154. subtitles=video.mkv:si=1
  7155. @end example
  7156. To make the subtitles stream from @file{sub.srt} appear in transparent green
  7157. @code{DejaVu Serif}, use:
  7158. @example
  7159. subtitles=sub.srt:force_style='FontName=DejaVu Serif,PrimaryColour=&HAA00FF00'
  7160. @end example
  7161. @section super2xsai
  7162. Scale the input by 2x and smooth using the Super2xSaI (Scale and
  7163. Interpolate) pixel art scaling algorithm.
  7164. Useful for enlarging pixel art images without reducing sharpness.
  7165. @section swapuv
  7166. Swap U & V plane.
  7167. @section telecine
  7168. Apply telecine process to the video.
  7169. This filter accepts the following options:
  7170. @table @option
  7171. @item first_field
  7172. @table @samp
  7173. @item top, t
  7174. top field first
  7175. @item bottom, b
  7176. bottom field first
  7177. The default value is @code{top}.
  7178. @end table
  7179. @item pattern
  7180. A string of numbers representing the pulldown pattern you wish to apply.
  7181. The default value is @code{23}.
  7182. @end table
  7183. @example
  7184. Some typical patterns:
  7185. NTSC output (30i):
  7186. 27.5p: 32222
  7187. 24p: 23 (classic)
  7188. 24p: 2332 (preferred)
  7189. 20p: 33
  7190. 18p: 334
  7191. 16p: 3444
  7192. PAL output (25i):
  7193. 27.5p: 12222
  7194. 24p: 222222222223 ("Euro pulldown")
  7195. 16.67p: 33
  7196. 16p: 33333334
  7197. @end example
  7198. @section thumbnail
  7199. Select the most representative frame in a given sequence of consecutive frames.
  7200. The filter accepts the following options:
  7201. @table @option
  7202. @item n
  7203. Set the frames batch size to analyze; in a set of @var{n} frames, the filter
  7204. will pick one of them, and then handle the next batch of @var{n} frames until
  7205. the end. Default is @code{100}.
  7206. @end table
  7207. Since the filter keeps track of the whole frames sequence, a bigger @var{n}
  7208. value will result in a higher memory usage, so a high value is not recommended.
  7209. @subsection Examples
  7210. @itemize
  7211. @item
  7212. Extract one picture each 50 frames:
  7213. @example
  7214. thumbnail=50
  7215. @end example
  7216. @item
  7217. Complete example of a thumbnail creation with @command{ffmpeg}:
  7218. @example
  7219. ffmpeg -i in.avi -vf thumbnail,scale=300:200 -frames:v 1 out.png
  7220. @end example
  7221. @end itemize
  7222. @section tile
  7223. Tile several successive frames together.
  7224. The filter accepts the following options:
  7225. @table @option
  7226. @item layout
  7227. Set the grid size (i.e. the number of lines and columns). For the syntax of
  7228. this option, check the
  7229. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  7230. @item nb_frames
  7231. Set the maximum number of frames to render in the given area. It must be less
  7232. than or equal to @var{w}x@var{h}. The default value is @code{0}, meaning all
  7233. the area will be used.
  7234. @item margin
  7235. Set the outer border margin in pixels.
  7236. @item padding
  7237. Set the inner border thickness (i.e. the number of pixels between frames). For
  7238. more advanced padding options (such as having different values for the edges),
  7239. refer to the pad video filter.
  7240. @item color
  7241. Specify the color of the unused area. For the syntax of this option, check the
  7242. "Color" section in the ffmpeg-utils manual. The default value of @var{color}
  7243. is "black".
  7244. @end table
  7245. @subsection Examples
  7246. @itemize
  7247. @item
  7248. Produce 8x8 PNG tiles of all keyframes (@option{-skip_frame nokey}) in a movie:
  7249. @example
  7250. ffmpeg -skip_frame nokey -i file.avi -vf 'scale=128:72,tile=8x8' -an -vsync 0 keyframes%03d.png
  7251. @end example
  7252. The @option{-vsync 0} is necessary to prevent @command{ffmpeg} from
  7253. duplicating each output frame to accommodate the originally detected frame
  7254. rate.
  7255. @item
  7256. Display @code{5} pictures in an area of @code{3x2} frames,
  7257. with @code{7} pixels between them, and @code{2} pixels of initial margin, using
  7258. mixed flat and named options:
  7259. @example
  7260. tile=3x2:nb_frames=5:padding=7:margin=2
  7261. @end example
  7262. @end itemize
  7263. @section tinterlace
  7264. Perform various types of temporal field interlacing.
  7265. Frames are counted starting from 1, so the first input frame is
  7266. considered odd.
  7267. The filter accepts the following options:
  7268. @table @option
  7269. @item mode
  7270. Specify the mode of the interlacing. This option can also be specified
  7271. as a value alone. See below for a list of values for this option.
  7272. Available values are:
  7273. @table @samp
  7274. @item merge, 0
  7275. Move odd frames into the upper field, even into the lower field,
  7276. generating a double height frame at half frame rate.
  7277. @example
  7278. ------> time
  7279. Input:
  7280. Frame 1 Frame 2 Frame 3 Frame 4
  7281. 11111 22222 33333 44444
  7282. 11111 22222 33333 44444
  7283. 11111 22222 33333 44444
  7284. 11111 22222 33333 44444
  7285. Output:
  7286. 11111 33333
  7287. 22222 44444
  7288. 11111 33333
  7289. 22222 44444
  7290. 11111 33333
  7291. 22222 44444
  7292. 11111 33333
  7293. 22222 44444
  7294. @end example
  7295. @item drop_odd, 1
  7296. Only output even frames, odd frames are dropped, generating a frame with
  7297. unchanged height at half frame rate.
  7298. @example
  7299. ------> time
  7300. Input:
  7301. Frame 1 Frame 2 Frame 3 Frame 4
  7302. 11111 22222 33333 44444
  7303. 11111 22222 33333 44444
  7304. 11111 22222 33333 44444
  7305. 11111 22222 33333 44444
  7306. Output:
  7307. 22222 44444
  7308. 22222 44444
  7309. 22222 44444
  7310. 22222 44444
  7311. @end example
  7312. @item drop_even, 2
  7313. Only output odd frames, even frames are dropped, generating a frame with
  7314. unchanged height at half frame rate.
  7315. @example
  7316. ------> time
  7317. Input:
  7318. Frame 1 Frame 2 Frame 3 Frame 4
  7319. 11111 22222 33333 44444
  7320. 11111 22222 33333 44444
  7321. 11111 22222 33333 44444
  7322. 11111 22222 33333 44444
  7323. Output:
  7324. 11111 33333
  7325. 11111 33333
  7326. 11111 33333
  7327. 11111 33333
  7328. @end example
  7329. @item pad, 3
  7330. Expand each frame to full height, but pad alternate lines with black,
  7331. generating a frame with double height at the same input frame rate.
  7332. @example
  7333. ------> time
  7334. Input:
  7335. Frame 1 Frame 2 Frame 3 Frame 4
  7336. 11111 22222 33333 44444
  7337. 11111 22222 33333 44444
  7338. 11111 22222 33333 44444
  7339. 11111 22222 33333 44444
  7340. Output:
  7341. 11111 ..... 33333 .....
  7342. ..... 22222 ..... 44444
  7343. 11111 ..... 33333 .....
  7344. ..... 22222 ..... 44444
  7345. 11111 ..... 33333 .....
  7346. ..... 22222 ..... 44444
  7347. 11111 ..... 33333 .....
  7348. ..... 22222 ..... 44444
  7349. @end example
  7350. @item interleave_top, 4
  7351. Interleave the upper field from odd frames with the lower field from
  7352. even frames, generating a frame with unchanged height at half frame rate.
  7353. @example
  7354. ------> time
  7355. Input:
  7356. Frame 1 Frame 2 Frame 3 Frame 4
  7357. 11111<- 22222 33333<- 44444
  7358. 11111 22222<- 33333 44444<-
  7359. 11111<- 22222 33333<- 44444
  7360. 11111 22222<- 33333 44444<-
  7361. Output:
  7362. 11111 33333
  7363. 22222 44444
  7364. 11111 33333
  7365. 22222 44444
  7366. @end example
  7367. @item interleave_bottom, 5
  7368. Interleave the lower field from odd frames with the upper field from
  7369. even frames, generating a frame with unchanged height at half frame rate.
  7370. @example
  7371. ------> time
  7372. Input:
  7373. Frame 1 Frame 2 Frame 3 Frame 4
  7374. 11111 22222<- 33333 44444<-
  7375. 11111<- 22222 33333<- 44444
  7376. 11111 22222<- 33333 44444<-
  7377. 11111<- 22222 33333<- 44444
  7378. Output:
  7379. 22222 44444
  7380. 11111 33333
  7381. 22222 44444
  7382. 11111 33333
  7383. @end example
  7384. @item interlacex2, 6
  7385. Double frame rate with unchanged height. Frames are inserted each
  7386. containing the second temporal field from the previous input frame and
  7387. the first temporal field from the next input frame. This mode relies on
  7388. the top_field_first flag. Useful for interlaced video displays with no
  7389. field synchronisation.
  7390. @example
  7391. ------> time
  7392. Input:
  7393. Frame 1 Frame 2 Frame 3 Frame 4
  7394. 11111 22222 33333 44444
  7395. 11111 22222 33333 44444
  7396. 11111 22222 33333 44444
  7397. 11111 22222 33333 44444
  7398. Output:
  7399. 11111 22222 22222 33333 33333 44444 44444
  7400. 11111 11111 22222 22222 33333 33333 44444
  7401. 11111 22222 22222 33333 33333 44444 44444
  7402. 11111 11111 22222 22222 33333 33333 44444
  7403. @end example
  7404. @end table
  7405. Numeric values are deprecated but are accepted for backward
  7406. compatibility reasons.
  7407. Default mode is @code{merge}.
  7408. @item flags
  7409. Specify flags influencing the filter process.
  7410. Available value for @var{flags} is:
  7411. @table @option
  7412. @item low_pass_filter, vlfp
  7413. Enable vertical low-pass filtering in the filter.
  7414. Vertical low-pass filtering is required when creating an interlaced
  7415. destination from a progressive source which contains high-frequency
  7416. vertical detail. Filtering will reduce interlace 'twitter' and Moire
  7417. patterning.
  7418. Vertical low-pass filtering can only be enabled for @option{mode}
  7419. @var{interleave_top} and @var{interleave_bottom}.
  7420. @end table
  7421. @end table
  7422. @section transpose
  7423. Transpose rows with columns in the input video and optionally flip it.
  7424. It accepts the following parameters:
  7425. @table @option
  7426. @item dir
  7427. Specify the transposition direction.
  7428. Can assume the following values:
  7429. @table @samp
  7430. @item 0, 4, cclock_flip
  7431. Rotate by 90 degrees counterclockwise and vertically flip (default), that is:
  7432. @example
  7433. L.R L.l
  7434. . . -> . .
  7435. l.r R.r
  7436. @end example
  7437. @item 1, 5, clock
  7438. Rotate by 90 degrees clockwise, that is:
  7439. @example
  7440. L.R l.L
  7441. . . -> . .
  7442. l.r r.R
  7443. @end example
  7444. @item 2, 6, cclock
  7445. Rotate by 90 degrees counterclockwise, that is:
  7446. @example
  7447. L.R R.r
  7448. . . -> . .
  7449. l.r L.l
  7450. @end example
  7451. @item 3, 7, clock_flip
  7452. Rotate by 90 degrees clockwise and vertically flip, that is:
  7453. @example
  7454. L.R r.R
  7455. . . -> . .
  7456. l.r l.L
  7457. @end example
  7458. @end table
  7459. For values between 4-7, the transposition is only done if the input
  7460. video geometry is portrait and not landscape. These values are
  7461. deprecated, the @code{passthrough} option should be used instead.
  7462. Numerical values are deprecated, and should be dropped in favor of
  7463. symbolic constants.
  7464. @item passthrough
  7465. Do not apply the transposition if the input geometry matches the one
  7466. specified by the specified value. It accepts the following values:
  7467. @table @samp
  7468. @item none
  7469. Always apply transposition.
  7470. @item portrait
  7471. Preserve portrait geometry (when @var{height} >= @var{width}).
  7472. @item landscape
  7473. Preserve landscape geometry (when @var{width} >= @var{height}).
  7474. @end table
  7475. Default value is @code{none}.
  7476. @end table
  7477. For example to rotate by 90 degrees clockwise and preserve portrait
  7478. layout:
  7479. @example
  7480. transpose=dir=1:passthrough=portrait
  7481. @end example
  7482. The command above can also be specified as:
  7483. @example
  7484. transpose=1:portrait
  7485. @end example
  7486. @section trim
  7487. Trim the input so that the output contains one continuous subpart of the input.
  7488. It accepts the following parameters:
  7489. @table @option
  7490. @item start
  7491. Specify the time of the start of the kept section, i.e. the frame with the
  7492. timestamp @var{start} will be the first frame in the output.
  7493. @item end
  7494. Specify the time of the first frame that will be dropped, i.e. the frame
  7495. immediately preceding the one with the timestamp @var{end} will be the last
  7496. frame in the output.
  7497. @item start_pts
  7498. This is the same as @var{start}, except this option sets the start timestamp
  7499. in timebase units instead of seconds.
  7500. @item end_pts
  7501. This is the same as @var{end}, except this option sets the end timestamp
  7502. in timebase units instead of seconds.
  7503. @item duration
  7504. The maximum duration of the output in seconds.
  7505. @item start_frame
  7506. The number of the first frame that should be passed to the output.
  7507. @item end_frame
  7508. The number of the first frame that should be dropped.
  7509. @end table
  7510. @option{start}, @option{end}, and @option{duration} are expressed as time
  7511. duration specifications; see
  7512. @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}
  7513. for the accepted syntax.
  7514. Note that the first two sets of the start/end options and the @option{duration}
  7515. option look at the frame timestamp, while the _frame variants simply count the
  7516. frames that pass through the filter. Also note that this filter does not modify
  7517. the timestamps. If you wish for the output timestamps to start at zero, insert a
  7518. setpts filter after the trim filter.
  7519. If multiple start or end options are set, this filter tries to be greedy and
  7520. keep all the frames that match at least one of the specified constraints. To keep
  7521. only the part that matches all the constraints at once, chain multiple trim
  7522. filters.
  7523. The defaults are such that all the input is kept. So it is possible to set e.g.
  7524. just the end values to keep everything before the specified time.
  7525. Examples:
  7526. @itemize
  7527. @item
  7528. Drop everything except the second minute of input:
  7529. @example
  7530. ffmpeg -i INPUT -vf trim=60:120
  7531. @end example
  7532. @item
  7533. Keep only the first second:
  7534. @example
  7535. ffmpeg -i INPUT -vf trim=duration=1
  7536. @end example
  7537. @end itemize
  7538. @anchor{unsharp}
  7539. @section unsharp
  7540. Sharpen or blur the input video.
  7541. It accepts the following parameters:
  7542. @table @option
  7543. @item luma_msize_x, lx
  7544. Set the luma matrix horizontal size. It must be an odd integer between
  7545. 3 and 63. The default value is 5.
  7546. @item luma_msize_y, ly
  7547. Set the luma matrix vertical size. It must be an odd integer between 3
  7548. and 63. The default value is 5.
  7549. @item luma_amount, la
  7550. Set the luma effect strength. It must be a floating point number, reasonable
  7551. values lay between -1.5 and 1.5.
  7552. Negative values will blur the input video, while positive values will
  7553. sharpen it, a value of zero will disable the effect.
  7554. Default value is 1.0.
  7555. @item chroma_msize_x, cx
  7556. Set the chroma matrix horizontal size. It must be an odd integer
  7557. between 3 and 63. The default value is 5.
  7558. @item chroma_msize_y, cy
  7559. Set the chroma matrix vertical size. It must be an odd integer
  7560. between 3 and 63. The default value is 5.
  7561. @item chroma_amount, ca
  7562. Set the chroma effect strength. It must be a floating point number, reasonable
  7563. values lay between -1.5 and 1.5.
  7564. Negative values will blur the input video, while positive values will
  7565. sharpen it, a value of zero will disable the effect.
  7566. Default value is 0.0.
  7567. @item opencl
  7568. If set to 1, specify using OpenCL capabilities, only available if
  7569. FFmpeg was configured with @code{--enable-opencl}. Default value is 0.
  7570. @end table
  7571. All parameters are optional and default to the equivalent of the
  7572. string '5:5:1.0:5:5:0.0'.
  7573. @subsection Examples
  7574. @itemize
  7575. @item
  7576. Apply strong luma sharpen effect:
  7577. @example
  7578. unsharp=luma_msize_x=7:luma_msize_y=7:luma_amount=2.5
  7579. @end example
  7580. @item
  7581. Apply a strong blur of both luma and chroma parameters:
  7582. @example
  7583. unsharp=7:7:-2:7:7:-2
  7584. @end example
  7585. @end itemize
  7586. @section uspp
  7587. Apply ultra slow/simple postprocessing filter that compresses and decompresses
  7588. the image at several (or - in the case of @option{quality} level @code{8} - all)
  7589. shifts and average the results.
  7590. The way this differs from the behavior of spp is that uspp actually encodes &
  7591. decodes each case with libavcodec Snow, whereas spp uses a simplified intra only 8x8
  7592. DCT similar to MJPEG.
  7593. The filter accepts the following options:
  7594. @table @option
  7595. @item quality
  7596. Set quality. This option defines the number of levels for averaging. It accepts
  7597. an integer in the range 0-8. If set to @code{0}, the filter will have no
  7598. effect. A value of @code{8} means the higher quality. For each increment of
  7599. that value the speed drops by a factor of approximately 2. Default value is
  7600. @code{3}.
  7601. @item qp
  7602. Force a constant quantization parameter. If not set, the filter will use the QP
  7603. from the video stream (if available).
  7604. @end table
  7605. @anchor{vidstabdetect}
  7606. @section vidstabdetect
  7607. Analyze video stabilization/deshaking. Perform pass 1 of 2, see
  7608. @ref{vidstabtransform} for pass 2.
  7609. This filter generates a file with relative translation and rotation
  7610. transform information about subsequent frames, which is then used by
  7611. the @ref{vidstabtransform} filter.
  7612. To enable compilation of this filter you need to configure FFmpeg with
  7613. @code{--enable-libvidstab}.
  7614. This filter accepts the following options:
  7615. @table @option
  7616. @item result
  7617. Set the path to the file used to write the transforms information.
  7618. Default value is @file{transforms.trf}.
  7619. @item shakiness
  7620. Set how shaky the video is and how quick the camera is. It accepts an
  7621. integer in the range 1-10, a value of 1 means little shakiness, a
  7622. value of 10 means strong shakiness. Default value is 5.
  7623. @item accuracy
  7624. Set the accuracy of the detection process. It must be a value in the
  7625. range 1-15. A value of 1 means low accuracy, a value of 15 means high
  7626. accuracy. Default value is 15.
  7627. @item stepsize
  7628. Set stepsize of the search process. The region around minimum is
  7629. scanned with 1 pixel resolution. Default value is 6.
  7630. @item mincontrast
  7631. Set minimum contrast. Below this value a local measurement field is
  7632. discarded. Must be a floating point value in the range 0-1. Default
  7633. value is 0.3.
  7634. @item tripod
  7635. Set reference frame number for tripod mode.
  7636. If enabled, the motion of the frames is compared to a reference frame
  7637. in the filtered stream, identified by the specified number. The idea
  7638. is to compensate all movements in a more-or-less static scene and keep
  7639. the camera view absolutely still.
  7640. If set to 0, it is disabled. The frames are counted starting from 1.
  7641. @item show
  7642. Show fields and transforms in the resulting frames. It accepts an
  7643. integer in the range 0-2. Default value is 0, which disables any
  7644. visualization.
  7645. @end table
  7646. @subsection Examples
  7647. @itemize
  7648. @item
  7649. Use default values:
  7650. @example
  7651. vidstabdetect
  7652. @end example
  7653. @item
  7654. Analyze strongly shaky movie and put the results in file
  7655. @file{mytransforms.trf}:
  7656. @example
  7657. vidstabdetect=shakiness=10:accuracy=15:result="mytransforms.trf"
  7658. @end example
  7659. @item
  7660. Visualize the result of internal transformations in the resulting
  7661. video:
  7662. @example
  7663. vidstabdetect=show=1
  7664. @end example
  7665. @item
  7666. Analyze a video with medium shakiness using @command{ffmpeg}:
  7667. @example
  7668. ffmpeg -i input -vf vidstabdetect=shakiness=5:show=1 dummy.avi
  7669. @end example
  7670. @end itemize
  7671. @anchor{vidstabtransform}
  7672. @section vidstabtransform
  7673. Video stabilization/deshaking: pass 2 of 2,
  7674. see @ref{vidstabdetect} for pass 1.
  7675. Read a file with transform information for each frame and
  7676. apply/compensate them. Together with the @ref{vidstabdetect}
  7677. filter this can be used to deshake videos. See also
  7678. @url{http://public.hronopik.de/vid.stab}. It is important to also use
  7679. the @ref{unsharp} filter, see below.
  7680. To enable compilation of this filter you need to configure FFmpeg with
  7681. @code{--enable-libvidstab}.
  7682. @subsection Options
  7683. @table @option
  7684. @item input
  7685. Set path to the file used to read the transforms. Default value is
  7686. @file{transforms.trf}.
  7687. @item smoothing
  7688. Set the number of frames (value*2 + 1) used for lowpass filtering the
  7689. camera movements. Default value is 10.
  7690. For example a number of 10 means that 21 frames are used (10 in the
  7691. past and 10 in the future) to smoothen the motion in the video. A
  7692. larger value leads to a smoother video, but limits the acceleration of
  7693. the camera (pan/tilt movements). 0 is a special case where a static
  7694. camera is simulated.
  7695. @item optalgo
  7696. Set the camera path optimization algorithm.
  7697. Accepted values are:
  7698. @table @samp
  7699. @item gauss
  7700. gaussian kernel low-pass filter on camera motion (default)
  7701. @item avg
  7702. averaging on transformations
  7703. @end table
  7704. @item maxshift
  7705. Set maximal number of pixels to translate frames. Default value is -1,
  7706. meaning no limit.
  7707. @item maxangle
  7708. Set maximal angle in radians (degree*PI/180) to rotate frames. Default
  7709. value is -1, meaning no limit.
  7710. @item crop
  7711. Specify how to deal with borders that may be visible due to movement
  7712. compensation.
  7713. Available values are:
  7714. @table @samp
  7715. @item keep
  7716. keep image information from previous frame (default)
  7717. @item black
  7718. fill the border black
  7719. @end table
  7720. @item invert
  7721. Invert transforms if set to 1. Default value is 0.
  7722. @item relative
  7723. Consider transforms as relative to previous frame if set to 1,
  7724. absolute if set to 0. Default value is 0.
  7725. @item zoom
  7726. Set percentage to zoom. A positive value will result in a zoom-in
  7727. effect, a negative value in a zoom-out effect. Default value is 0 (no
  7728. zoom).
  7729. @item optzoom
  7730. Set optimal zooming to avoid borders.
  7731. Accepted values are:
  7732. @table @samp
  7733. @item 0
  7734. disabled
  7735. @item 1
  7736. optimal static zoom value is determined (only very strong movements
  7737. will lead to visible borders) (default)
  7738. @item 2
  7739. optimal adaptive zoom value is determined (no borders will be
  7740. visible), see @option{zoomspeed}
  7741. @end table
  7742. Note that the value given at zoom is added to the one calculated here.
  7743. @item zoomspeed
  7744. Set percent to zoom maximally each frame (enabled when
  7745. @option{optzoom} is set to 2). Range is from 0 to 5, default value is
  7746. 0.25.
  7747. @item interpol
  7748. Specify type of interpolation.
  7749. Available values are:
  7750. @table @samp
  7751. @item no
  7752. no interpolation
  7753. @item linear
  7754. linear only horizontal
  7755. @item bilinear
  7756. linear in both directions (default)
  7757. @item bicubic
  7758. cubic in both directions (slow)
  7759. @end table
  7760. @item tripod
  7761. Enable virtual tripod mode if set to 1, which is equivalent to
  7762. @code{relative=0:smoothing=0}. Default value is 0.
  7763. Use also @code{tripod} option of @ref{vidstabdetect}.
  7764. @item debug
  7765. Increase log verbosity if set to 1. Also the detected global motions
  7766. are written to the temporary file @file{global_motions.trf}. Default
  7767. value is 0.
  7768. @end table
  7769. @subsection Examples
  7770. @itemize
  7771. @item
  7772. Use @command{ffmpeg} for a typical stabilization with default values:
  7773. @example
  7774. ffmpeg -i inp.mpeg -vf vidstabtransform,unsharp=5:5:0.8:3:3:0.4 inp_stabilized.mpeg
  7775. @end example
  7776. Note the use of the @ref{unsharp} filter which is always recommended.
  7777. @item
  7778. Zoom in a bit more and load transform data from a given file:
  7779. @example
  7780. vidstabtransform=zoom=5:input="mytransforms.trf"
  7781. @end example
  7782. @item
  7783. Smoothen the video even more:
  7784. @example
  7785. vidstabtransform=smoothing=30
  7786. @end example
  7787. @end itemize
  7788. @section vflip
  7789. Flip the input video vertically.
  7790. For example, to vertically flip a video with @command{ffmpeg}:
  7791. @example
  7792. ffmpeg -i in.avi -vf "vflip" out.avi
  7793. @end example
  7794. @anchor{vignette}
  7795. @section vignette
  7796. Make or reverse a natural vignetting effect.
  7797. The filter accepts the following options:
  7798. @table @option
  7799. @item angle, a
  7800. Set lens angle expression as a number of radians.
  7801. The value is clipped in the @code{[0,PI/2]} range.
  7802. Default value: @code{"PI/5"}
  7803. @item x0
  7804. @item y0
  7805. Set center coordinates expressions. Respectively @code{"w/2"} and @code{"h/2"}
  7806. by default.
  7807. @item mode
  7808. Set forward/backward mode.
  7809. Available modes are:
  7810. @table @samp
  7811. @item forward
  7812. The larger the distance from the central point, the darker the image becomes.
  7813. @item backward
  7814. The larger the distance from the central point, the brighter the image becomes.
  7815. This can be used to reverse a vignette effect, though there is no automatic
  7816. detection to extract the lens @option{angle} and other settings (yet). It can
  7817. also be used to create a burning effect.
  7818. @end table
  7819. Default value is @samp{forward}.
  7820. @item eval
  7821. Set evaluation mode for the expressions (@option{angle}, @option{x0}, @option{y0}).
  7822. It accepts the following values:
  7823. @table @samp
  7824. @item init
  7825. Evaluate expressions only once during the filter initialization.
  7826. @item frame
  7827. Evaluate expressions for each incoming frame. This is way slower than the
  7828. @samp{init} mode since it requires all the scalers to be re-computed, but it
  7829. allows advanced dynamic expressions.
  7830. @end table
  7831. Default value is @samp{init}.
  7832. @item dither
  7833. Set dithering to reduce the circular banding effects. Default is @code{1}
  7834. (enabled).
  7835. @item aspect
  7836. Set vignette aspect. This setting allows one to adjust the shape of the vignette.
  7837. Setting this value to the SAR of the input will make a rectangular vignetting
  7838. following the dimensions of the video.
  7839. Default is @code{1/1}.
  7840. @end table
  7841. @subsection Expressions
  7842. The @option{alpha}, @option{x0} and @option{y0} expressions can contain the
  7843. following parameters.
  7844. @table @option
  7845. @item w
  7846. @item h
  7847. input width and height
  7848. @item n
  7849. the number of input frame, starting from 0
  7850. @item pts
  7851. the PTS (Presentation TimeStamp) time of the filtered video frame, expressed in
  7852. @var{TB} units, NAN if undefined
  7853. @item r
  7854. frame rate of the input video, NAN if the input frame rate is unknown
  7855. @item t
  7856. the PTS (Presentation TimeStamp) of the filtered video frame,
  7857. expressed in seconds, NAN if undefined
  7858. @item tb
  7859. time base of the input video
  7860. @end table
  7861. @subsection Examples
  7862. @itemize
  7863. @item
  7864. Apply simple strong vignetting effect:
  7865. @example
  7866. vignette=PI/4
  7867. @end example
  7868. @item
  7869. Make a flickering vignetting:
  7870. @example
  7871. vignette='PI/4+random(1)*PI/50':eval=frame
  7872. @end example
  7873. @end itemize
  7874. @section w3fdif
  7875. Deinterlace the input video ("w3fdif" stands for "Weston 3 Field
  7876. Deinterlacing Filter").
  7877. Based on the process described by Martin Weston for BBC R&D, and
  7878. implemented based on the de-interlace algorithm written by Jim
  7879. Easterbrook for BBC R&D, the Weston 3 field deinterlacing filter
  7880. uses filter coefficients calculated by BBC R&D.
  7881. There are two sets of filter coefficients, so called "simple":
  7882. and "complex". Which set of filter coefficients is used can
  7883. be set by passing an optional parameter:
  7884. @table @option
  7885. @item filter
  7886. Set the interlacing filter coefficients. Accepts one of the following values:
  7887. @table @samp
  7888. @item simple
  7889. Simple filter coefficient set.
  7890. @item complex
  7891. More-complex filter coefficient set.
  7892. @end table
  7893. Default value is @samp{complex}.
  7894. @item deint
  7895. Specify which frames to deinterlace. Accept one of the following values:
  7896. @table @samp
  7897. @item all
  7898. Deinterlace all frames,
  7899. @item interlaced
  7900. Only deinterlace frames marked as interlaced.
  7901. @end table
  7902. Default value is @samp{all}.
  7903. @end table
  7904. @section xbr
  7905. Apply the xBR high-quality magnification filter which is designed for pixel
  7906. art. It follows a set of edge-detection rules, see
  7907. @url{http://www.libretro.com/forums/viewtopic.php?f=6&t=134}.
  7908. It accepts the following option:
  7909. @table @option
  7910. @item n
  7911. Set the scaling dimension: @code{2} for @code{2xBR}, @code{3} for
  7912. @code{3xBR} and @code{4} for @code{4xBR}.
  7913. Default is @code{3}.
  7914. @end table
  7915. @anchor{yadif}
  7916. @section yadif
  7917. Deinterlace the input video ("yadif" means "yet another deinterlacing
  7918. filter").
  7919. It accepts the following parameters:
  7920. @table @option
  7921. @item mode
  7922. The interlacing mode to adopt. It accepts one of the following values:
  7923. @table @option
  7924. @item 0, send_frame
  7925. Output one frame for each frame.
  7926. @item 1, send_field
  7927. Output one frame for each field.
  7928. @item 2, send_frame_nospatial
  7929. Like @code{send_frame}, but it skips the spatial interlacing check.
  7930. @item 3, send_field_nospatial
  7931. Like @code{send_field}, but it skips the spatial interlacing check.
  7932. @end table
  7933. The default value is @code{send_frame}.
  7934. @item parity
  7935. The picture field parity assumed for the input interlaced video. It accepts one
  7936. of the following values:
  7937. @table @option
  7938. @item 0, tff
  7939. Assume the top field is first.
  7940. @item 1, bff
  7941. Assume the bottom field is first.
  7942. @item -1, auto
  7943. Enable automatic detection of field parity.
  7944. @end table
  7945. The default value is @code{auto}.
  7946. If the interlacing is unknown or the decoder does not export this information,
  7947. top field first will be assumed.
  7948. @item deint
  7949. Specify which frames to deinterlace. Accept one of the following
  7950. values:
  7951. @table @option
  7952. @item 0, all
  7953. Deinterlace all frames.
  7954. @item 1, interlaced
  7955. Only deinterlace frames marked as interlaced.
  7956. @end table
  7957. The default value is @code{all}.
  7958. @end table
  7959. @section zoompan
  7960. Apply Zoom & Pan effect.
  7961. This filter accepts the following options:
  7962. @table @option
  7963. @item zoom, z
  7964. Set the zoom expression. Default is 1.
  7965. @item x
  7966. @item y
  7967. Set the x and y expression. Default is 0.
  7968. @item d
  7969. Set the duration expression in number of frames.
  7970. This sets for how many number of frames effect will last for
  7971. single input image.
  7972. @item s
  7973. Set the output image size, default is 'hd720'.
  7974. @end table
  7975. Each expression can contain the following constants:
  7976. @table @option
  7977. @item in_w, iw
  7978. Input width.
  7979. @item in_h, ih
  7980. Input height.
  7981. @item out_w, ow
  7982. Output width.
  7983. @item out_h, oh
  7984. Output height.
  7985. @item in
  7986. Input frame count.
  7987. @item on
  7988. Output frame count.
  7989. @item x
  7990. @item y
  7991. Last calculated 'x' and 'y' position from 'x' and 'y' expression
  7992. for current input frame.
  7993. @item px
  7994. @item py
  7995. 'x' and 'y' of last output frame of previous input frame or 0 when there was
  7996. not yet such frame (first input frame).
  7997. @item zoom
  7998. Last calculated zoom from 'z' expression for current input frame.
  7999. @item pzoom
  8000. Last calculated zoom of last output frame of previous input frame.
  8001. @item duration
  8002. Number of output frames for current input frame. Calculated from 'd' expression
  8003. for each input frame.
  8004. @item pduration
  8005. number of output frames created for previous input frame
  8006. @item a
  8007. Rational number: input width / input height
  8008. @item sar
  8009. sample aspect ratio
  8010. @item dar
  8011. display aspect ratio
  8012. @end table
  8013. @subsection Examples
  8014. @itemize
  8015. @item
  8016. Zoom-in up to 1.5 and pan at same time to some spot near center of picture:
  8017. @example
  8018. zoompan=z='min(zoom+0.0015,1.5)':d=700:x='if(gte(zoom,1.5),x,x+1/a)':y='if(gte(zoom,1.5),y,y+1)':s=640x360
  8019. @end example
  8020. @item
  8021. Zoom-in up to 1.5 and pan always at center of picture:
  8022. @example
  8023. zoompan=z='min(zoom+0.0015,1.5)':d=700:x='iw/2-(iw/zoom/2)':y='ih/2-(ih/zoom/2)'
  8024. @end example
  8025. @end itemize
  8026. @c man end VIDEO FILTERS
  8027. @chapter Video Sources
  8028. @c man begin VIDEO SOURCES
  8029. Below is a description of the currently available video sources.
  8030. @section buffer
  8031. Buffer video frames, and make them available to the filter chain.
  8032. This source is mainly intended for a programmatic use, in particular
  8033. through the interface defined in @file{libavfilter/vsrc_buffer.h}.
  8034. It accepts the following parameters:
  8035. @table @option
  8036. @item video_size
  8037. Specify the size (width and height) of the buffered video frames. For the
  8038. syntax of this option, check the
  8039. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  8040. @item width
  8041. The input video width.
  8042. @item height
  8043. The input video height.
  8044. @item pix_fmt
  8045. A string representing the pixel format of the buffered video frames.
  8046. It may be a number corresponding to a pixel format, or a pixel format
  8047. name.
  8048. @item time_base
  8049. Specify the timebase assumed by the timestamps of the buffered frames.
  8050. @item frame_rate
  8051. Specify the frame rate expected for the video stream.
  8052. @item pixel_aspect, sar
  8053. The sample (pixel) aspect ratio of the input video.
  8054. @item sws_param
  8055. Specify the optional parameters to be used for the scale filter which
  8056. is automatically inserted when an input change is detected in the
  8057. input size or format.
  8058. @end table
  8059. For example:
  8060. @example
  8061. buffer=width=320:height=240:pix_fmt=yuv410p:time_base=1/24:sar=1
  8062. @end example
  8063. will instruct the source to accept video frames with size 320x240 and
  8064. with format "yuv410p", assuming 1/24 as the timestamps timebase and
  8065. square pixels (1:1 sample aspect ratio).
  8066. Since the pixel format with name "yuv410p" corresponds to the number 6
  8067. (check the enum AVPixelFormat definition in @file{libavutil/pixfmt.h}),
  8068. this example corresponds to:
  8069. @example
  8070. buffer=size=320x240:pixfmt=6:time_base=1/24:pixel_aspect=1/1
  8071. @end example
  8072. Alternatively, the options can be specified as a flat string, but this
  8073. syntax is deprecated:
  8074. @var{width}:@var{height}:@var{pix_fmt}:@var{time_base.num}:@var{time_base.den}:@var{pixel_aspect.num}:@var{pixel_aspect.den}[:@var{sws_param}]
  8075. @section cellauto
  8076. Create a pattern generated by an elementary cellular automaton.
  8077. The initial state of the cellular automaton can be defined through the
  8078. @option{filename}, and @option{pattern} options. If such options are
  8079. not specified an initial state is created randomly.
  8080. At each new frame a new row in the video is filled with the result of
  8081. the cellular automaton next generation. The behavior when the whole
  8082. frame is filled is defined by the @option{scroll} option.
  8083. This source accepts the following options:
  8084. @table @option
  8085. @item filename, f
  8086. Read the initial cellular automaton state, i.e. the starting row, from
  8087. the specified file.
  8088. In the file, each non-whitespace character is considered an alive
  8089. cell, a newline will terminate the row, and further characters in the
  8090. file will be ignored.
  8091. @item pattern, p
  8092. Read the initial cellular automaton state, i.e. the starting row, from
  8093. the specified string.
  8094. Each non-whitespace character in the string is considered an alive
  8095. cell, a newline will terminate the row, and further characters in the
  8096. string will be ignored.
  8097. @item rate, r
  8098. Set the video rate, that is the number of frames generated per second.
  8099. Default is 25.
  8100. @item random_fill_ratio, ratio
  8101. Set the random fill ratio for the initial cellular automaton row. It
  8102. is a floating point number value ranging from 0 to 1, defaults to
  8103. 1/PHI.
  8104. This option is ignored when a file or a pattern is specified.
  8105. @item random_seed, seed
  8106. Set the seed for filling randomly the initial row, must be an integer
  8107. included between 0 and UINT32_MAX. If not specified, or if explicitly
  8108. set to -1, the filter will try to use a good random seed on a best
  8109. effort basis.
  8110. @item rule
  8111. Set the cellular automaton rule, it is a number ranging from 0 to 255.
  8112. Default value is 110.
  8113. @item size, s
  8114. Set the size of the output video. For the syntax of this option, check the
  8115. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  8116. If @option{filename} or @option{pattern} is specified, the size is set
  8117. by default to the width of the specified initial state row, and the
  8118. height is set to @var{width} * PHI.
  8119. If @option{size} is set, it must contain the width of the specified
  8120. pattern string, and the specified pattern will be centered in the
  8121. larger row.
  8122. If a filename or a pattern string is not specified, the size value
  8123. defaults to "320x518" (used for a randomly generated initial state).
  8124. @item scroll
  8125. If set to 1, scroll the output upward when all the rows in the output
  8126. have been already filled. If set to 0, the new generated row will be
  8127. written over the top row just after the bottom row is filled.
  8128. Defaults to 1.
  8129. @item start_full, full
  8130. If set to 1, completely fill the output with generated rows before
  8131. outputting the first frame.
  8132. This is the default behavior, for disabling set the value to 0.
  8133. @item stitch
  8134. If set to 1, stitch the left and right row edges together.
  8135. This is the default behavior, for disabling set the value to 0.
  8136. @end table
  8137. @subsection Examples
  8138. @itemize
  8139. @item
  8140. Read the initial state from @file{pattern}, and specify an output of
  8141. size 200x400.
  8142. @example
  8143. cellauto=f=pattern:s=200x400
  8144. @end example
  8145. @item
  8146. Generate a random initial row with a width of 200 cells, with a fill
  8147. ratio of 2/3:
  8148. @example
  8149. cellauto=ratio=2/3:s=200x200
  8150. @end example
  8151. @item
  8152. Create a pattern generated by rule 18 starting by a single alive cell
  8153. centered on an initial row with width 100:
  8154. @example
  8155. cellauto=p=@@:s=100x400:full=0:rule=18
  8156. @end example
  8157. @item
  8158. Specify a more elaborated initial pattern:
  8159. @example
  8160. cellauto=p='@@@@ @@ @@@@':s=100x400:full=0:rule=18
  8161. @end example
  8162. @end itemize
  8163. @section mandelbrot
  8164. Generate a Mandelbrot set fractal, and progressively zoom towards the
  8165. point specified with @var{start_x} and @var{start_y}.
  8166. This source accepts the following options:
  8167. @table @option
  8168. @item end_pts
  8169. Set the terminal pts value. Default value is 400.
  8170. @item end_scale
  8171. Set the terminal scale value.
  8172. Must be a floating point value. Default value is 0.3.
  8173. @item inner
  8174. Set the inner coloring mode, that is the algorithm used to draw the
  8175. Mandelbrot fractal internal region.
  8176. It shall assume one of the following values:
  8177. @table @option
  8178. @item black
  8179. Set black mode.
  8180. @item convergence
  8181. Show time until convergence.
  8182. @item mincol
  8183. Set color based on point closest to the origin of the iterations.
  8184. @item period
  8185. Set period mode.
  8186. @end table
  8187. Default value is @var{mincol}.
  8188. @item bailout
  8189. Set the bailout value. Default value is 10.0.
  8190. @item maxiter
  8191. Set the maximum of iterations performed by the rendering
  8192. algorithm. Default value is 7189.
  8193. @item outer
  8194. Set outer coloring mode.
  8195. It shall assume one of following values:
  8196. @table @option
  8197. @item iteration_count
  8198. Set iteration cound mode.
  8199. @item normalized_iteration_count
  8200. set normalized iteration count mode.
  8201. @end table
  8202. Default value is @var{normalized_iteration_count}.
  8203. @item rate, r
  8204. Set frame rate, expressed as number of frames per second. Default
  8205. value is "25".
  8206. @item size, s
  8207. Set frame size. For the syntax of this option, check the "Video
  8208. size" section in the ffmpeg-utils manual. Default value is "640x480".
  8209. @item start_scale
  8210. Set the initial scale value. Default value is 3.0.
  8211. @item start_x
  8212. Set the initial x position. Must be a floating point value between
  8213. -100 and 100. Default value is -0.743643887037158704752191506114774.
  8214. @item start_y
  8215. Set the initial y position. Must be a floating point value between
  8216. -100 and 100. Default value is -0.131825904205311970493132056385139.
  8217. @end table
  8218. @section mptestsrc
  8219. Generate various test patterns, as generated by the MPlayer test filter.
  8220. The size of the generated video is fixed, and is 256x256.
  8221. This source is useful in particular for testing encoding features.
  8222. This source accepts the following options:
  8223. @table @option
  8224. @item rate, r
  8225. Specify the frame rate of the sourced video, as the number of frames
  8226. generated per second. It has to be a string in the format
  8227. @var{frame_rate_num}/@var{frame_rate_den}, an integer number, a floating point
  8228. number or a valid video frame rate abbreviation. The default value is
  8229. "25".
  8230. @item duration, d
  8231. Set the duration of the sourced video. See
  8232. @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}
  8233. for the accepted syntax.
  8234. If not specified, or the expressed duration is negative, the video is
  8235. supposed to be generated forever.
  8236. @item test, t
  8237. Set the number or the name of the test to perform. Supported tests are:
  8238. @table @option
  8239. @item dc_luma
  8240. @item dc_chroma
  8241. @item freq_luma
  8242. @item freq_chroma
  8243. @item amp_luma
  8244. @item amp_chroma
  8245. @item cbp
  8246. @item mv
  8247. @item ring1
  8248. @item ring2
  8249. @item all
  8250. @end table
  8251. Default value is "all", which will cycle through the list of all tests.
  8252. @end table
  8253. Some examples:
  8254. @example
  8255. mptestsrc=t=dc_luma
  8256. @end example
  8257. will generate a "dc_luma" test pattern.
  8258. @section frei0r_src
  8259. Provide a frei0r source.
  8260. To enable compilation of this filter you need to install the frei0r
  8261. header and configure FFmpeg with @code{--enable-frei0r}.
  8262. This source accepts the following parameters:
  8263. @table @option
  8264. @item size
  8265. The size of the video to generate. For the syntax of this option, check the
  8266. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  8267. @item framerate
  8268. The framerate of the generated video. It may be a string of the form
  8269. @var{num}/@var{den} or a frame rate abbreviation.
  8270. @item filter_name
  8271. The name to the frei0r source to load. For more information regarding frei0r and
  8272. how to set the parameters, read the @ref{frei0r} section in the video filters
  8273. documentation.
  8274. @item filter_params
  8275. A '|'-separated list of parameters to pass to the frei0r source.
  8276. @end table
  8277. For example, to generate a frei0r partik0l source with size 200x200
  8278. and frame rate 10 which is overlaid on the overlay filter main input:
  8279. @example
  8280. frei0r_src=size=200x200:framerate=10:filter_name=partik0l:filter_params=1234 [overlay]; [in][overlay] overlay
  8281. @end example
  8282. @section life
  8283. Generate a life pattern.
  8284. This source is based on a generalization of John Conway's life game.
  8285. The sourced input represents a life grid, each pixel represents a cell
  8286. which can be in one of two possible states, alive or dead. Every cell
  8287. interacts with its eight neighbours, which are the cells that are
  8288. horizontally, vertically, or diagonally adjacent.
  8289. At each interaction the grid evolves according to the adopted rule,
  8290. which specifies the number of neighbor alive cells which will make a
  8291. cell stay alive or born. The @option{rule} option allows one to specify
  8292. the rule to adopt.
  8293. This source accepts the following options:
  8294. @table @option
  8295. @item filename, f
  8296. Set the file from which to read the initial grid state. In the file,
  8297. each non-whitespace character is considered an alive cell, and newline
  8298. is used to delimit the end of each row.
  8299. If this option is not specified, the initial grid is generated
  8300. randomly.
  8301. @item rate, r
  8302. Set the video rate, that is the number of frames generated per second.
  8303. Default is 25.
  8304. @item random_fill_ratio, ratio
  8305. Set the random fill ratio for the initial random grid. It is a
  8306. floating point number value ranging from 0 to 1, defaults to 1/PHI.
  8307. It is ignored when a file is specified.
  8308. @item random_seed, seed
  8309. Set the seed for filling the initial random grid, must be an integer
  8310. included between 0 and UINT32_MAX. If not specified, or if explicitly
  8311. set to -1, the filter will try to use a good random seed on a best
  8312. effort basis.
  8313. @item rule
  8314. Set the life rule.
  8315. A rule can be specified with a code of the kind "S@var{NS}/B@var{NB}",
  8316. where @var{NS} and @var{NB} are sequences of numbers in the range 0-8,
  8317. @var{NS} specifies the number of alive neighbor cells which make a
  8318. live cell stay alive, and @var{NB} the number of alive neighbor cells
  8319. which make a dead cell to become alive (i.e. to "born").
  8320. "s" and "b" can be used in place of "S" and "B", respectively.
  8321. Alternatively a rule can be specified by an 18-bits integer. The 9
  8322. high order bits are used to encode the next cell state if it is alive
  8323. for each number of neighbor alive cells, the low order bits specify
  8324. the rule for "borning" new cells. Higher order bits encode for an
  8325. higher number of neighbor cells.
  8326. For example the number 6153 = @code{(12<<9)+9} specifies a stay alive
  8327. rule of 12 and a born rule of 9, which corresponds to "S23/B03".
  8328. Default value is "S23/B3", which is the original Conway's game of life
  8329. rule, and will keep a cell alive if it has 2 or 3 neighbor alive
  8330. cells, and will born a new cell if there are three alive cells around
  8331. a dead cell.
  8332. @item size, s
  8333. Set the size of the output video. For the syntax of this option, check the
  8334. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  8335. If @option{filename} is specified, the size is set by default to the
  8336. same size of the input file. If @option{size} is set, it must contain
  8337. the size specified in the input file, and the initial grid defined in
  8338. that file is centered in the larger resulting area.
  8339. If a filename is not specified, the size value defaults to "320x240"
  8340. (used for a randomly generated initial grid).
  8341. @item stitch
  8342. If set to 1, stitch the left and right grid edges together, and the
  8343. top and bottom edges also. Defaults to 1.
  8344. @item mold
  8345. Set cell mold speed. If set, a dead cell will go from @option{death_color} to
  8346. @option{mold_color} with a step of @option{mold}. @option{mold} can have a
  8347. value from 0 to 255.
  8348. @item life_color
  8349. Set the color of living (or new born) cells.
  8350. @item death_color
  8351. Set the color of dead cells. If @option{mold} is set, this is the first color
  8352. used to represent a dead cell.
  8353. @item mold_color
  8354. Set mold color, for definitely dead and moldy cells.
  8355. For the syntax of these 3 color options, check the "Color" section in the
  8356. ffmpeg-utils manual.
  8357. @end table
  8358. @subsection Examples
  8359. @itemize
  8360. @item
  8361. Read a grid from @file{pattern}, and center it on a grid of size
  8362. 300x300 pixels:
  8363. @example
  8364. life=f=pattern:s=300x300
  8365. @end example
  8366. @item
  8367. Generate a random grid of size 200x200, with a fill ratio of 2/3:
  8368. @example
  8369. life=ratio=2/3:s=200x200
  8370. @end example
  8371. @item
  8372. Specify a custom rule for evolving a randomly generated grid:
  8373. @example
  8374. life=rule=S14/B34
  8375. @end example
  8376. @item
  8377. Full example with slow death effect (mold) using @command{ffplay}:
  8378. @example
  8379. ffplay -f lavfi life=s=300x200:mold=10:r=60:ratio=0.1:death_color=#C83232:life_color=#00ff00,scale=1200:800:flags=16
  8380. @end example
  8381. @end itemize
  8382. @anchor{color}
  8383. @anchor{haldclutsrc}
  8384. @anchor{nullsrc}
  8385. @anchor{rgbtestsrc}
  8386. @anchor{smptebars}
  8387. @anchor{smptehdbars}
  8388. @anchor{testsrc}
  8389. @section color, haldclutsrc, nullsrc, rgbtestsrc, smptebars, smptehdbars, testsrc
  8390. The @code{color} source provides an uniformly colored input.
  8391. The @code{haldclutsrc} source provides an identity Hald CLUT. See also
  8392. @ref{haldclut} filter.
  8393. The @code{nullsrc} source returns unprocessed video frames. It is
  8394. mainly useful to be employed in analysis / debugging tools, or as the
  8395. source for filters which ignore the input data.
  8396. The @code{rgbtestsrc} source generates an RGB test pattern useful for
  8397. detecting RGB vs BGR issues. You should see a red, green and blue
  8398. stripe from top to bottom.
  8399. The @code{smptebars} source generates a color bars pattern, based on
  8400. the SMPTE Engineering Guideline EG 1-1990.
  8401. The @code{smptehdbars} source generates a color bars pattern, based on
  8402. the SMPTE RP 219-2002.
  8403. The @code{testsrc} source generates a test video pattern, showing a
  8404. color pattern, a scrolling gradient and a timestamp. This is mainly
  8405. intended for testing purposes.
  8406. The sources accept the following parameters:
  8407. @table @option
  8408. @item color, c
  8409. Specify the color of the source, only available in the @code{color}
  8410. source. For the syntax of this option, check the "Color" section in the
  8411. ffmpeg-utils manual.
  8412. @item level
  8413. Specify the level of the Hald CLUT, only available in the @code{haldclutsrc}
  8414. source. A level of @code{N} generates a picture of @code{N*N*N} by @code{N*N*N}
  8415. pixels to be used as identity matrix for 3D lookup tables. Each component is
  8416. coded on a @code{1/(N*N)} scale.
  8417. @item size, s
  8418. Specify the size of the sourced video. For the syntax of this option, check the
  8419. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  8420. The default value is @code{320x240}.
  8421. This option is not available with the @code{haldclutsrc} filter.
  8422. @item rate, r
  8423. Specify the frame rate of the sourced video, as the number of frames
  8424. generated per second. It has to be a string in the format
  8425. @var{frame_rate_num}/@var{frame_rate_den}, an integer number, a floating point
  8426. number or a valid video frame rate abbreviation. The default value is
  8427. "25".
  8428. @item sar
  8429. Set the sample aspect ratio of the sourced video.
  8430. @item duration, d
  8431. Set the duration of the sourced video. See
  8432. @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}
  8433. for the accepted syntax.
  8434. If not specified, or the expressed duration is negative, the video is
  8435. supposed to be generated forever.
  8436. @item decimals, n
  8437. Set the number of decimals to show in the timestamp, only available in the
  8438. @code{testsrc} source.
  8439. The displayed timestamp value will correspond to the original
  8440. timestamp value multiplied by the power of 10 of the specified
  8441. value. Default value is 0.
  8442. @end table
  8443. For example the following:
  8444. @example
  8445. testsrc=duration=5.3:size=qcif:rate=10
  8446. @end example
  8447. will generate a video with a duration of 5.3 seconds, with size
  8448. 176x144 and a frame rate of 10 frames per second.
  8449. The following graph description will generate a red source
  8450. with an opacity of 0.2, with size "qcif" and a frame rate of 10
  8451. frames per second.
  8452. @example
  8453. color=c=red@@0.2:s=qcif:r=10
  8454. @end example
  8455. If the input content is to be ignored, @code{nullsrc} can be used. The
  8456. following command generates noise in the luminance plane by employing
  8457. the @code{geq} filter:
  8458. @example
  8459. nullsrc=s=256x256, geq=random(1)*255:128:128
  8460. @end example
  8461. @subsection Commands
  8462. The @code{color} source supports the following commands:
  8463. @table @option
  8464. @item c, color
  8465. Set the color of the created image. Accepts the same syntax of the
  8466. corresponding @option{color} option.
  8467. @end table
  8468. @c man end VIDEO SOURCES
  8469. @chapter Video Sinks
  8470. @c man begin VIDEO SINKS
  8471. Below is a description of the currently available video sinks.
  8472. @section buffersink
  8473. Buffer video frames, and make them available to the end of the filter
  8474. graph.
  8475. This sink is mainly intended for programmatic use, in particular
  8476. through the interface defined in @file{libavfilter/buffersink.h}
  8477. or the options system.
  8478. It accepts a pointer to an AVBufferSinkContext structure, which
  8479. defines the incoming buffers' formats, to be passed as the opaque
  8480. parameter to @code{avfilter_init_filter} for initialization.
  8481. @section nullsink
  8482. Null video sink: do absolutely nothing with the input video. It is
  8483. mainly useful as a template and for use in analysis / debugging
  8484. tools.
  8485. @c man end VIDEO SINKS
  8486. @chapter Multimedia Filters
  8487. @c man begin MULTIMEDIA FILTERS
  8488. Below is a description of the currently available multimedia filters.
  8489. @section avectorscope
  8490. Convert input audio to a video output, representing the audio vector
  8491. scope.
  8492. The filter is used to measure the difference between channels of stereo
  8493. audio stream. A monoaural signal, consisting of identical left and right
  8494. signal, results in straight vertical line. Any stereo separation is visible
  8495. as a deviation from this line, creating a Lissajous figure.
  8496. If the straight (or deviation from it) but horizontal line appears this
  8497. indicates that the left and right channels are out of phase.
  8498. The filter accepts the following options:
  8499. @table @option
  8500. @item mode, m
  8501. Set the vectorscope mode.
  8502. Available values are:
  8503. @table @samp
  8504. @item lissajous
  8505. Lissajous rotated by 45 degrees.
  8506. @item lissajous_xy
  8507. Same as above but not rotated.
  8508. @end table
  8509. Default value is @samp{lissajous}.
  8510. @item size, s
  8511. Set the video size for the output. For the syntax of this option, check the
  8512. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  8513. Default value is @code{400x400}.
  8514. @item rate, r
  8515. Set the output frame rate. Default value is @code{25}.
  8516. @item rc
  8517. @item gc
  8518. @item bc
  8519. Specify the red, green and blue contrast. Default values are @code{40}, @code{160} and @code{80}.
  8520. Allowed range is @code{[0, 255]}.
  8521. @item rf
  8522. @item gf
  8523. @item bf
  8524. Specify the red, green and blue fade. Default values are @code{15}, @code{10} and @code{5}.
  8525. Allowed range is @code{[0, 255]}.
  8526. @item zoom
  8527. Set the zoom factor. Default value is @code{1}. Allowed range is @code{[1, 10]}.
  8528. @end table
  8529. @subsection Examples
  8530. @itemize
  8531. @item
  8532. Complete example using @command{ffplay}:
  8533. @example
  8534. ffplay -f lavfi 'amovie=input.mp3, asplit [a][out1];
  8535. [a] avectorscope=zoom=1.3:rc=2:gc=200:bc=10:rf=1:gf=8:bf=7 [out0]'
  8536. @end example
  8537. @end itemize
  8538. @section concat
  8539. Concatenate audio and video streams, joining them together one after the
  8540. other.
  8541. The filter works on segments of synchronized video and audio streams. All
  8542. segments must have the same number of streams of each type, and that will
  8543. also be the number of streams at output.
  8544. The filter accepts the following options:
  8545. @table @option
  8546. @item n
  8547. Set the number of segments. Default is 2.
  8548. @item v
  8549. Set the number of output video streams, that is also the number of video
  8550. streams in each segment. Default is 1.
  8551. @item a
  8552. Set the number of output audio streams, that is also the number of audio
  8553. streams in each segment. Default is 0.
  8554. @item unsafe
  8555. Activate unsafe mode: do not fail if segments have a different format.
  8556. @end table
  8557. The filter has @var{v}+@var{a} outputs: first @var{v} video outputs, then
  8558. @var{a} audio outputs.
  8559. There are @var{n}x(@var{v}+@var{a}) inputs: first the inputs for the first
  8560. segment, in the same order as the outputs, then the inputs for the second
  8561. segment, etc.
  8562. Related streams do not always have exactly the same duration, for various
  8563. reasons including codec frame size or sloppy authoring. For that reason,
  8564. related synchronized streams (e.g. a video and its audio track) should be
  8565. concatenated at once. The concat filter will use the duration of the longest
  8566. stream in each segment (except the last one), and if necessary pad shorter
  8567. audio streams with silence.
  8568. For this filter to work correctly, all segments must start at timestamp 0.
  8569. All corresponding streams must have the same parameters in all segments; the
  8570. filtering system will automatically select a common pixel format for video
  8571. streams, and a common sample format, sample rate and channel layout for
  8572. audio streams, but other settings, such as resolution, must be converted
  8573. explicitly by the user.
  8574. Different frame rates are acceptable but will result in variable frame rate
  8575. at output; be sure to configure the output file to handle it.
  8576. @subsection Examples
  8577. @itemize
  8578. @item
  8579. Concatenate an opening, an episode and an ending, all in bilingual version
  8580. (video in stream 0, audio in streams 1 and 2):
  8581. @example
  8582. ffmpeg -i opening.mkv -i episode.mkv -i ending.mkv -filter_complex \
  8583. '[0:0] [0:1] [0:2] [1:0] [1:1] [1:2] [2:0] [2:1] [2:2]
  8584. concat=n=3:v=1:a=2 [v] [a1] [a2]' \
  8585. -map '[v]' -map '[a1]' -map '[a2]' output.mkv
  8586. @end example
  8587. @item
  8588. Concatenate two parts, handling audio and video separately, using the
  8589. (a)movie sources, and adjusting the resolution:
  8590. @example
  8591. movie=part1.mp4, scale=512:288 [v1] ; amovie=part1.mp4 [a1] ;
  8592. movie=part2.mp4, scale=512:288 [v2] ; amovie=part2.mp4 [a2] ;
  8593. [v1] [v2] concat [outv] ; [a1] [a2] concat=v=0:a=1 [outa]
  8594. @end example
  8595. Note that a desync will happen at the stitch if the audio and video streams
  8596. do not have exactly the same duration in the first file.
  8597. @end itemize
  8598. @anchor{ebur128}
  8599. @section ebur128
  8600. EBU R128 scanner filter. This filter takes an audio stream as input and outputs
  8601. it unchanged. By default, it logs a message at a frequency of 10Hz with the
  8602. Momentary loudness (identified by @code{M}), Short-term loudness (@code{S}),
  8603. Integrated loudness (@code{I}) and Loudness Range (@code{LRA}).
  8604. The filter also has a video output (see the @var{video} option) with a real
  8605. time graph to observe the loudness evolution. The graphic contains the logged
  8606. message mentioned above, so it is not printed anymore when this option is set,
  8607. unless the verbose logging is set. The main graphing area contains the
  8608. short-term loudness (3 seconds of analysis), and the gauge on the right is for
  8609. the momentary loudness (400 milliseconds).
  8610. More information about the Loudness Recommendation EBU R128 on
  8611. @url{http://tech.ebu.ch/loudness}.
  8612. The filter accepts the following options:
  8613. @table @option
  8614. @item video
  8615. Activate the video output. The audio stream is passed unchanged whether this
  8616. option is set or no. The video stream will be the first output stream if
  8617. activated. Default is @code{0}.
  8618. @item size
  8619. Set the video size. This option is for video only. For the syntax of this
  8620. option, check the
  8621. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  8622. Default and minimum resolution is @code{640x480}.
  8623. @item meter
  8624. Set the EBU scale meter. Default is @code{9}. Common values are @code{9} and
  8625. @code{18}, respectively for EBU scale meter +9 and EBU scale meter +18. Any
  8626. other integer value between this range is allowed.
  8627. @item metadata
  8628. Set metadata injection. If set to @code{1}, the audio input will be segmented
  8629. into 100ms output frames, each of them containing various loudness information
  8630. in metadata. All the metadata keys are prefixed with @code{lavfi.r128.}.
  8631. Default is @code{0}.
  8632. @item framelog
  8633. Force the frame logging level.
  8634. Available values are:
  8635. @table @samp
  8636. @item info
  8637. information logging level
  8638. @item verbose
  8639. verbose logging level
  8640. @end table
  8641. By default, the logging level is set to @var{info}. If the @option{video} or
  8642. the @option{metadata} options are set, it switches to @var{verbose}.
  8643. @item peak
  8644. Set peak mode(s).
  8645. Available modes can be cumulated (the option is a @code{flag} type). Possible
  8646. values are:
  8647. @table @samp
  8648. @item none
  8649. Disable any peak mode (default).
  8650. @item sample
  8651. Enable sample-peak mode.
  8652. Simple peak mode looking for the higher sample value. It logs a message
  8653. for sample-peak (identified by @code{SPK}).
  8654. @item true
  8655. Enable true-peak mode.
  8656. If enabled, the peak lookup is done on an over-sampled version of the input
  8657. stream for better peak accuracy. It logs a message for true-peak.
  8658. (identified by @code{TPK}) and true-peak per frame (identified by @code{FTPK}).
  8659. This mode requires a build with @code{libswresample}.
  8660. @end table
  8661. @end table
  8662. @subsection Examples
  8663. @itemize
  8664. @item
  8665. Real-time graph using @command{ffplay}, with a EBU scale meter +18:
  8666. @example
  8667. ffplay -f lavfi -i "amovie=input.mp3,ebur128=video=1:meter=18 [out0][out1]"
  8668. @end example
  8669. @item
  8670. Run an analysis with @command{ffmpeg}:
  8671. @example
  8672. ffmpeg -nostats -i input.mp3 -filter_complex ebur128 -f null -
  8673. @end example
  8674. @end itemize
  8675. @section interleave, ainterleave
  8676. Temporally interleave frames from several inputs.
  8677. @code{interleave} works with video inputs, @code{ainterleave} with audio.
  8678. These filters read frames from several inputs and send the oldest
  8679. queued frame to the output.
  8680. Input streams must have a well defined, monotonically increasing frame
  8681. timestamp values.
  8682. In order to submit one frame to output, these filters need to enqueue
  8683. at least one frame for each input, so they cannot work in case one
  8684. input is not yet terminated and will not receive incoming frames.
  8685. For example consider the case when one input is a @code{select} filter
  8686. which always drop input frames. The @code{interleave} filter will keep
  8687. reading from that input, but it will never be able to send new frames
  8688. to output until the input will send an end-of-stream signal.
  8689. Also, depending on inputs synchronization, the filters will drop
  8690. frames in case one input receives more frames than the other ones, and
  8691. the queue is already filled.
  8692. These filters accept the following options:
  8693. @table @option
  8694. @item nb_inputs, n
  8695. Set the number of different inputs, it is 2 by default.
  8696. @end table
  8697. @subsection Examples
  8698. @itemize
  8699. @item
  8700. Interleave frames belonging to different streams using @command{ffmpeg}:
  8701. @example
  8702. ffmpeg -i bambi.avi -i pr0n.mkv -filter_complex "[0:v][1:v] interleave" out.avi
  8703. @end example
  8704. @item
  8705. Add flickering blur effect:
  8706. @example
  8707. select='if(gt(random(0), 0.2), 1, 2)':n=2 [tmp], boxblur=2:2, [tmp] interleave
  8708. @end example
  8709. @end itemize
  8710. @section perms, aperms
  8711. Set read/write permissions for the output frames.
  8712. These filters are mainly aimed at developers to test direct path in the
  8713. following filter in the filtergraph.
  8714. The filters accept the following options:
  8715. @table @option
  8716. @item mode
  8717. Select the permissions mode.
  8718. It accepts the following values:
  8719. @table @samp
  8720. @item none
  8721. Do nothing. This is the default.
  8722. @item ro
  8723. Set all the output frames read-only.
  8724. @item rw
  8725. Set all the output frames directly writable.
  8726. @item toggle
  8727. Make the frame read-only if writable, and writable if read-only.
  8728. @item random
  8729. Set each output frame read-only or writable randomly.
  8730. @end table
  8731. @item seed
  8732. Set the seed for the @var{random} mode, must be an integer included between
  8733. @code{0} and @code{UINT32_MAX}. If not specified, or if explicitly set to
  8734. @code{-1}, the filter will try to use a good random seed on a best effort
  8735. basis.
  8736. @end table
  8737. Note: in case of auto-inserted filter between the permission filter and the
  8738. following one, the permission might not be received as expected in that
  8739. following filter. Inserting a @ref{format} or @ref{aformat} filter before the
  8740. perms/aperms filter can avoid this problem.
  8741. @section select, aselect
  8742. Select frames to pass in output.
  8743. This filter accepts the following options:
  8744. @table @option
  8745. @item expr, e
  8746. Set expression, which is evaluated for each input frame.
  8747. If the expression is evaluated to zero, the frame is discarded.
  8748. If the evaluation result is negative or NaN, the frame is sent to the
  8749. first output; otherwise it is sent to the output with index
  8750. @code{ceil(val)-1}, assuming that the input index starts from 0.
  8751. For example a value of @code{1.2} corresponds to the output with index
  8752. @code{ceil(1.2)-1 = 2-1 = 1}, that is the second output.
  8753. @item outputs, n
  8754. Set the number of outputs. The output to which to send the selected
  8755. frame is based on the result of the evaluation. Default value is 1.
  8756. @end table
  8757. The expression can contain the following constants:
  8758. @table @option
  8759. @item n
  8760. The (sequential) number of the filtered frame, starting from 0.
  8761. @item selected_n
  8762. The (sequential) number of the selected frame, starting from 0.
  8763. @item prev_selected_n
  8764. The sequential number of the last selected frame. It's NAN if undefined.
  8765. @item TB
  8766. The timebase of the input timestamps.
  8767. @item pts
  8768. The PTS (Presentation TimeStamp) of the filtered video frame,
  8769. expressed in @var{TB} units. It's NAN if undefined.
  8770. @item t
  8771. The PTS of the filtered video frame,
  8772. expressed in seconds. It's NAN if undefined.
  8773. @item prev_pts
  8774. The PTS of the previously filtered video frame. It's NAN if undefined.
  8775. @item prev_selected_pts
  8776. The PTS of the last previously filtered video frame. It's NAN if undefined.
  8777. @item prev_selected_t
  8778. The PTS of the last previously selected video frame. It's NAN if undefined.
  8779. @item start_pts
  8780. The PTS of the first video frame in the video. It's NAN if undefined.
  8781. @item start_t
  8782. The time of the first video frame in the video. It's NAN if undefined.
  8783. @item pict_type @emph{(video only)}
  8784. The type of the filtered frame. It can assume one of the following
  8785. values:
  8786. @table @option
  8787. @item I
  8788. @item P
  8789. @item B
  8790. @item S
  8791. @item SI
  8792. @item SP
  8793. @item BI
  8794. @end table
  8795. @item interlace_type @emph{(video only)}
  8796. The frame interlace type. It can assume one of the following values:
  8797. @table @option
  8798. @item PROGRESSIVE
  8799. The frame is progressive (not interlaced).
  8800. @item TOPFIRST
  8801. The frame is top-field-first.
  8802. @item BOTTOMFIRST
  8803. The frame is bottom-field-first.
  8804. @end table
  8805. @item consumed_sample_n @emph{(audio only)}
  8806. the number of selected samples before the current frame
  8807. @item samples_n @emph{(audio only)}
  8808. the number of samples in the current frame
  8809. @item sample_rate @emph{(audio only)}
  8810. the input sample rate
  8811. @item key
  8812. This is 1 if the filtered frame is a key-frame, 0 otherwise.
  8813. @item pos
  8814. the position in the file of the filtered frame, -1 if the information
  8815. is not available (e.g. for synthetic video)
  8816. @item scene @emph{(video only)}
  8817. value between 0 and 1 to indicate a new scene; a low value reflects a low
  8818. probability for the current frame to introduce a new scene, while a higher
  8819. value means the current frame is more likely to be one (see the example below)
  8820. @end table
  8821. The default value of the select expression is "1".
  8822. @subsection Examples
  8823. @itemize
  8824. @item
  8825. Select all frames in input:
  8826. @example
  8827. select
  8828. @end example
  8829. The example above is the same as:
  8830. @example
  8831. select=1
  8832. @end example
  8833. @item
  8834. Skip all frames:
  8835. @example
  8836. select=0
  8837. @end example
  8838. @item
  8839. Select only I-frames:
  8840. @example
  8841. select='eq(pict_type\,I)'
  8842. @end example
  8843. @item
  8844. Select one frame every 100:
  8845. @example
  8846. select='not(mod(n\,100))'
  8847. @end example
  8848. @item
  8849. Select only frames contained in the 10-20 time interval:
  8850. @example
  8851. select=between(t\,10\,20)
  8852. @end example
  8853. @item
  8854. Select only I frames contained in the 10-20 time interval:
  8855. @example
  8856. select=between(t\,10\,20)*eq(pict_type\,I)
  8857. @end example
  8858. @item
  8859. Select frames with a minimum distance of 10 seconds:
  8860. @example
  8861. select='isnan(prev_selected_t)+gte(t-prev_selected_t\,10)'
  8862. @end example
  8863. @item
  8864. Use aselect to select only audio frames with samples number > 100:
  8865. @example
  8866. aselect='gt(samples_n\,100)'
  8867. @end example
  8868. @item
  8869. Create a mosaic of the first scenes:
  8870. @example
  8871. ffmpeg -i video.avi -vf select='gt(scene\,0.4)',scale=160:120,tile -frames:v 1 preview.png
  8872. @end example
  8873. Comparing @var{scene} against a value between 0.3 and 0.5 is generally a sane
  8874. choice.
  8875. @item
  8876. Send even and odd frames to separate outputs, and compose them:
  8877. @example
  8878. select=n=2:e='mod(n, 2)+1' [odd][even]; [odd] pad=h=2*ih [tmp]; [tmp][even] overlay=y=h
  8879. @end example
  8880. @end itemize
  8881. @section sendcmd, asendcmd
  8882. Send commands to filters in the filtergraph.
  8883. These filters read commands to be sent to other filters in the
  8884. filtergraph.
  8885. @code{sendcmd} must be inserted between two video filters,
  8886. @code{asendcmd} must be inserted between two audio filters, but apart
  8887. from that they act the same way.
  8888. The specification of commands can be provided in the filter arguments
  8889. with the @var{commands} option, or in a file specified by the
  8890. @var{filename} option.
  8891. These filters accept the following options:
  8892. @table @option
  8893. @item commands, c
  8894. Set the commands to be read and sent to the other filters.
  8895. @item filename, f
  8896. Set the filename of the commands to be read and sent to the other
  8897. filters.
  8898. @end table
  8899. @subsection Commands syntax
  8900. A commands description consists of a sequence of interval
  8901. specifications, comprising a list of commands to be executed when a
  8902. particular event related to that interval occurs. The occurring event
  8903. is typically the current frame time entering or leaving a given time
  8904. interval.
  8905. An interval is specified by the following syntax:
  8906. @example
  8907. @var{START}[-@var{END}] @var{COMMANDS};
  8908. @end example
  8909. The time interval is specified by the @var{START} and @var{END} times.
  8910. @var{END} is optional and defaults to the maximum time.
  8911. The current frame time is considered within the specified interval if
  8912. it is included in the interval [@var{START}, @var{END}), that is when
  8913. the time is greater or equal to @var{START} and is lesser than
  8914. @var{END}.
  8915. @var{COMMANDS} consists of a sequence of one or more command
  8916. specifications, separated by ",", relating to that interval. The
  8917. syntax of a command specification is given by:
  8918. @example
  8919. [@var{FLAGS}] @var{TARGET} @var{COMMAND} @var{ARG}
  8920. @end example
  8921. @var{FLAGS} is optional and specifies the type of events relating to
  8922. the time interval which enable sending the specified command, and must
  8923. be a non-null sequence of identifier flags separated by "+" or "|" and
  8924. enclosed between "[" and "]".
  8925. The following flags are recognized:
  8926. @table @option
  8927. @item enter
  8928. The command is sent when the current frame timestamp enters the
  8929. specified interval. In other words, the command is sent when the
  8930. previous frame timestamp was not in the given interval, and the
  8931. current is.
  8932. @item leave
  8933. The command is sent when the current frame timestamp leaves the
  8934. specified interval. In other words, the command is sent when the
  8935. previous frame timestamp was in the given interval, and the
  8936. current is not.
  8937. @end table
  8938. If @var{FLAGS} is not specified, a default value of @code{[enter]} is
  8939. assumed.
  8940. @var{TARGET} specifies the target of the command, usually the name of
  8941. the filter class or a specific filter instance name.
  8942. @var{COMMAND} specifies the name of the command for the target filter.
  8943. @var{ARG} is optional and specifies the optional list of argument for
  8944. the given @var{COMMAND}.
  8945. Between one interval specification and another, whitespaces, or
  8946. sequences of characters starting with @code{#} until the end of line,
  8947. are ignored and can be used to annotate comments.
  8948. A simplified BNF description of the commands specification syntax
  8949. follows:
  8950. @example
  8951. @var{COMMAND_FLAG} ::= "enter" | "leave"
  8952. @var{COMMAND_FLAGS} ::= @var{COMMAND_FLAG} [(+|"|")@var{COMMAND_FLAG}]
  8953. @var{COMMAND} ::= ["[" @var{COMMAND_FLAGS} "]"] @var{TARGET} @var{COMMAND} [@var{ARG}]
  8954. @var{COMMANDS} ::= @var{COMMAND} [,@var{COMMANDS}]
  8955. @var{INTERVAL} ::= @var{START}[-@var{END}] @var{COMMANDS}
  8956. @var{INTERVALS} ::= @var{INTERVAL}[;@var{INTERVALS}]
  8957. @end example
  8958. @subsection Examples
  8959. @itemize
  8960. @item
  8961. Specify audio tempo change at second 4:
  8962. @example
  8963. asendcmd=c='4.0 atempo tempo 1.5',atempo
  8964. @end example
  8965. @item
  8966. Specify a list of drawtext and hue commands in a file.
  8967. @example
  8968. # show text in the interval 5-10
  8969. 5.0-10.0 [enter] drawtext reinit 'fontfile=FreeSerif.ttf:text=hello world',
  8970. [leave] drawtext reinit 'fontfile=FreeSerif.ttf:text=';
  8971. # desaturate the image in the interval 15-20
  8972. 15.0-20.0 [enter] hue s 0,
  8973. [enter] drawtext reinit 'fontfile=FreeSerif.ttf:text=nocolor',
  8974. [leave] hue s 1,
  8975. [leave] drawtext reinit 'fontfile=FreeSerif.ttf:text=color';
  8976. # apply an exponential saturation fade-out effect, starting from time 25
  8977. 25 [enter] hue s exp(25-t)
  8978. @end example
  8979. A filtergraph allowing to read and process the above command list
  8980. stored in a file @file{test.cmd}, can be specified with:
  8981. @example
  8982. sendcmd=f=test.cmd,drawtext=fontfile=FreeSerif.ttf:text='',hue
  8983. @end example
  8984. @end itemize
  8985. @anchor{setpts}
  8986. @section setpts, asetpts
  8987. Change the PTS (presentation timestamp) of the input frames.
  8988. @code{setpts} works on video frames, @code{asetpts} on audio frames.
  8989. This filter accepts the following options:
  8990. @table @option
  8991. @item expr
  8992. The expression which is evaluated for each frame to construct its timestamp.
  8993. @end table
  8994. The expression is evaluated through the eval API and can contain the following
  8995. constants:
  8996. @table @option
  8997. @item FRAME_RATE
  8998. frame rate, only defined for constant frame-rate video
  8999. @item PTS
  9000. The presentation timestamp in input
  9001. @item N
  9002. The count of the input frame for video or the number of consumed samples,
  9003. not including the current frame for audio, starting from 0.
  9004. @item NB_CONSUMED_SAMPLES
  9005. The number of consumed samples, not including the current frame (only
  9006. audio)
  9007. @item NB_SAMPLES, S
  9008. The number of samples in the current frame (only audio)
  9009. @item SAMPLE_RATE, SR
  9010. The audio sample rate.
  9011. @item STARTPTS
  9012. The PTS of the first frame.
  9013. @item STARTT
  9014. the time in seconds of the first frame
  9015. @item INTERLACED
  9016. State whether the current frame is interlaced.
  9017. @item T
  9018. the time in seconds of the current frame
  9019. @item POS
  9020. original position in the file of the frame, or undefined if undefined
  9021. for the current frame
  9022. @item PREV_INPTS
  9023. The previous input PTS.
  9024. @item PREV_INT
  9025. previous input time in seconds
  9026. @item PREV_OUTPTS
  9027. The previous output PTS.
  9028. @item PREV_OUTT
  9029. previous output time in seconds
  9030. @item RTCTIME
  9031. The wallclock (RTC) time in microseconds. This is deprecated, use time(0)
  9032. instead.
  9033. @item RTCSTART
  9034. The wallclock (RTC) time at the start of the movie in microseconds.
  9035. @item TB
  9036. The timebase of the input timestamps.
  9037. @end table
  9038. @subsection Examples
  9039. @itemize
  9040. @item
  9041. Start counting PTS from zero
  9042. @example
  9043. setpts=PTS-STARTPTS
  9044. @end example
  9045. @item
  9046. Apply fast motion effect:
  9047. @example
  9048. setpts=0.5*PTS
  9049. @end example
  9050. @item
  9051. Apply slow motion effect:
  9052. @example
  9053. setpts=2.0*PTS
  9054. @end example
  9055. @item
  9056. Set fixed rate of 25 frames per second:
  9057. @example
  9058. setpts=N/(25*TB)
  9059. @end example
  9060. @item
  9061. Set fixed rate 25 fps with some jitter:
  9062. @example
  9063. setpts='1/(25*TB) * (N + 0.05 * sin(N*2*PI/25))'
  9064. @end example
  9065. @item
  9066. Apply an offset of 10 seconds to the input PTS:
  9067. @example
  9068. setpts=PTS+10/TB
  9069. @end example
  9070. @item
  9071. Generate timestamps from a "live source" and rebase onto the current timebase:
  9072. @example
  9073. setpts='(RTCTIME - RTCSTART) / (TB * 1000000)'
  9074. @end example
  9075. @item
  9076. Generate timestamps by counting samples:
  9077. @example
  9078. asetpts=N/SR/TB
  9079. @end example
  9080. @end itemize
  9081. @section settb, asettb
  9082. Set the timebase to use for the output frames timestamps.
  9083. It is mainly useful for testing timebase configuration.
  9084. It accepts the following parameters:
  9085. @table @option
  9086. @item expr, tb
  9087. The expression which is evaluated into the output timebase.
  9088. @end table
  9089. The value for @option{tb} is an arithmetic expression representing a
  9090. rational. The expression can contain the constants "AVTB" (the default
  9091. timebase), "intb" (the input timebase) and "sr" (the sample rate,
  9092. audio only). Default value is "intb".
  9093. @subsection Examples
  9094. @itemize
  9095. @item
  9096. Set the timebase to 1/25:
  9097. @example
  9098. settb=expr=1/25
  9099. @end example
  9100. @item
  9101. Set the timebase to 1/10:
  9102. @example
  9103. settb=expr=0.1
  9104. @end example
  9105. @item
  9106. Set the timebase to 1001/1000:
  9107. @example
  9108. settb=1+0.001
  9109. @end example
  9110. @item
  9111. Set the timebase to 2*intb:
  9112. @example
  9113. settb=2*intb
  9114. @end example
  9115. @item
  9116. Set the default timebase value:
  9117. @example
  9118. settb=AVTB
  9119. @end example
  9120. @end itemize
  9121. @section showcqt
  9122. Convert input audio to a video output representing
  9123. frequency spectrum logarithmically (using constant Q transform with
  9124. Brown-Puckette algorithm), with musical tone scale, from E0 to D#10 (10 octaves).
  9125. The filter accepts the following options:
  9126. @table @option
  9127. @item volume
  9128. Specify transform volume (multiplier) expression. The expression can contain
  9129. variables:
  9130. @table @option
  9131. @item frequency, freq, f
  9132. the frequency where transform is evaluated
  9133. @item timeclamp, tc
  9134. value of timeclamp option
  9135. @end table
  9136. and functions:
  9137. @table @option
  9138. @item a_weighting(f)
  9139. A-weighting of equal loudness
  9140. @item b_weighting(f)
  9141. B-weighting of equal loudness
  9142. @item c_weighting(f)
  9143. C-weighting of equal loudness
  9144. @end table
  9145. Default value is @code{16}.
  9146. @item tlength
  9147. Specify transform length expression. The expression can contain variables:
  9148. @table @option
  9149. @item frequency, freq, f
  9150. the frequency where transform is evaluated
  9151. @item timeclamp, tc
  9152. value of timeclamp option
  9153. @end table
  9154. Default value is @code{384/f*tc/(384/f+tc)}.
  9155. @item timeclamp
  9156. Specify the transform timeclamp. At low frequency, there is trade-off between
  9157. accuracy in time domain and frequency domain. If timeclamp is lower,
  9158. event in time domain is represented more accurately (such as fast bass drum),
  9159. otherwise event in frequency domain is represented more accurately
  9160. (such as bass guitar). Acceptable value is [0.1, 1.0]. Default value is @code{0.17}.
  9161. @item coeffclamp
  9162. Specify the transform coeffclamp. If coeffclamp is lower, transform is
  9163. more accurate, otherwise transform is faster. Acceptable value is [0.1, 10.0].
  9164. Default value is @code{1.0}.
  9165. @item gamma
  9166. Specify gamma. Lower gamma makes the spectrum more contrast, higher gamma
  9167. makes the spectrum having more range. Acceptable value is [1.0, 7.0].
  9168. Default value is @code{3.0}.
  9169. @item gamma2
  9170. Specify gamma of bargraph. Acceptable value is [1.0, 7.0].
  9171. Default value is @code{1.0}.
  9172. @item fontfile
  9173. Specify font file for use with freetype. If not specified, use embedded font.
  9174. @item fontcolor
  9175. Specify font color expression. This is arithmetic expression that should return
  9176. integer value 0xRRGGBB. The expression can contain variables:
  9177. @table @option
  9178. @item frequency, freq, f
  9179. the frequency where transform is evaluated
  9180. @item timeclamp, tc
  9181. value of timeclamp option
  9182. @end table
  9183. and functions:
  9184. @table @option
  9185. @item midi(f)
  9186. midi number of frequency f, some midi numbers: E0(16), C1(24), C2(36), A4(69)
  9187. @item r(x), g(x), b(x)
  9188. red, green, and blue value of intensity x
  9189. @end table
  9190. Default value is @code{st(0, (midi(f)-59.5)/12);
  9191. st(1, if(between(ld(0),0,1), 0.5-0.5*cos(2*PI*ld(0)), 0));
  9192. r(1-ld(1)) + b(ld(1))}
  9193. @item fullhd
  9194. If set to 1 (the default), the video size is 1920x1080 (full HD),
  9195. if set to 0, the video size is 960x540. Use this option to make CPU usage lower.
  9196. @item fps
  9197. Specify video fps. Default value is @code{25}.
  9198. @item count
  9199. Specify number of transform per frame, so there are fps*count transforms
  9200. per second. Note that audio data rate must be divisible by fps*count.
  9201. Default value is @code{6}.
  9202. @end table
  9203. @subsection Examples
  9204. @itemize
  9205. @item
  9206. Playing audio while showing the spectrum:
  9207. @example
  9208. ffplay -f lavfi 'amovie=a.mp3, asplit [a][out1]; [a] showcqt [out0]'
  9209. @end example
  9210. @item
  9211. Same as above, but with frame rate 30 fps:
  9212. @example
  9213. ffplay -f lavfi 'amovie=a.mp3, asplit [a][out1]; [a] showcqt=fps=30:count=5 [out0]'
  9214. @end example
  9215. @item
  9216. Playing at 960x540 and lower CPU usage:
  9217. @example
  9218. ffplay -f lavfi 'amovie=a.mp3, asplit [a][out1]; [a] showcqt=fullhd=0:count=3 [out0]'
  9219. @end example
  9220. @item
  9221. A1 and its harmonics: A1, A2, (near)E3, A3:
  9222. @example
  9223. ffplay -f lavfi 'aevalsrc=0.1*sin(2*PI*55*t)+0.1*sin(4*PI*55*t)+0.1*sin(6*PI*55*t)+0.1*sin(8*PI*55*t),
  9224. asplit[a][out1]; [a] showcqt [out0]'
  9225. @end example
  9226. @item
  9227. Same as above, but with more accuracy in frequency domain (and slower):
  9228. @example
  9229. ffplay -f lavfi 'aevalsrc=0.1*sin(2*PI*55*t)+0.1*sin(4*PI*55*t)+0.1*sin(6*PI*55*t)+0.1*sin(8*PI*55*t),
  9230. asplit[a][out1]; [a] showcqt=timeclamp=0.5 [out0]'
  9231. @end example
  9232. @item
  9233. B-weighting of equal loudness
  9234. @example
  9235. volume=16*b_weighting(f)
  9236. @end example
  9237. @item
  9238. Lower Q factor
  9239. @example
  9240. tlength=100/f*tc/(100/f+tc)
  9241. @end example
  9242. @item
  9243. Custom fontcolor, C-note is colored green, others are colored blue
  9244. @example
  9245. fontcolor='if(mod(floor(midi(f)+0.5),12), 0x0000FF, g(1))'
  9246. @end example
  9247. @item
  9248. Custom gamma, now spectrum is linear to the amplitude.
  9249. @example
  9250. gamma=2:gamma2=2
  9251. @end example
  9252. @end itemize
  9253. @section showspectrum
  9254. Convert input audio to a video output, representing the audio frequency
  9255. spectrum.
  9256. The filter accepts the following options:
  9257. @table @option
  9258. @item size, s
  9259. Specify the video size for the output. For the syntax of this option, check the
  9260. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  9261. Default value is @code{640x512}.
  9262. @item slide
  9263. Specify how the spectrum should slide along the window.
  9264. It accepts the following values:
  9265. @table @samp
  9266. @item replace
  9267. the samples start again on the left when they reach the right
  9268. @item scroll
  9269. the samples scroll from right to left
  9270. @item fullframe
  9271. frames are only produced when the samples reach the right
  9272. @end table
  9273. Default value is @code{replace}.
  9274. @item mode
  9275. Specify display mode.
  9276. It accepts the following values:
  9277. @table @samp
  9278. @item combined
  9279. all channels are displayed in the same row
  9280. @item separate
  9281. all channels are displayed in separate rows
  9282. @end table
  9283. Default value is @samp{combined}.
  9284. @item color
  9285. Specify display color mode.
  9286. It accepts the following values:
  9287. @table @samp
  9288. @item channel
  9289. each channel is displayed in a separate color
  9290. @item intensity
  9291. each channel is is displayed using the same color scheme
  9292. @end table
  9293. Default value is @samp{channel}.
  9294. @item scale
  9295. Specify scale used for calculating intensity color values.
  9296. It accepts the following values:
  9297. @table @samp
  9298. @item lin
  9299. linear
  9300. @item sqrt
  9301. square root, default
  9302. @item cbrt
  9303. cubic root
  9304. @item log
  9305. logarithmic
  9306. @end table
  9307. Default value is @samp{sqrt}.
  9308. @item saturation
  9309. Set saturation modifier for displayed colors. Negative values provide
  9310. alternative color scheme. @code{0} is no saturation at all.
  9311. Saturation must be in [-10.0, 10.0] range.
  9312. Default value is @code{1}.
  9313. @item win_func
  9314. Set window function.
  9315. It accepts the following values:
  9316. @table @samp
  9317. @item none
  9318. No samples pre-processing (do not expect this to be faster)
  9319. @item hann
  9320. Hann window
  9321. @item hamming
  9322. Hamming window
  9323. @item blackman
  9324. Blackman window
  9325. @end table
  9326. Default value is @code{hann}.
  9327. @end table
  9328. The usage is very similar to the showwaves filter; see the examples in that
  9329. section.
  9330. @subsection Examples
  9331. @itemize
  9332. @item
  9333. Large window with logarithmic color scaling:
  9334. @example
  9335. showspectrum=s=1280x480:scale=log
  9336. @end example
  9337. @item
  9338. Complete example for a colored and sliding spectrum per channel using @command{ffplay}:
  9339. @example
  9340. ffplay -f lavfi 'amovie=input.mp3, asplit [a][out1];
  9341. [a] showspectrum=mode=separate:color=intensity:slide=1:scale=cbrt [out0]'
  9342. @end example
  9343. @end itemize
  9344. @section showvolume
  9345. Convert input audio volume to a video output.
  9346. The filter accepts the following options:
  9347. @table @option
  9348. @item rate, r
  9349. Set video rate.
  9350. @item b
  9351. Set border width, allowed range is [0, 5]. Default is 1.
  9352. @item w
  9353. Set channel width, allowed range is [40, 1080]. Default is 400.
  9354. @item h
  9355. Set channel height, allowed range is [1, 100]. Default is 20.
  9356. @item f
  9357. Set fade, allowed range is [1, 255]. Default is 20.
  9358. @item c
  9359. Set volume color expression.
  9360. The expression can use the following variables:
  9361. @table @option
  9362. @item VOLUME
  9363. Current max volume of channel in dB.
  9364. @item CHANNEL
  9365. Current channel number, starting from 0.
  9366. @end table
  9367. @item t
  9368. If set, displays channel names. Default is enabled.
  9369. @end table
  9370. @section showwaves
  9371. Convert input audio to a video output, representing the samples waves.
  9372. The filter accepts the following options:
  9373. @table @option
  9374. @item size, s
  9375. Specify the video size for the output. For the syntax of this option, check the
  9376. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  9377. Default value is @code{600x240}.
  9378. @item mode
  9379. Set display mode.
  9380. Available values are:
  9381. @table @samp
  9382. @item point
  9383. Draw a point for each sample.
  9384. @item line
  9385. Draw a vertical line for each sample.
  9386. @item p2p
  9387. Draw a point for each sample and a line between them.
  9388. @item cline
  9389. Draw a centered vertical line for each sample.
  9390. @end table
  9391. Default value is @code{point}.
  9392. @item n
  9393. Set the number of samples which are printed on the same column. A
  9394. larger value will decrease the frame rate. Must be a positive
  9395. integer. This option can be set only if the value for @var{rate}
  9396. is not explicitly specified.
  9397. @item rate, r
  9398. Set the (approximate) output frame rate. This is done by setting the
  9399. option @var{n}. Default value is "25".
  9400. @item split_channels
  9401. Set if channels should be drawn separately or overlap. Default value is 0.
  9402. @end table
  9403. @subsection Examples
  9404. @itemize
  9405. @item
  9406. Output the input file audio and the corresponding video representation
  9407. at the same time:
  9408. @example
  9409. amovie=a.mp3,asplit[out0],showwaves[out1]
  9410. @end example
  9411. @item
  9412. Create a synthetic signal and show it with showwaves, forcing a
  9413. frame rate of 30 frames per second:
  9414. @example
  9415. aevalsrc=sin(1*2*PI*t)*sin(880*2*PI*t):cos(2*PI*200*t),asplit[out0],showwaves=r=30[out1]
  9416. @end example
  9417. @end itemize
  9418. @section showwavespic
  9419. Convert input audio to a single video frame, representing the samples waves.
  9420. The filter accepts the following options:
  9421. @table @option
  9422. @item size, s
  9423. Specify the video size for the output. For the syntax of this option, check the
  9424. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  9425. Default value is @code{600x240}.
  9426. @item split_channels
  9427. Set if channels should be drawn separately or overlap. Default value is 0.
  9428. @end table
  9429. @subsection Examples
  9430. @itemize
  9431. @item
  9432. Extract a channel split representation of the wave form of a whole audio track
  9433. in a 1024x800 picture using @command{ffmpeg}:
  9434. @example
  9435. ffmpeg -i audio.flac -lavfi showwavespic=split_channels=1:s=1024x800 waveform.png
  9436. @end example
  9437. @end itemize
  9438. @section split, asplit
  9439. Split input into several identical outputs.
  9440. @code{asplit} works with audio input, @code{split} with video.
  9441. The filter accepts a single parameter which specifies the number of outputs. If
  9442. unspecified, it defaults to 2.
  9443. @subsection Examples
  9444. @itemize
  9445. @item
  9446. Create two separate outputs from the same input:
  9447. @example
  9448. [in] split [out0][out1]
  9449. @end example
  9450. @item
  9451. To create 3 or more outputs, you need to specify the number of
  9452. outputs, like in:
  9453. @example
  9454. [in] asplit=3 [out0][out1][out2]
  9455. @end example
  9456. @item
  9457. Create two separate outputs from the same input, one cropped and
  9458. one padded:
  9459. @example
  9460. [in] split [splitout1][splitout2];
  9461. [splitout1] crop=100:100:0:0 [cropout];
  9462. [splitout2] pad=200:200:100:100 [padout];
  9463. @end example
  9464. @item
  9465. Create 5 copies of the input audio with @command{ffmpeg}:
  9466. @example
  9467. ffmpeg -i INPUT -filter_complex asplit=5 OUTPUT
  9468. @end example
  9469. @end itemize
  9470. @section zmq, azmq
  9471. Receive commands sent through a libzmq client, and forward them to
  9472. filters in the filtergraph.
  9473. @code{zmq} and @code{azmq} work as a pass-through filters. @code{zmq}
  9474. must be inserted between two video filters, @code{azmq} between two
  9475. audio filters.
  9476. To enable these filters you need to install the libzmq library and
  9477. headers and configure FFmpeg with @code{--enable-libzmq}.
  9478. For more information about libzmq see:
  9479. @url{http://www.zeromq.org/}
  9480. The @code{zmq} and @code{azmq} filters work as a libzmq server, which
  9481. receives messages sent through a network interface defined by the
  9482. @option{bind_address} option.
  9483. The received message must be in the form:
  9484. @example
  9485. @var{TARGET} @var{COMMAND} [@var{ARG}]
  9486. @end example
  9487. @var{TARGET} specifies the target of the command, usually the name of
  9488. the filter class or a specific filter instance name.
  9489. @var{COMMAND} specifies the name of the command for the target filter.
  9490. @var{ARG} is optional and specifies the optional argument list for the
  9491. given @var{COMMAND}.
  9492. Upon reception, the message is processed and the corresponding command
  9493. is injected into the filtergraph. Depending on the result, the filter
  9494. will send a reply to the client, adopting the format:
  9495. @example
  9496. @var{ERROR_CODE} @var{ERROR_REASON}
  9497. @var{MESSAGE}
  9498. @end example
  9499. @var{MESSAGE} is optional.
  9500. @subsection Examples
  9501. Look at @file{tools/zmqsend} for an example of a zmq client which can
  9502. be used to send commands processed by these filters.
  9503. Consider the following filtergraph generated by @command{ffplay}
  9504. @example
  9505. ffplay -dumpgraph 1 -f lavfi "
  9506. color=s=100x100:c=red [l];
  9507. color=s=100x100:c=blue [r];
  9508. nullsrc=s=200x100, zmq [bg];
  9509. [bg][l] overlay [bg+l];
  9510. [bg+l][r] overlay=x=100 "
  9511. @end example
  9512. To change the color of the left side of the video, the following
  9513. command can be used:
  9514. @example
  9515. echo Parsed_color_0 c yellow | tools/zmqsend
  9516. @end example
  9517. To change the right side:
  9518. @example
  9519. echo Parsed_color_1 c pink | tools/zmqsend
  9520. @end example
  9521. @c man end MULTIMEDIA FILTERS
  9522. @chapter Multimedia Sources
  9523. @c man begin MULTIMEDIA SOURCES
  9524. Below is a description of the currently available multimedia sources.
  9525. @section amovie
  9526. This is the same as @ref{movie} source, except it selects an audio
  9527. stream by default.
  9528. @anchor{movie}
  9529. @section movie
  9530. Read audio and/or video stream(s) from a movie container.
  9531. It accepts the following parameters:
  9532. @table @option
  9533. @item filename
  9534. The name of the resource to read (not necessarily a file; it can also be a
  9535. device or a stream accessed through some protocol).
  9536. @item format_name, f
  9537. Specifies the format assumed for the movie to read, and can be either
  9538. the name of a container or an input device. If not specified, the
  9539. format is guessed from @var{movie_name} or by probing.
  9540. @item seek_point, sp
  9541. Specifies the seek point in seconds. The frames will be output
  9542. starting from this seek point. The parameter is evaluated with
  9543. @code{av_strtod}, so the numerical value may be suffixed by an IS
  9544. postfix. The default value is "0".
  9545. @item streams, s
  9546. Specifies the streams to read. Several streams can be specified,
  9547. separated by "+". The source will then have as many outputs, in the
  9548. same order. The syntax is explained in the ``Stream specifiers''
  9549. section in the ffmpeg manual. Two special names, "dv" and "da" specify
  9550. respectively the default (best suited) video and audio stream. Default
  9551. is "dv", or "da" if the filter is called as "amovie".
  9552. @item stream_index, si
  9553. Specifies the index of the video stream to read. If the value is -1,
  9554. the most suitable video stream will be automatically selected. The default
  9555. value is "-1". Deprecated. If the filter is called "amovie", it will select
  9556. audio instead of video.
  9557. @item loop
  9558. Specifies how many times to read the stream in sequence.
  9559. If the value is less than 1, the stream will be read again and again.
  9560. Default value is "1".
  9561. Note that when the movie is looped the source timestamps are not
  9562. changed, so it will generate non monotonically increasing timestamps.
  9563. @end table
  9564. It allows overlaying a second video on top of the main input of
  9565. a filtergraph, as shown in this graph:
  9566. @example
  9567. input -----------> deltapts0 --> overlay --> output
  9568. ^
  9569. |
  9570. movie --> scale--> deltapts1 -------+
  9571. @end example
  9572. @subsection Examples
  9573. @itemize
  9574. @item
  9575. Skip 3.2 seconds from the start of the AVI file in.avi, and overlay it
  9576. on top of the input labelled "in":
  9577. @example
  9578. movie=in.avi:seek_point=3.2, scale=180:-1, setpts=PTS-STARTPTS [over];
  9579. [in] setpts=PTS-STARTPTS [main];
  9580. [main][over] overlay=16:16 [out]
  9581. @end example
  9582. @item
  9583. Read from a video4linux2 device, and overlay it on top of the input
  9584. labelled "in":
  9585. @example
  9586. movie=/dev/video0:f=video4linux2, scale=180:-1, setpts=PTS-STARTPTS [over];
  9587. [in] setpts=PTS-STARTPTS [main];
  9588. [main][over] overlay=16:16 [out]
  9589. @end example
  9590. @item
  9591. Read the first video stream and the audio stream with id 0x81 from
  9592. dvd.vob; the video is connected to the pad named "video" and the audio is
  9593. connected to the pad named "audio":
  9594. @example
  9595. movie=dvd.vob:s=v:0+#0x81 [video] [audio]
  9596. @end example
  9597. @end itemize
  9598. @c man end MULTIMEDIA SOURCES