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.

12235 lines
332KB

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