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.

9910 lines
267KB

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