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.

11253 lines
305KB

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