filters.texi 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614
  1. @chapter Audio Filters
  2. @c man begin AUDIO FILTERS
  3. When you configure your FFmpeg build, you can disable any of the
  4. existing filters using --disable-filters.
  5. The configure output will show the audio filters included in your
  6. build.
  7. Below is a description of the currently available audio filters.
  8. @section anull
  9. Pass the audio source unchanged to the output.
  10. @c man end AUDIO FILTERS
  11. @chapter Audio Sources
  12. @c man begin AUDIO SOURCES
  13. Below is a description of the currently available audio sources.
  14. @section anullsrc
  15. Null audio source, never return audio frames. It is mainly useful as a
  16. template and to be employed in analysis / debugging tools.
  17. It accepts as optional parameter a string of the form
  18. @var{sample_rate}:@var{channel_layout}.
  19. @var{sample_rate} specify the sample rate, and defaults to 44100.
  20. @var{channel_layout} specify the channel layout, and can be either an
  21. integer or a string representing a channel layout. The default value
  22. of @var{channel_layout} is 3, which corresponds to CH_LAYOUT_STEREO.
  23. Check the channel_layout_map definition in
  24. @file{libavcodec/audioconvert.c} for the mapping between strings and
  25. channel layout values.
  26. Follow some examples:
  27. @example
  28. # set the sample rate to 48000 Hz and the channel layout to CH_LAYOUT_MONO.
  29. anullsrc=48000:4
  30. # same as
  31. anullsrc=48000:mono
  32. @end example
  33. @c man end AUDIO SOURCES
  34. @chapter Audio Sinks
  35. @c man begin AUDIO SINKS
  36. Below is a description of the currently available audio sinks.
  37. @section anullsink
  38. Null audio sink, do absolutely nothing with the input audio. It is
  39. mainly useful as a template and to be employed in analysis / debugging
  40. tools.
  41. @c man end AUDIO SINKS
  42. @chapter Video Filters
  43. @c man begin VIDEO FILTERS
  44. When you configure your FFmpeg build, you can disable any of the
  45. existing filters using --disable-filters.
  46. The configure output will show the video filters included in your
  47. build.
  48. Below is a description of the currently available video filters.
  49. @section blackframe
  50. Detect frames that are (almost) completely black. Can be useful to
  51. detect chapter transitions or commercials. Output lines consist of
  52. the frame number of the detected frame, the percentage of blackness,
  53. the position in the file if known or -1 and the timestamp in seconds.
  54. In order to display the output lines, you need to set the loglevel at
  55. least to the AV_LOG_INFO value.
  56. The filter accepts the syntax:
  57. @example
  58. blackframe[=@var{amount}:[@var{threshold}]]
  59. @end example
  60. @var{amount} is the percentage of the pixels that have to be below the
  61. threshold, and defaults to 98.
  62. @var{threshold} is the threshold below which a pixel value is
  63. considered black, and defaults to 32.
  64. @section crop
  65. Crop the input video to @var{out_w}:@var{out_h}:@var{x}:@var{y}.
  66. The parameters are expressions containing the following constants:
  67. @table @option
  68. @item E, PI, PHI
  69. the corresponding mathematical approximated values for e
  70. (euler number), pi (greek PI), PHI (golden ratio)
  71. @item x, y
  72. the computed values for @var{x} and @var{y}. They are evaluated for
  73. each new frame.
  74. @item in_w, in_h
  75. the input width and heigth
  76. @item iw, ih
  77. same as @var{in_w} and @var{in_h}
  78. @item out_w, out_h
  79. the output (cropped) width and heigth
  80. @item ow, oh
  81. same as @var{out_w} and @var{out_h}
  82. @item n
  83. the number of input frame, starting from 0
  84. @item pos
  85. the position in the file of the input frame, NAN if unknown
  86. @item t
  87. timestamp expressed in seconds, NAN if the input timestamp is unknown
  88. @end table
  89. The @var{out_w} and @var{out_h} parameters specify the expressions for
  90. the width and height of the output (cropped) video. They are
  91. evaluated just at the configuration of the filter.
  92. The default value of @var{out_w} is "in_w", and the default value of
  93. @var{out_h} is "in_h".
  94. The expression for @var{out_w} may depend on the value of @var{out_h},
  95. and the expression for @var{out_h} may depend on @var{out_w}, but they
  96. cannot depend on @var{x} and @var{y}, as @var{x} and @var{y} are
  97. evaluated after @var{out_w} and @var{out_h}.
  98. The @var{x} and @var{y} parameters specify the expressions for the
  99. position of the top-left corner of the output (non-cropped) area. They
  100. are evaluated for each frame. If the evaluated value is not valid, it
  101. is approximated to the nearest valid value.
  102. The default value of @var{x} is "(in_w-out_w)/2", and the default
  103. value for @var{y} is "(in_h-out_h)/2", which set the cropped area at
  104. the center of the input image.
  105. The expression for @var{x} may depend on @var{y}, and the expression
  106. for @var{y} may depend on @var{x}.
  107. Follow some examples:
  108. @example
  109. # crop the central input area with size 100x100
  110. crop=100:100
  111. # crop the central input area with size 2/3 of the input video
  112. "crop=2/3*in_w:2/3*in_h"
  113. # crop the input video central square
  114. crop=in_h
  115. # delimit the rectangle with the top-left corner placed at position
  116. # 100:100 and the right-bottom corner corresponding to the right-bottom
  117. # corner of the input image.
  118. crop=in_w-100:in_h-100:100:100
  119. # crop 10 pixels from the lefth and right borders, and 20 pixels from
  120. # the top and bottom borders
  121. "crop=in_w-2*10:in_h-2*20"
  122. # keep only the bottom right quarter of the input image
  123. "crop=in_w/2:in_h/2:in_w/2:in_h/2"
  124. # crop height for getting Greek harmony
  125. "crop=in_w:1/PHI*in_w"
  126. # trembling effect
  127. "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)"
  128. # erratic camera effect depending on timestamp and position
  129. "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)"
  130. # set x depending on the value of y
  131. "crop=in_w/2:in_h/2:y:10+10*sin(n/10)"
  132. @end example
  133. @section fifo
  134. Buffer input images and send them when they are requested.
  135. This filter is mainly useful when auto-inserted by the libavfilter
  136. framework.
  137. The filter does not take parameters.
  138. @section format
  139. Convert the input video to one of the specified pixel formats.
  140. Libavfilter will try to pick one that is supported for the input to
  141. the next filter.
  142. The filter accepts a list of pixel format names, separated by ":",
  143. for example "yuv420p:monow:rgb24".
  144. The following command:
  145. @example
  146. ./ffmpeg -i in.avi -vf "format=yuv420p" out.avi
  147. @end example
  148. will convert the input video to the format "yuv420p".
  149. @section frei0r
  150. Apply a frei0r effect to the input video.
  151. To enable compilation of this filter you need to install the frei0r
  152. header and configure FFmpeg with --enable-frei0r.
  153. The filter supports the syntax:
  154. @example
  155. @var{filter_name}:@var{param1}:@var{param2}:...:@var{paramN}
  156. @end example
  157. @var{filter_name} is the name to the frei0r effect to load. If the
  158. environment variable @env{FREI0R_PATH} is defined, the frei0r effect
  159. is searched in each one of the directories specified by the colon
  160. separated list in @env{FREIOR_PATH}, otherwise in the standard frei0r
  161. paths, which are in this order: @file{HOME/.frei0r-1/lib/},
  162. @file{/usr/local/lib/frei0r-1/}, @file{/usr/lib/frei0r-1/}.
  163. @var{param1}, @var{param2}, ... , @var{paramN} specify the parameters
  164. for the frei0r effect.
  165. A frei0r effect parameter can be a boolean (whose values are specified
  166. with "y" and "n"), a double, a color (specified by the syntax
  167. @var{R}/@var{G}/@var{B}, @var{R}, @var{G}, and @var{B} being float
  168. numbers from 0.0 to 1.0) or by an @code{av_parse_color()} color
  169. description), a position (specified by the syntax @var{X}/@var{Y},
  170. @var{X} and @var{Y} being float numbers) and a string.
  171. The number and kind of parameters depend on the loaded effect. If an
  172. effect parameter is not specified the default value is set.
  173. Some examples follow:
  174. @example
  175. # apply the distort0r effect, set the first two double parameters
  176. frei0r=distort0r:0.5:0.01
  177. # apply the colordistance effect, takes a color as first parameter
  178. frei0r=colordistance:0.2/0.3/0.4
  179. frei0r=colordistance:violet
  180. frei0r=colordistance:0x112233
  181. # apply the perspective effect, specify the top left and top right
  182. # image positions
  183. frei0r=perspective:0.2/0.2:0.8/0.2
  184. @end example
  185. For more information see:
  186. @url{http://piksel.org/frei0r}
  187. @section hflip
  188. Flip the input video horizontally.
  189. For example to horizontally flip the video in input with
  190. @file{ffmpeg}:
  191. @example
  192. ffmpeg -i in.avi -vf "hflip" out.avi
  193. @end example
  194. @section noformat
  195. Force libavfilter not to use any of the specified pixel formats for the
  196. input to the next filter.
  197. The filter accepts a list of pixel format names, separated by ":",
  198. for example "yuv420p:monow:rgb24".
  199. The following command:
  200. @example
  201. ./ffmpeg -i in.avi -vf "noformat=yuv420p, vflip" out.avi
  202. @end example
  203. will make libavfilter use a format different from "yuv420p" for the
  204. input to the vflip filter.
  205. @section null
  206. Pass the video source unchanged to the output.
  207. @section ocv_smooth
  208. Apply smooth transform using libopencv.
  209. To enable this filter install libopencv library and headers and
  210. configure FFmpeg with --enable-libopencv.
  211. The filter accepts the following parameters:
  212. @var{type}:@var{param1}:@var{param2}:@var{param3}:@var{param4}.
  213. @var{type} is the type of smooth filter to apply, and can be one of
  214. the following values: "blur", "blur_no_scale", "median", "gaussian",
  215. "bilateral". The default value is "gaussian".
  216. @var{param1}, @var{param2}, @var{param3}, and @var{param4} are
  217. parameters whose meanings depend on smooth type. @var{param1} and
  218. @var{param2} accept integer positive values or 0, @var{param3} and
  219. @var{param4} accept float values.
  220. The default value for @var{param1} is 3, the default value for the
  221. other parameters is 0.
  222. These parameters correspond to the parameters assigned to the
  223. libopencv function @code{cvSmooth}. Refer to the official libopencv
  224. documentation for the exact meaning of the parameters:
  225. @url{http://opencv.willowgarage.com/documentation/c/image_filtering.html}
  226. @section pad
  227. Add paddings to the input image, and places the original input at the
  228. given coordinates @var{x}, @var{y}.
  229. It accepts the following parameters:
  230. @var{width}:@var{height}:@var{x}:@var{y}:@var{color}.
  231. Follows the description of the accepted parameters.
  232. @table @option
  233. @item width, height
  234. Specify the size of the output image with the paddings added. If the
  235. value for @var{width} or @var{height} is 0, the corresponding input size
  236. is used for the output.
  237. The default value of @var{width} and @var{height} is 0.
  238. @item x, y
  239. Specify the offsets where to place the input image in the padded area
  240. with respect to the top/left border of the output image.
  241. The default value of @var{x} and @var{y} is 0.
  242. @item color
  243. Specify the color of the padded area, it can be the name of a color
  244. (case insensitive match) or a 0xRRGGBB[AA] sequence.
  245. The default value of @var{color} is "black".
  246. @end table
  247. @section pixdesctest
  248. Pixel format descriptor test filter, mainly useful for internal
  249. testing. The output video should be equal to the input video.
  250. For example:
  251. @example
  252. format=monow, pixdesctest
  253. @end example
  254. can be used to test the monowhite pixel format descriptor definition.
  255. @section scale
  256. Scale the input video to @var{width}:@var{height} and/or convert the image format.
  257. For example the command:
  258. @example
  259. ./ffmpeg -i in.avi -vf "scale=200:100" out.avi
  260. @end example
  261. will scale the input video to a size of 200x100.
  262. If the input image format is different from the format requested by
  263. the next filter, the scale filter will convert the input to the
  264. requested format.
  265. If the value for @var{width} or @var{height} is 0, the respective input
  266. size is used for the output.
  267. If the value for @var{width} or @var{height} is -1, the scale filter will
  268. use, for the respective output size, a value that maintains the aspect
  269. ratio of the input image.
  270. The default value of @var{width} and @var{height} is 0.
  271. @section slicify
  272. Pass the images of input video on to next video filter as multiple
  273. slices.
  274. @example
  275. ./ffmpeg -i in.avi -vf "slicify=32" out.avi
  276. @end example
  277. The filter accepts the slice height as parameter. If the parameter is
  278. not specified it will use the default value of 16.
  279. Adding this in the beginning of filter chains should make filtering
  280. faster due to better use of the memory cache.
  281. @section unsharp
  282. Sharpen or blur the input video.
  283. It accepts the following parameters:
  284. @var{luma_msize_x}:@var{luma_msize_y}:@var{luma_amount}:@var{chroma_msize_x}:@var{chroma_msize_y}:@var{chroma_amount}
  285. Negative values for the amount will blur the input video, while positive
  286. values will sharpen. All parameters are optional and default to the
  287. equivalent of the string '5:5:1.0:0:0:0.0'.
  288. @table @option
  289. @item luma_msize_x
  290. Set the luma matrix horizontal size. It can be an integer between 3
  291. and 13, default value is 5.
  292. @item luma_msize_y
  293. Set the luma matrix vertical size. It can be an integer between 3
  294. and 13, default value is 5.
  295. @item luma_amount
  296. Set the luma effect strength. It can be a float number between -2.0
  297. and 5.0, default value is 1.0.
  298. @item chroma_msize_x
  299. Set the chroma matrix horizontal size. It can be an integer between 3
  300. and 13, default value is 0.
  301. @item chroma_msize_y
  302. Set the chroma matrix vertical size. It can be an integer between 3
  303. and 13, default value is 0.
  304. @item luma_amount
  305. Set the chroma effect strength. It can be a float number between -2.0
  306. and 5.0, default value is 0.0.
  307. @end table
  308. @example
  309. # Strong luma sharpen effect parameters
  310. unsharp=7:7:2.5
  311. # Strong blur of both luma and chroma parameters
  312. unsharp=7:7:-2:7:7:-2
  313. # Use the default values with @command{ffmpeg}
  314. ./ffmpeg -i in.avi -vf "unsharp" out.mp4
  315. @end example
  316. @section vflip
  317. Flip the input video vertically.
  318. @example
  319. ./ffmpeg -i in.avi -vf "vflip" out.avi
  320. @end example
  321. @section yadif
  322. yadif is "yet another deinterlacing filter".
  323. It accepts the syntax:
  324. @example
  325. yadif=[@var{mode}[:@var{parity}]]
  326. @end example
  327. @table @option
  328. @item mode
  329. Specify the interlacing mode to adopt, accepts one of the following values.
  330. 0: Output 1 frame for each frame.
  331. 1: Output 1 frame for each field.
  332. 2: Like 0 but skips spatial interlacing check.
  333. 3: Like 1 but skips spatial interlacing check.
  334. Default value is 0.
  335. @item parity
  336. 0 if is bottom field first, 1 if the interlaced video is top field
  337. first, -1 to enable automatic detection.
  338. @end table
  339. @c man end VIDEO FILTERS
  340. @chapter Video Sources
  341. @c man begin VIDEO SOURCES
  342. Below is a description of the currently available video sources.
  343. @section buffer
  344. Buffer video frames, and make them available to the filter chain.
  345. This source is mainly intended for a programmatic use, in particular
  346. through the interface defined in @file{libavfilter/vsrc_buffer.h}.
  347. It accepts the following parameters:
  348. @var{width}:@var{height}:@var{pix_fmt_string}
  349. All the parameters need to be explicitely defined.
  350. Follows the list of the accepted parameters.
  351. @table @option
  352. @item width, height
  353. Specify the width and height of the buffered video frames.
  354. @item pix_fmt_string
  355. A string representing the pixel format of the buffered video frames.
  356. It may be a number corresponding to a pixel format, or a pixel format
  357. name.
  358. @end table
  359. For example:
  360. @example
  361. buffer=320:240:yuv410p
  362. @end example
  363. will instruct the source to accept video frames with size 320x240 and
  364. with format "yuv410p". Since the pixel format with name "yuv410p"
  365. corresponds to the number 6 (check the enum PixelFormat definition in
  366. @file{libavutil/pixfmt.h}), this example corresponds to:
  367. @example
  368. buffer=320:240:6
  369. @end example
  370. @section color
  371. Provide an uniformly colored input.
  372. It accepts the following parameters:
  373. @var{color}:@var{frame_size}:@var{frame_rate}
  374. Follows the description of the accepted parameters.
  375. @table @option
  376. @item color
  377. Specify the color of the source. It can be the name of a color (case
  378. insensitive match) or a 0xRRGGBB[AA] sequence, possibly followed by an
  379. alpha specifier. The default value is "black".
  380. @item frame_size
  381. Specify the size of the sourced video, it may be a string of the form
  382. @var{width}x@var{heigth}, or the name of a size abbreviation. The
  383. default value is "320x240".
  384. @item frame_rate
  385. Specify the frame rate of the sourced video, as the number of frames
  386. generated per second. It has to be a string in the format
  387. @var{frame_rate_num}/@var{frame_rate_den}, an integer number, a float
  388. number or a valid video frame rate abbreviation. The default value is
  389. "25".
  390. @end table
  391. For example the following graph description will generate a red source
  392. with an opacity of 0.2, with size "qcif" and a frame rate of 10
  393. frames per second, which will be overlayed over the source connected
  394. to the pad with identifier "in".
  395. @example
  396. "color=red@@0.2:qcif:10 [color]; [in][color] overlay [out]"
  397. @end example
  398. @section nullsrc
  399. Null video source, never return images. It is mainly useful as a
  400. template and to be employed in analysis / debugging tools.
  401. It accepts as optional parameter a string of the form
  402. @var{width}:@var{height}, where @var{width} and @var{height} specify the size of
  403. the configured source.
  404. The default values of @var{width} and @var{height} are respectively 352
  405. and 288 (corresponding to the CIF size format).
  406. @c man end VIDEO SOURCES
  407. @chapter Video Sinks
  408. @c man begin VIDEO SINKS
  409. Below is a description of the currently available video sinks.
  410. @section nullsink
  411. Null video sink, do absolutely nothing with the input video. It is
  412. mainly useful as a template and to be employed in analysis / debugging
  413. tools.
  414. @c man end VIDEO SINKS