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.

12947 lines
354KB

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