filters.texi 105 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760
  1. @chapter Filtergraph description
  2. @c man begin FILTERGRAPH DESCRIPTION
  3. A filtergraph is a directed graph of connected filters. It can contain
  4. cycles, and there can be multiple links between a pair of
  5. filters. Each link has one input pad on one side connecting it to one
  6. filter from which it takes its input, and one output pad on the other
  7. side connecting it to the one filter accepting its output.
  8. Each filter in a filtergraph is an instance of a filter class
  9. registered in the application, which defines the features and the
  10. number of input and output pads of the filter.
  11. A filter with no input pads is called a "source", a filter with no
  12. output pads is called a "sink".
  13. @anchor{Filtergraph syntax}
  14. @section Filtergraph syntax
  15. A filtergraph can be represented using a textual representation, which is
  16. recognized by the @option{-filter}/@option{-vf} and @option{-filter_complex}
  17. options in @command{ffmpeg} and @option{-vf} in @command{ffplay}, and by the
  18. @code{avfilter_graph_parse()}/@code{avfilter_graph_parse2()} function defined in
  19. @file{libavfilter/avfiltergraph.h}.
  20. A filterchain consists of a sequence of connected filters, each one
  21. connected to the previous one in the sequence. A filterchain is
  22. represented by a list of ","-separated filter descriptions.
  23. A filtergraph consists of a sequence of filterchains. A sequence of
  24. filterchains is represented by a list of ";"-separated filterchain
  25. descriptions.
  26. A filter is represented by a string of the form:
  27. [@var{in_link_1}]...[@var{in_link_N}]@var{filter_name}=@var{arguments}[@var{out_link_1}]...[@var{out_link_M}]
  28. @var{filter_name} is the name of the filter class of which the
  29. described filter is an instance of, and has to be the name of one of
  30. the filter classes registered in the program.
  31. The name of the filter class is optionally followed by a string
  32. "=@var{arguments}".
  33. @var{arguments} is a string which contains the parameters used to
  34. initialize the filter instance, and are described in the filter
  35. descriptions below.
  36. The list of arguments can be quoted using the character "'" as initial
  37. and ending mark, and the character '\' for escaping the characters
  38. within the quoted text; otherwise the argument string is considered
  39. terminated when the next special character (belonging to the set
  40. "[]=;,") is encountered.
  41. The name and arguments of the filter are optionally preceded and
  42. followed by a list of link labels.
  43. A link label allows to name a link and associate it to a filter output
  44. or input pad. The preceding labels @var{in_link_1}
  45. ... @var{in_link_N}, are associated to the filter input pads,
  46. the following labels @var{out_link_1} ... @var{out_link_M}, are
  47. associated to the output pads.
  48. When two link labels with the same name are found in the
  49. filtergraph, a link between the corresponding input and output pad is
  50. created.
  51. If an output pad is not labelled, it is linked by default to the first
  52. unlabelled input pad of the next filter in the filterchain.
  53. For example in the filterchain:
  54. @example
  55. nullsrc, split[L1], [L2]overlay, nullsink
  56. @end example
  57. the split filter instance has two output pads, and the overlay filter
  58. instance two input pads. The first output pad of split is labelled
  59. "L1", the first input pad of overlay is labelled "L2", and the second
  60. output pad of split is linked to the second input pad of overlay,
  61. which are both unlabelled.
  62. In a complete filterchain all the unlabelled filter input and output
  63. pads must be connected. A filtergraph is considered valid if all the
  64. filter input and output pads of all the filterchains are connected.
  65. Libavfilter will automatically insert scale filters where format
  66. conversion is required. It is possible to specify swscale flags
  67. for those automatically inserted scalers by prepending
  68. @code{sws_flags=@var{flags};}
  69. to the filtergraph description.
  70. Follows a BNF description for the filtergraph syntax:
  71. @example
  72. @var{NAME} ::= sequence of alphanumeric characters and '_'
  73. @var{LINKLABEL} ::= "[" @var{NAME} "]"
  74. @var{LINKLABELS} ::= @var{LINKLABEL} [@var{LINKLABELS}]
  75. @var{FILTER_ARGUMENTS} ::= sequence of chars (eventually quoted)
  76. @var{FILTER} ::= [@var{LINKNAMES}] @var{NAME} ["=" @var{ARGUMENTS}] [@var{LINKNAMES}]
  77. @var{FILTERCHAIN} ::= @var{FILTER} [,@var{FILTERCHAIN}]
  78. @var{FILTERGRAPH} ::= [sws_flags=@var{flags};] @var{FILTERCHAIN} [;@var{FILTERGRAPH}]
  79. @end example
  80. @c man end FILTERGRAPH DESCRIPTION
  81. @chapter Audio Filters
  82. @c man begin AUDIO FILTERS
  83. When you configure your FFmpeg build, you can disable any of the
  84. existing filters using @code{--disable-filters}.
  85. The configure output will show the audio filters included in your
  86. build.
  87. Below is a description of the currently available audio filters.
  88. @section aconvert
  89. Convert the input audio format to the specified formats.
  90. The filter accepts a string of the form:
  91. "@var{sample_format}:@var{channel_layout}".
  92. @var{sample_format} specifies the sample format, and can be a string or the
  93. corresponding numeric value defined in @file{libavutil/samplefmt.h}. Use 'p'
  94. suffix for a planar sample format.
  95. @var{channel_layout} specifies the channel layout, and can be a string
  96. or the corresponding number value defined in @file{libavutil/audioconvert.h}.
  97. The special parameter "auto", signifies that the filter will
  98. automatically select the output format depending on the output filter.
  99. Some examples follow.
  100. @itemize
  101. @item
  102. Convert input to float, planar, stereo:
  103. @example
  104. aconvert=fltp:stereo
  105. @end example
  106. @item
  107. Convert input to unsigned 8-bit, automatically select out channel layout:
  108. @example
  109. aconvert=u8:auto
  110. @end example
  111. @end itemize
  112. @section aformat
  113. Convert the input audio to one of the specified formats. The framework will
  114. negotiate the most appropriate format to minimize conversions.
  115. The filter accepts the following named parameters:
  116. @table @option
  117. @item sample_fmts
  118. A comma-separated list of requested sample formats.
  119. @item sample_rates
  120. A comma-separated list of requested sample rates.
  121. @item channel_layouts
  122. A comma-separated list of requested channel layouts.
  123. @end table
  124. If a parameter is omitted, all values are allowed.
  125. For example to force the output to either unsigned 8-bit or signed 16-bit stereo:
  126. @example
  127. aformat=sample_fmts\=u8\,s16:channel_layouts\=stereo
  128. @end example
  129. @section amerge
  130. Merge two or more audio streams into a single multi-channel stream.
  131. The filter accepts the following named options:
  132. @table @option
  133. @item inputs
  134. Set the number of inputs. Default is 2.
  135. @end table
  136. If the channel layouts of the inputs are disjoint, and therefore compatible,
  137. the channel layout of the output will be set accordingly and the channels
  138. will be reordered as necessary. If the channel layouts of the inputs are not
  139. disjoint, the output will have all the channels of the first input then all
  140. the channels of the second input, in that order, and the channel layout of
  141. the output will be the default value corresponding to the total number of
  142. channels.
  143. For example, if the first input is in 2.1 (FL+FR+LF) and the second input
  144. is FC+BL+BR, then the output will be in 5.1, with the channels in the
  145. following order: a1, a2, b1, a3, b2, b3 (a1 is the first channel of the
  146. first input, b1 is the first channel of the second input).
  147. On the other hand, if both input are in stereo, the output channels will be
  148. in the default order: a1, a2, b1, b2, and the channel layout will be
  149. arbitrarily set to 4.0, which may or may not be the expected value.
  150. All inputs must have the same sample rate, and format.
  151. If inputs do not have the same duration, the output will stop with the
  152. shortest.
  153. Example: merge two mono files into a stereo stream:
  154. @example
  155. amovie=left.wav [l] ; amovie=right.mp3 [r] ; [l] [r] amerge
  156. @end example
  157. Example: multiple merges:
  158. @example
  159. ffmpeg -f lavfi -i "
  160. amovie=input.mkv:si=0 [a0];
  161. amovie=input.mkv:si=1 [a1];
  162. amovie=input.mkv:si=2 [a2];
  163. amovie=input.mkv:si=3 [a3];
  164. amovie=input.mkv:si=4 [a4];
  165. amovie=input.mkv:si=5 [a5];
  166. [a0][a1][a2][a3][a4][a5] amerge=inputs=6" -c:a pcm_s16le output.mkv
  167. @end example
  168. @section amix
  169. Mixes multiple audio inputs into a single output.
  170. For example
  171. @example
  172. ffmpeg -i INPUT1 -i INPUT2 -i INPUT3 -filter_complex amix=inputs=3:duration=first:dropout_transition=3 OUTPUT
  173. @end example
  174. will mix 3 input audio streams to a single output with the same duration as the
  175. first input and a dropout transition time of 3 seconds.
  176. The filter accepts the following named parameters:
  177. @table @option
  178. @item inputs
  179. Number of inputs. If unspecified, it defaults to 2.
  180. @item duration
  181. How to determine the end-of-stream.
  182. @table @option
  183. @item longest
  184. Duration of longest input. (default)
  185. @item shortest
  186. Duration of shortest input.
  187. @item first
  188. Duration of first input.
  189. @end table
  190. @item dropout_transition
  191. Transition time, in seconds, for volume renormalization when an input
  192. stream ends. The default value is 2 seconds.
  193. @end table
  194. @section anull
  195. Pass the audio source unchanged to the output.
  196. @section aresample
  197. Resample the input audio to the specified sample rate.
  198. The filter accepts exactly one parameter, the output sample rate. If not
  199. specified then the filter will automatically convert between its input
  200. and output sample rates.
  201. For example, to resample the input audio to 44100Hz:
  202. @example
  203. aresample=44100
  204. @end example
  205. @section ashowinfo
  206. Show a line containing various information for each input audio frame.
  207. The input audio is not modified.
  208. The shown line contains a sequence of key/value pairs of the form
  209. @var{key}:@var{value}.
  210. A description of each shown parameter follows:
  211. @table @option
  212. @item n
  213. sequential number of the input frame, starting from 0
  214. @item pts
  215. presentation TimeStamp of the input frame, expressed as a number of
  216. time base units. The time base unit depends on the filter input pad, and
  217. is usually 1/@var{sample_rate}.
  218. @item pts_time
  219. presentation TimeStamp of the input frame, expressed as a number of
  220. seconds
  221. @item pos
  222. position of the frame in the input stream, -1 if this information in
  223. unavailable and/or meaningless (for example in case of synthetic audio)
  224. @item fmt
  225. sample format name
  226. @item chlayout
  227. channel layout description
  228. @item nb_samples
  229. number of samples (per each channel) contained in the filtered frame
  230. @item rate
  231. sample rate for the audio frame
  232. @item checksum
  233. Adler-32 checksum (printed in hexadecimal) of all the planes of the input frame
  234. @item plane_checksum
  235. Adler-32 checksum (printed in hexadecimal) for each input frame plane,
  236. expressed in the form "[@var{c0} @var{c1} @var{c2} @var{c3} @var{c4} @var{c5}
  237. @var{c6} @var{c7}]"
  238. @end table
  239. @section asplit
  240. Split input audio into several identical outputs.
  241. The filter accepts a single parameter which specifies the number of outputs. If
  242. unspecified, it defaults to 2.
  243. For example:
  244. @example
  245. [in] asplit [out0][out1]
  246. @end example
  247. will create two separate outputs from the same input.
  248. To create 3 or more outputs, you need to specify the number of
  249. outputs, like in:
  250. @example
  251. [in] asplit=3 [out0][out1][out2]
  252. @end example
  253. @example
  254. ffmpeg -i INPUT -filter_complex asplit=5 OUTPUT
  255. @end example
  256. will create 5 copies of the input audio.
  257. @section astreamsync
  258. Forward two audio streams and control the order the buffers are forwarded.
  259. The argument to the filter is an expression deciding which stream should be
  260. forwarded next: if the result is negative, the first stream is forwarded; if
  261. the result is positive or zero, the second stream is forwarded. It can use
  262. the following variables:
  263. @table @var
  264. @item b1 b2
  265. number of buffers forwarded so far on each stream
  266. @item s1 s2
  267. number of samples forwarded so far on each stream
  268. @item t1 t2
  269. current timestamp of each stream
  270. @end table
  271. The default value is @code{t1-t2}, which means to always forward the stream
  272. that has a smaller timestamp.
  273. Example: stress-test @code{amerge} by randomly sending buffers on the wrong
  274. input, while avoiding too much of a desynchronization:
  275. @example
  276. amovie=file.ogg [a] ; amovie=file.mp3 [b] ;
  277. [a] [b] astreamsync=(2*random(1))-1+tanh(5*(t1-t2)) [a2] [b2] ;
  278. [a2] [b2] amerge
  279. @end example
  280. @section earwax
  281. Make audio easier to listen to on headphones.
  282. This filter adds `cues' to 44.1kHz stereo (i.e. audio CD format) audio
  283. so that when listened to on headphones the stereo image is moved from
  284. inside your head (standard for headphones) to outside and in front of
  285. the listener (standard for speakers).
  286. Ported from SoX.
  287. @section pan
  288. Mix channels with specific gain levels. The filter accepts the output
  289. channel layout followed by a set of channels definitions.
  290. This filter is also designed to remap efficiently the channels of an audio
  291. stream.
  292. The filter accepts parameters of the form:
  293. "@var{l}:@var{outdef}:@var{outdef}:..."
  294. @table @option
  295. @item l
  296. output channel layout or number of channels
  297. @item outdef
  298. output channel specification, of the form:
  299. "@var{out_name}=[@var{gain}*]@var{in_name}[+[@var{gain}*]@var{in_name}...]"
  300. @item out_name
  301. output channel to define, either a channel name (FL, FR, etc.) or a channel
  302. number (c0, c1, etc.)
  303. @item gain
  304. multiplicative coefficient for the channel, 1 leaving the volume unchanged
  305. @item in_name
  306. input channel to use, see out_name for details; it is not possible to mix
  307. named and numbered input channels
  308. @end table
  309. If the `=' in a channel specification is replaced by `<', then the gains for
  310. that specification will be renormalized so that the total is 1, thus
  311. avoiding clipping noise.
  312. @subsection Mixing examples
  313. For example, if you want to down-mix from stereo to mono, but with a bigger
  314. factor for the left channel:
  315. @example
  316. pan=1:c0=0.9*c0+0.1*c1
  317. @end example
  318. A customized down-mix to stereo that works automatically for 3-, 4-, 5- and
  319. 7-channels surround:
  320. @example
  321. pan=stereo: FL < FL + 0.5*FC + 0.6*BL + 0.6*SL : FR < FR + 0.5*FC + 0.6*BR + 0.6*SR
  322. @end example
  323. Note that @command{ffmpeg} integrates a default down-mix (and up-mix) system
  324. that should be preferred (see "-ac" option) unless you have very specific
  325. needs.
  326. @subsection Remapping examples
  327. The channel remapping will be effective if, and only if:
  328. @itemize
  329. @item gain coefficients are zeroes or ones,
  330. @item only one input per channel output,
  331. @end itemize
  332. If all these conditions are satisfied, the filter will notify the user ("Pure
  333. channel mapping detected"), and use an optimized and lossless method to do the
  334. remapping.
  335. For example, if you have a 5.1 source and want a stereo audio stream by
  336. dropping the extra channels:
  337. @example
  338. pan="stereo: c0=FL : c1=FR"
  339. @end example
  340. Given the same source, you can also switch front left and front right channels
  341. and keep the input channel layout:
  342. @example
  343. pan="5.1: c0=c1 : c1=c0 : c2=c2 : c3=c3 : c4=c4 : c5=c5"
  344. @end example
  345. If the input is a stereo audio stream, you can mute the front left channel (and
  346. still keep the stereo channel layout) with:
  347. @example
  348. pan="stereo:c1=c1"
  349. @end example
  350. Still with a stereo audio stream input, you can copy the right channel in both
  351. front left and right:
  352. @example
  353. pan="stereo: c0=FR : c1=FR"
  354. @end example
  355. @section silencedetect
  356. Detect silence in an audio stream.
  357. This filter logs a message when it detects that the input audio volume is less
  358. or equal to a noise tolerance value for a duration greater or equal to the
  359. minimum detected noise duration.
  360. The printed times and duration are expressed in seconds.
  361. @table @option
  362. @item duration, d
  363. Set silence duration until notification (default is 2 seconds).
  364. @item noise, n
  365. Set noise tolerance. Can be specified in dB (in case "dB" is appended to the
  366. specified value) or amplitude ratio. Default is -60dB, or 0.001.
  367. @end table
  368. Detect 5 seconds of silence with -50dB noise tolerance:
  369. @example
  370. silencedetect=n=-50dB:d=5
  371. @end example
  372. Complete example with @command{ffmpeg} to detect silence with 0.0001 noise
  373. tolerance in @file{silence.mp3}:
  374. @example
  375. ffmpeg -f lavfi -i amovie=silence.mp3,silencedetect=noise=0.0001 -f null -
  376. @end example
  377. @section volume
  378. Adjust the input audio volume.
  379. The filter accepts exactly one parameter @var{vol}, which expresses
  380. how the audio volume will be increased or decreased.
  381. Output values are clipped to the maximum value.
  382. If @var{vol} is expressed as a decimal number, the output audio
  383. volume is given by the relation:
  384. @example
  385. @var{output_volume} = @var{vol} * @var{input_volume}
  386. @end example
  387. If @var{vol} is expressed as a decimal number followed by the string
  388. "dB", the value represents the requested change in decibels of the
  389. input audio power, and the output audio volume is given by the
  390. relation:
  391. @example
  392. @var{output_volume} = 10^(@var{vol}/20) * @var{input_volume}
  393. @end example
  394. Otherwise @var{vol} is considered an expression and its evaluated
  395. value is used for computing the output audio volume according to the
  396. first relation.
  397. Default value for @var{vol} is 1.0.
  398. @subsection Examples
  399. @itemize
  400. @item
  401. Half the input audio volume:
  402. @example
  403. volume=0.5
  404. @end example
  405. The above example is equivalent to:
  406. @example
  407. volume=1/2
  408. @end example
  409. @item
  410. Decrease input audio power by 12 decibels:
  411. @example
  412. volume=-12dB
  413. @end example
  414. @end itemize
  415. @section asyncts
  416. Synchronize audio data with timestamps by squeezing/stretching it and/or
  417. dropping samples/adding silence when needed.
  418. The filter accepts the following named parameters:
  419. @table @option
  420. @item compensate
  421. Enable stretching/squeezing the data to make it match the timestamps.
  422. @item min_delta
  423. Minimum difference between timestamps and audio data (in seconds) to trigger
  424. adding/dropping samples.
  425. @item max_comp
  426. Maximum compensation in samples per second.
  427. @end table
  428. @section channelsplit
  429. Split each channel in input audio stream into a separate output stream.
  430. This filter accepts the following named parameters:
  431. @table @option
  432. @item channel_layout
  433. Channel layout of the input stream. Default is "stereo".
  434. @end table
  435. For example, assuming a stereo input MP3 file
  436. @example
  437. ffmpeg -i in.mp3 -filter_complex channelsplit out.mkv
  438. @end example
  439. will create an output Matroska file with two audio streams, one containing only
  440. the left channel and the other the right channel.
  441. To split a 5.1 WAV file into per-channel files
  442. @example
  443. ffmpeg -i in.wav -filter_complex
  444. 'channelsplit=channel_layout=5.1[FL][FR][FC][LFE][SL][SR]'
  445. -map '[FL]' front_left.wav -map '[FR]' front_right.wav -map '[FC]'
  446. front_center.wav -map '[LFE]' lfe.wav -map '[SL]' side_left.wav -map '[SR]'
  447. side_right.wav
  448. @end example
  449. @section resample
  450. Convert the audio sample format, sample rate and channel layout. This filter is
  451. not meant to be used directly.
  452. @c man end AUDIO FILTERS
  453. @chapter Audio Sources
  454. @c man begin AUDIO SOURCES
  455. Below is a description of the currently available audio sources.
  456. @section abuffer
  457. Buffer audio frames, and make them available to the filter chain.
  458. This source is mainly intended for a programmatic use, in particular
  459. through the interface defined in @file{libavfilter/asrc_abuffer.h}.
  460. It accepts the following mandatory parameters:
  461. @var{sample_rate}:@var{sample_fmt}:@var{channel_layout}
  462. @table @option
  463. @item sample_rate
  464. The sample rate of the incoming audio buffers.
  465. @item sample_fmt
  466. The sample format of the incoming audio buffers.
  467. Either a sample format name or its corresponging integer representation from
  468. the enum AVSampleFormat in @file{libavutil/samplefmt.h}
  469. @item channel_layout
  470. The channel layout of the incoming audio buffers.
  471. Either a channel layout name from channel_layout_map in
  472. @file{libavutil/audioconvert.c} or its corresponding integer representation
  473. from the AV_CH_LAYOUT_* macros in @file{libavutil/audioconvert.h}
  474. @end table
  475. For example:
  476. @example
  477. abuffer=44100:s16p:stereo
  478. @end example
  479. will instruct the source to accept planar 16bit signed stereo at 44100Hz.
  480. Since the sample format with name "s16p" corresponds to the number
  481. 6 and the "stereo" channel layout corresponds to the value 0x3, this is
  482. equivalent to:
  483. @example
  484. abuffer=44100:6:0x3
  485. @end example
  486. @section aevalsrc
  487. Generate an audio signal specified by an expression.
  488. This source accepts in input one or more expressions (one for each
  489. channel), which are evaluated and used to generate a corresponding
  490. audio signal.
  491. It accepts the syntax: @var{exprs}[::@var{options}].
  492. @var{exprs} is a list of expressions separated by ":", one for each
  493. separate channel. In case the @var{channel_layout} is not
  494. specified, the selected channel layout depends on the number of
  495. provided expressions.
  496. @var{options} is an optional sequence of @var{key}=@var{value} pairs,
  497. separated by ":".
  498. The description of the accepted options follows.
  499. @table @option
  500. @item channel_layout, c
  501. Set the channel layout. The number of channels in the specified layout
  502. must be equal to the number of specified expressions.
  503. @item duration, d
  504. Set the minimum duration of the sourced audio. See the function
  505. @code{av_parse_time()} for the accepted format.
  506. Note that the resulting duration may be greater than the specified
  507. duration, as the generated audio is always cut at the end of a
  508. complete frame.
  509. If not specified, or the expressed duration is negative, the audio is
  510. supposed to be generated forever.
  511. @item nb_samples, n
  512. Set the number of samples per channel per each output frame,
  513. default to 1024.
  514. @item sample_rate, s
  515. Specify the sample rate, default to 44100.
  516. @end table
  517. Each expression in @var{exprs} can contain the following constants:
  518. @table @option
  519. @item n
  520. number of the evaluated sample, starting from 0
  521. @item t
  522. time of the evaluated sample expressed in seconds, starting from 0
  523. @item s
  524. sample rate
  525. @end table
  526. @subsection Examples
  527. @itemize
  528. @item
  529. Generate silence:
  530. @example
  531. aevalsrc=0
  532. @end example
  533. @item
  534. Generate a sin signal with frequency of 440 Hz, set sample rate to
  535. 8000 Hz:
  536. @example
  537. aevalsrc="sin(440*2*PI*t)::s=8000"
  538. @end example
  539. @item
  540. Generate a two channels signal, specify the channel layout (Front
  541. Center + Back Center) explicitly:
  542. @example
  543. aevalsrc="sin(420*2*PI*t):cos(430*2*PI*t)::c=FC|BC"
  544. @end example
  545. @item
  546. Generate white noise:
  547. @example
  548. aevalsrc="-2+random(0)"
  549. @end example
  550. @item
  551. Generate an amplitude modulated signal:
  552. @example
  553. aevalsrc="sin(10*2*PI*t)*sin(880*2*PI*t)"
  554. @end example
  555. @item
  556. Generate 2.5 Hz binaural beats on a 360 Hz carrier:
  557. @example
  558. aevalsrc="0.1*sin(2*PI*(360-2.5/2)*t) : 0.1*sin(2*PI*(360+2.5/2)*t)"
  559. @end example
  560. @end itemize
  561. @section amovie
  562. Read an audio stream from a movie container.
  563. It accepts the syntax: @var{movie_name}[:@var{options}] where
  564. @var{movie_name} is the name of the resource to read (not necessarily
  565. a file but also a device or a stream accessed through some protocol),
  566. and @var{options} is an optional sequence of @var{key}=@var{value}
  567. pairs, separated by ":".
  568. The description of the accepted options follows.
  569. @table @option
  570. @item format_name, f
  571. Specify the format assumed for the movie to read, and can be either
  572. the name of a container or an input device. If not specified the
  573. format is guessed from @var{movie_name} or by probing.
  574. @item seek_point, sp
  575. Specify the seek point in seconds, the frames will be output
  576. starting from this seek point, the parameter is evaluated with
  577. @code{av_strtod} so the numerical value may be suffixed by an IS
  578. postfix. Default value is "0".
  579. @item stream_index, si
  580. Specify the index of the audio stream to read. If the value is -1,
  581. the best suited audio stream will be automatically selected. Default
  582. value is "-1".
  583. @end table
  584. @section anullsrc
  585. Null audio source, return unprocessed audio frames. It is mainly useful
  586. as a template and to be employed in analysis / debugging tools, or as
  587. the source for filters which ignore the input data (for example the sox
  588. synth filter).
  589. It accepts an optional sequence of @var{key}=@var{value} pairs,
  590. separated by ":".
  591. The description of the accepted options follows.
  592. @table @option
  593. @item sample_rate, s
  594. Specify the sample rate, and defaults to 44100.
  595. @item channel_layout, cl
  596. Specify the channel layout, and can be either an integer or a string
  597. representing a channel layout. The default value of @var{channel_layout}
  598. is "stereo".
  599. Check the channel_layout_map definition in
  600. @file{libavcodec/audioconvert.c} for the mapping between strings and
  601. channel layout values.
  602. @item nb_samples, n
  603. Set the number of samples per requested frames.
  604. @end table
  605. Follow some examples:
  606. @example
  607. # set the sample rate to 48000 Hz and the channel layout to AV_CH_LAYOUT_MONO.
  608. anullsrc=r=48000:cl=4
  609. # same as
  610. anullsrc=r=48000:cl=mono
  611. @end example
  612. @section abuffer
  613. Buffer audio frames, and make them available to the filter chain.
  614. This source is not intended to be part of user-supplied graph descriptions but
  615. for insertion by calling programs through the interface defined in
  616. @file{libavfilter/buffersrc.h}.
  617. It accepts the following named parameters:
  618. @table @option
  619. @item time_base
  620. Timebase which will be used for timestamps of submitted frames. It must be
  621. either a floating-point number or in @var{numerator}/@var{denominator} form.
  622. @item sample_rate
  623. Audio sample rate.
  624. @item sample_fmt
  625. Name of the sample format, as returned by @code{av_get_sample_fmt_name()}.
  626. @item channel_layout
  627. Channel layout of the audio data, in the form that can be accepted by
  628. @code{av_get_channel_layout()}.
  629. @end table
  630. All the parameters need to be explicitly defined.
  631. @c man end AUDIO SOURCES
  632. @chapter Audio Sinks
  633. @c man begin AUDIO SINKS
  634. Below is a description of the currently available audio sinks.
  635. @section abuffersink
  636. Buffer audio frames, and make them available to the end of filter chain.
  637. This sink is mainly intended for programmatic use, in particular
  638. through the interface defined in @file{libavfilter/buffersink.h}.
  639. It requires a pointer to an AVABufferSinkContext structure, which
  640. defines the incoming buffers' formats, to be passed as the opaque
  641. parameter to @code{avfilter_init_filter} for initialization.
  642. @section anullsink
  643. Null audio sink, do absolutely nothing with the input audio. It is
  644. mainly useful as a template and to be employed in analysis / debugging
  645. tools.
  646. @section abuffersink
  647. This sink is intended for programmatic use. Frames that arrive on this sink can
  648. be retrieved by the calling program using the interface defined in
  649. @file{libavfilter/buffersink.h}.
  650. This filter accepts no parameters.
  651. @c man end AUDIO SINKS
  652. @chapter Video Filters
  653. @c man begin VIDEO FILTERS
  654. When you configure your FFmpeg build, you can disable any of the
  655. existing filters using @code{--disable-filters}.
  656. The configure output will show the video filters included in your
  657. build.
  658. Below is a description of the currently available video filters.
  659. @section ass
  660. Draw ASS (Advanced Substation Alpha) subtitles on top of input video
  661. using the libass library.
  662. To enable compilation of this filter you need to configure FFmpeg with
  663. @code{--enable-libass}.
  664. This filter accepts the syntax: @var{ass_filename}[:@var{options}],
  665. where @var{ass_filename} is the filename of the ASS file to read, and
  666. @var{options} is an optional sequence of @var{key}=@var{value} pairs,
  667. separated by ":".
  668. A description of the accepted options follows.
  669. @table @option
  670. @item original_size
  671. Specifies the size of the original video, the video for which the ASS file
  672. was composed. Due to a misdesign in ASS aspect ratio arithmetic, this is
  673. necessary to correctly scale the fonts if the aspect ratio has been changed.
  674. @end table
  675. For example, to render the file @file{sub.ass} on top of the input
  676. video, use the command:
  677. @example
  678. ass=sub.ass
  679. @end example
  680. @section bbox
  681. Compute the bounding box for the non-black pixels in the input frame
  682. luminance plane.
  683. This filter computes the bounding box containing all the pixels with a
  684. luminance value greater than the minimum allowed value.
  685. The parameters describing the bounding box are printed on the filter
  686. log.
  687. @section blackdetect
  688. Detect video intervals that are (almost) completely black. Can be
  689. useful to detect chapter transitions, commercials, or invalid
  690. recordings. Output lines contains the time for the start, end and
  691. duration of the detected black interval expressed in seconds.
  692. In order to display the output lines, you need to set the loglevel at
  693. least to the AV_LOG_INFO value.
  694. This filter accepts a list of options in the form of
  695. @var{key}=@var{value} pairs separated by ":". A description of the
  696. accepted options follows.
  697. @table @option
  698. @item black_min_duration, d
  699. Set the minimum detected black duration expressed in seconds. It must
  700. be a non-negative floating point number.
  701. Default value is 2.0.
  702. @item picture_black_ratio_th, pic_th
  703. Set the threshold for considering a picture "black".
  704. Express the minimum value for the ratio:
  705. @example
  706. @var{nb_black_pixels} / @var{nb_pixels}
  707. @end example
  708. for which a picture is considered black.
  709. Default value is 0.98.
  710. @item pixel_black_th, pix_th
  711. Set the threshold for considering a pixel "black".
  712. The threshold expresses the maximum pixel luminance value for which a
  713. pixel is considered "black". The provided value is scaled according to
  714. the following equation:
  715. @example
  716. @var{absolute_threshold} = @var{luminance_minimum_value} + @var{pixel_black_th} * @var{luminance_range_size}
  717. @end example
  718. @var{luminance_range_size} and @var{luminance_minimum_value} depend on
  719. the input video format, the range is [0-255] for YUV full-range
  720. formats and [16-235] for YUV non full-range formats.
  721. Default value is 0.10.
  722. @end table
  723. The following example sets the maximum pixel threshold to the minimum
  724. value, and detects only black intervals of 2 or more seconds:
  725. @example
  726. blackdetect=d=2:pix_th=0.00
  727. @end example
  728. @section blackframe
  729. Detect frames that are (almost) completely black. Can be useful to
  730. detect chapter transitions or commercials. Output lines consist of
  731. the frame number of the detected frame, the percentage of blackness,
  732. the position in the file if known or -1 and the timestamp in seconds.
  733. In order to display the output lines, you need to set the loglevel at
  734. least to the AV_LOG_INFO value.
  735. The filter accepts the syntax:
  736. @example
  737. blackframe[=@var{amount}:[@var{threshold}]]
  738. @end example
  739. @var{amount} is the percentage of the pixels that have to be below the
  740. threshold, and defaults to 98.
  741. @var{threshold} is the threshold below which a pixel value is
  742. considered black, and defaults to 32.
  743. @section boxblur
  744. Apply boxblur algorithm to the input video.
  745. This filter accepts the parameters:
  746. @var{luma_radius}:@var{luma_power}:@var{chroma_radius}:@var{chroma_power}:@var{alpha_radius}:@var{alpha_power}
  747. Chroma and alpha parameters are optional, if not specified they default
  748. to the corresponding values set for @var{luma_radius} and
  749. @var{luma_power}.
  750. @var{luma_radius}, @var{chroma_radius}, and @var{alpha_radius} represent
  751. the radius in pixels of the box used for blurring the corresponding
  752. input plane. They are expressions, and can contain the following
  753. constants:
  754. @table @option
  755. @item w, h
  756. the input width and height in pixels
  757. @item cw, ch
  758. the input chroma image width and height in pixels
  759. @item hsub, vsub
  760. horizontal and vertical chroma subsample values. For example for the
  761. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  762. @end table
  763. The radius must be a non-negative number, and must not be greater than
  764. the value of the expression @code{min(w,h)/2} for the luma and alpha planes,
  765. and of @code{min(cw,ch)/2} for the chroma planes.
  766. @var{luma_power}, @var{chroma_power}, and @var{alpha_power} represent
  767. how many times the boxblur filter is applied to the corresponding
  768. plane.
  769. Some examples follow:
  770. @itemize
  771. @item
  772. Apply a boxblur filter with luma, chroma, and alpha radius
  773. set to 2:
  774. @example
  775. boxblur=2:1
  776. @end example
  777. @item
  778. Set luma radius to 2, alpha and chroma radius to 0
  779. @example
  780. boxblur=2:1:0:0:0:0
  781. @end example
  782. @item
  783. Set luma and chroma radius to a fraction of the video dimension
  784. @example
  785. boxblur=min(h\,w)/10:1:min(cw\,ch)/10:1
  786. @end example
  787. @end itemize
  788. @section colormatrix
  789. The colormatrix filter allows conversion between any of the following color
  790. space: BT.709 (@var{bt709}), BT.601 (@var{bt601}), SMPTE-240M (@var{smpte240m})
  791. and FCC (@var{fcc}).
  792. The syntax of the parameters is @var{source}:@var{destination}:
  793. @example
  794. colormatrix=bt601:smpte240m
  795. @end example
  796. @section copy
  797. Copy the input source unchanged to the output. Mainly useful for
  798. testing purposes.
  799. @section crop
  800. Crop the input video to @var{out_w}:@var{out_h}:@var{x}:@var{y}:@var{keep_aspect}
  801. The @var{keep_aspect} parameter is optional, if specified and set to a
  802. non-zero value will force the output display aspect ratio to be the
  803. same of the input, by changing the output sample aspect ratio.
  804. The @var{out_w}, @var{out_h}, @var{x}, @var{y} parameters are
  805. expressions containing the following constants:
  806. @table @option
  807. @item x, y
  808. the computed values for @var{x} and @var{y}. They are evaluated for
  809. each new frame.
  810. @item in_w, in_h
  811. the input width and height
  812. @item iw, ih
  813. same as @var{in_w} and @var{in_h}
  814. @item out_w, out_h
  815. the output (cropped) width and height
  816. @item ow, oh
  817. same as @var{out_w} and @var{out_h}
  818. @item a
  819. same as @var{iw} / @var{ih}
  820. @item sar
  821. input sample aspect ratio
  822. @item dar
  823. input display aspect ratio, it is the same as (@var{iw} / @var{ih}) * @var{sar}
  824. @item hsub, vsub
  825. horizontal and vertical chroma subsample values. For example for the
  826. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  827. @item n
  828. the number of input frame, starting from 0
  829. @item pos
  830. the position in the file of the input frame, NAN if unknown
  831. @item t
  832. timestamp expressed in seconds, NAN if the input timestamp is unknown
  833. @end table
  834. The @var{out_w} and @var{out_h} parameters specify the expressions for
  835. the width and height of the output (cropped) video. They are
  836. evaluated just at the configuration of the filter.
  837. The default value of @var{out_w} is "in_w", and the default value of
  838. @var{out_h} is "in_h".
  839. The expression for @var{out_w} may depend on the value of @var{out_h},
  840. and the expression for @var{out_h} may depend on @var{out_w}, but they
  841. cannot depend on @var{x} and @var{y}, as @var{x} and @var{y} are
  842. evaluated after @var{out_w} and @var{out_h}.
  843. The @var{x} and @var{y} parameters specify the expressions for the
  844. position of the top-left corner of the output (non-cropped) area. They
  845. are evaluated for each frame. If the evaluated value is not valid, it
  846. is approximated to the nearest valid value.
  847. The default value of @var{x} is "(in_w-out_w)/2", and the default
  848. value for @var{y} is "(in_h-out_h)/2", which set the cropped area at
  849. the center of the input image.
  850. The expression for @var{x} may depend on @var{y}, and the expression
  851. for @var{y} may depend on @var{x}.
  852. Follow some examples:
  853. @example
  854. # crop the central input area with size 100x100
  855. crop=100:100
  856. # crop the central input area with size 2/3 of the input video
  857. "crop=2/3*in_w:2/3*in_h"
  858. # crop the input video central square
  859. crop=in_h
  860. # delimit the rectangle with the top-left corner placed at position
  861. # 100:100 and the right-bottom corner corresponding to the right-bottom
  862. # corner of the input image.
  863. crop=in_w-100:in_h-100:100:100
  864. # crop 10 pixels from the left and right borders, and 20 pixels from
  865. # the top and bottom borders
  866. "crop=in_w-2*10:in_h-2*20"
  867. # keep only the bottom right quarter of the input image
  868. "crop=in_w/2:in_h/2:in_w/2:in_h/2"
  869. # crop height for getting Greek harmony
  870. "crop=in_w:1/PHI*in_w"
  871. # trembling effect
  872. "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)"
  873. # erratic camera effect depending on timestamp
  874. "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)"
  875. # set x depending on the value of y
  876. "crop=in_w/2:in_h/2:y:10+10*sin(n/10)"
  877. @end example
  878. @section cropdetect
  879. Auto-detect crop size.
  880. Calculate necessary cropping parameters and prints the recommended
  881. parameters through the logging system. The detected dimensions
  882. correspond to the non-black area of the input video.
  883. It accepts the syntax:
  884. @example
  885. cropdetect[=@var{limit}[:@var{round}[:@var{reset}]]]
  886. @end example
  887. @table @option
  888. @item limit
  889. Threshold, which can be optionally specified from nothing (0) to
  890. everything (255), defaults to 24.
  891. @item round
  892. Value which the width/height should be divisible by, defaults to
  893. 16. The offset is automatically adjusted to center the video. Use 2 to
  894. get only even dimensions (needed for 4:2:2 video). 16 is best when
  895. encoding to most video codecs.
  896. @item reset
  897. Counter that determines after how many frames cropdetect will reset
  898. the previously detected largest video area and start over to detect
  899. the current optimal crop area. Defaults to 0.
  900. This can be useful when channel logos distort the video area. 0
  901. indicates never reset and return the largest area encountered during
  902. playback.
  903. @end table
  904. @section delogo
  905. Suppress a TV station logo by a simple interpolation of the surrounding
  906. pixels. Just set a rectangle covering the logo and watch it disappear
  907. (and sometimes something even uglier appear - your mileage may vary).
  908. The filter accepts parameters as a string of the form
  909. "@var{x}:@var{y}:@var{w}:@var{h}:@var{band}", or as a list of
  910. @var{key}=@var{value} pairs, separated by ":".
  911. The description of the accepted parameters follows.
  912. @table @option
  913. @item x, y
  914. Specify the top left corner coordinates of the logo. They must be
  915. specified.
  916. @item w, h
  917. Specify the width and height of the logo to clear. They must be
  918. specified.
  919. @item band, t
  920. Specify the thickness of the fuzzy edge of the rectangle (added to
  921. @var{w} and @var{h}). The default value is 4.
  922. @item show
  923. When set to 1, a green rectangle is drawn on the screen to simplify
  924. finding the right @var{x}, @var{y}, @var{w}, @var{h} parameters, and
  925. @var{band} is set to 4. The default value is 0.
  926. @end table
  927. Some examples follow.
  928. @itemize
  929. @item
  930. Set a rectangle covering the area with top left corner coordinates 0,0
  931. and size 100x77, setting a band of size 10:
  932. @example
  933. delogo=0:0:100:77:10
  934. @end example
  935. @item
  936. As the previous example, but use named options:
  937. @example
  938. delogo=x=0:y=0:w=100:h=77:band=10
  939. @end example
  940. @end itemize
  941. @section deshake
  942. Attempt to fix small changes in horizontal and/or vertical shift. This
  943. filter helps remove camera shake from hand-holding a camera, bumping a
  944. tripod, moving on a vehicle, etc.
  945. The filter accepts parameters as a string of the form
  946. "@var{x}:@var{y}:@var{w}:@var{h}:@var{rx}:@var{ry}:@var{edge}:@var{blocksize}:@var{contrast}:@var{search}:@var{filename}"
  947. A description of the accepted parameters follows.
  948. @table @option
  949. @item x, y, w, h
  950. Specify a rectangular area where to limit the search for motion
  951. vectors.
  952. If desired the search for motion vectors can be limited to a
  953. rectangular area of the frame defined by its top left corner, width
  954. and height. These parameters have the same meaning as the drawbox
  955. filter which can be used to visualise the position of the bounding
  956. box.
  957. This is useful when simultaneous movement of subjects within the frame
  958. might be confused for camera motion by the motion vector search.
  959. If any or all of @var{x}, @var{y}, @var{w} and @var{h} are set to -1
  960. then the full frame is used. This allows later options to be set
  961. without specifying the bounding box for the motion vector search.
  962. Default - search the whole frame.
  963. @item rx, ry
  964. Specify the maximum extent of movement in x and y directions in the
  965. range 0-64 pixels. Default 16.
  966. @item edge
  967. Specify how to generate pixels to fill blanks at the edge of the
  968. frame. An integer from 0 to 3 as follows:
  969. @table @option
  970. @item 0
  971. Fill zeroes at blank locations
  972. @item 1
  973. Original image at blank locations
  974. @item 2
  975. Extruded edge value at blank locations
  976. @item 3
  977. Mirrored edge at blank locations
  978. @end table
  979. The default setting is mirror edge at blank locations.
  980. @item blocksize
  981. Specify the blocksize to use for motion search. Range 4-128 pixels,
  982. default 8.
  983. @item contrast
  984. Specify the contrast threshold for blocks. Only blocks with more than
  985. the specified contrast (difference between darkest and lightest
  986. pixels) will be considered. Range 1-255, default 125.
  987. @item search
  988. Specify the search strategy 0 = exhaustive search, 1 = less exhaustive
  989. search. Default - exhaustive search.
  990. @item filename
  991. If set then a detailed log of the motion search is written to the
  992. specified file.
  993. @end table
  994. @section drawbox
  995. Draw a colored box on the input image.
  996. It accepts the syntax:
  997. @example
  998. drawbox=@var{x}:@var{y}:@var{width}:@var{height}:@var{color}
  999. @end example
  1000. @table @option
  1001. @item x, y
  1002. Specify the top left corner coordinates of the box. Default to 0.
  1003. @item width, height
  1004. Specify the width and height of the box, if 0 they are interpreted as
  1005. the input width and height. Default to 0.
  1006. @item color
  1007. Specify the color of the box to write, it can be the name of a color
  1008. (case insensitive match) or a 0xRRGGBB[AA] sequence.
  1009. @end table
  1010. Follow some examples:
  1011. @example
  1012. # draw a black box around the edge of the input image
  1013. drawbox
  1014. # draw a box with color red and an opacity of 50%
  1015. drawbox=10:20:200:60:red@@0.5"
  1016. @end example
  1017. @section drawtext
  1018. Draw text string or text from specified file on top of video using the
  1019. libfreetype library.
  1020. To enable compilation of this filter you need to configure FFmpeg with
  1021. @code{--enable-libfreetype}.
  1022. The filter also recognizes strftime() sequences in the provided text
  1023. and expands them accordingly. Check the documentation of strftime().
  1024. The filter accepts parameters as a list of @var{key}=@var{value} pairs,
  1025. separated by ":".
  1026. The description of the accepted parameters follows.
  1027. @table @option
  1028. @item box
  1029. Used to draw a box around text using background color.
  1030. Value should be either 1 (enable) or 0 (disable).
  1031. The default value of @var{box} is 0.
  1032. @item boxcolor
  1033. The color to be used for drawing box around text.
  1034. Either a string (e.g. "yellow") or in 0xRRGGBB[AA] format
  1035. (e.g. "0xff00ff"), possibly followed by an alpha specifier.
  1036. The default value of @var{boxcolor} is "white".
  1037. @item draw
  1038. Set an expression which specifies if the text should be drawn. If the
  1039. expression evaluates to 0, the text is not drawn. This is useful for
  1040. specifying that the text should be drawn only when specific conditions
  1041. are met.
  1042. Default value is "1".
  1043. See below for the list of accepted constants and functions.
  1044. @item fix_bounds
  1045. If true, check and fix text coords to avoid clipping.
  1046. @item fontcolor
  1047. The color to be used for drawing fonts.
  1048. Either a string (e.g. "red") or in 0xRRGGBB[AA] format
  1049. (e.g. "0xff000033"), possibly followed by an alpha specifier.
  1050. The default value of @var{fontcolor} is "black".
  1051. @item fontfile
  1052. The font file to be used for drawing text. Path must be included.
  1053. This parameter is mandatory.
  1054. @item fontsize
  1055. The font size to be used for drawing text.
  1056. The default value of @var{fontsize} is 16.
  1057. @item ft_load_flags
  1058. Flags to be used for loading the fonts.
  1059. The flags map the corresponding flags supported by libfreetype, and are
  1060. a combination of the following values:
  1061. @table @var
  1062. @item default
  1063. @item no_scale
  1064. @item no_hinting
  1065. @item render
  1066. @item no_bitmap
  1067. @item vertical_layout
  1068. @item force_autohint
  1069. @item crop_bitmap
  1070. @item pedantic
  1071. @item ignore_global_advance_width
  1072. @item no_recurse
  1073. @item ignore_transform
  1074. @item monochrome
  1075. @item linear_design
  1076. @item no_autohint
  1077. @item end table
  1078. @end table
  1079. Default value is "render".
  1080. For more information consult the documentation for the FT_LOAD_*
  1081. libfreetype flags.
  1082. @item shadowcolor
  1083. The color to be used for drawing a shadow behind the drawn text. It
  1084. can be a color name (e.g. "yellow") or a string in the 0xRRGGBB[AA]
  1085. form (e.g. "0xff00ff"), possibly followed by an alpha specifier.
  1086. The default value of @var{shadowcolor} is "black".
  1087. @item shadowx, shadowy
  1088. The x and y offsets for the text shadow position with respect to the
  1089. position of the text. They can be either positive or negative
  1090. values. Default value for both is "0".
  1091. @item tabsize
  1092. The size in number of spaces to use for rendering the tab.
  1093. Default value is 4.
  1094. @item timecode
  1095. Set the initial timecode representation in "hh:mm:ss[:;.]ff"
  1096. format. It can be used with or without text parameter. @var{timecode_rate}
  1097. option must be specified.
  1098. @item timecode_rate, rate, r
  1099. Set the timecode frame rate (timecode only).
  1100. @item text
  1101. The text string to be drawn. The text must be a sequence of UTF-8
  1102. encoded characters.
  1103. This parameter is mandatory if no file is specified with the parameter
  1104. @var{textfile}.
  1105. @item textfile
  1106. A text file containing text to be drawn. The text must be a sequence
  1107. of UTF-8 encoded characters.
  1108. This parameter is mandatory if no text string is specified with the
  1109. parameter @var{text}.
  1110. If both @var{text} and @var{textfile} are specified, an error is thrown.
  1111. @item x, y
  1112. The expressions which specify the offsets where text will be drawn
  1113. within the video frame. They are relative to the top/left border of the
  1114. output image.
  1115. The default value of @var{x} and @var{y} is "0".
  1116. See below for the list of accepted constants and functions.
  1117. @end table
  1118. The parameters for @var{x} and @var{y} are expressions containing the
  1119. following constants and functions:
  1120. @table @option
  1121. @item dar
  1122. input display aspect ratio, it is the same as (@var{w} / @var{h}) * @var{sar}
  1123. @item hsub, vsub
  1124. horizontal and vertical chroma subsample values. For example for the
  1125. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  1126. @item line_h, lh
  1127. the height of each text line
  1128. @item main_h, h, H
  1129. the input height
  1130. @item main_w, w, W
  1131. the input width
  1132. @item max_glyph_a, ascent
  1133. the maximum distance from the baseline to the highest/upper grid
  1134. coordinate used to place a glyph outline point, for all the rendered
  1135. glyphs.
  1136. It is a positive value, due to the grid's orientation with the Y axis
  1137. upwards.
  1138. @item max_glyph_d, descent
  1139. the maximum distance from the baseline to the lowest grid coordinate
  1140. used to place a glyph outline point, for all the rendered glyphs.
  1141. This is a negative value, due to the grid's orientation, with the Y axis
  1142. upwards.
  1143. @item max_glyph_h
  1144. maximum glyph height, that is the maximum height for all the glyphs
  1145. contained in the rendered text, it is equivalent to @var{ascent} -
  1146. @var{descent}.
  1147. @item max_glyph_w
  1148. maximum glyph width, that is the maximum width for all the glyphs
  1149. contained in the rendered text
  1150. @item n
  1151. the number of input frame, starting from 0
  1152. @item rand(min, max)
  1153. return a random number included between @var{min} and @var{max}
  1154. @item sar
  1155. input sample aspect ratio
  1156. @item t
  1157. timestamp expressed in seconds, NAN if the input timestamp is unknown
  1158. @item text_h, th
  1159. the height of the rendered text
  1160. @item text_w, tw
  1161. the width of the rendered text
  1162. @item x, y
  1163. the x and y offset coordinates where the text is drawn.
  1164. These parameters allow the @var{x} and @var{y} expressions to refer
  1165. each other, so you can for example specify @code{y=x/dar}.
  1166. @end table
  1167. If libavfilter was built with @code{--enable-fontconfig}, then
  1168. @option{fontfile} can be a fontconfig pattern or omitted.
  1169. Some examples follow.
  1170. @itemize
  1171. @item
  1172. Draw "Test Text" with font FreeSerif, using the default values for the
  1173. optional parameters.
  1174. @example
  1175. drawtext="fontfile=/usr/share/fonts/truetype/freefont/FreeSerif.ttf: text='Test Text'"
  1176. @end example
  1177. @item
  1178. Draw 'Test Text' with font FreeSerif of size 24 at position x=100
  1179. and y=50 (counting from the top-left corner of the screen), text is
  1180. yellow with a red box around it. Both the text and the box have an
  1181. opacity of 20%.
  1182. @example
  1183. drawtext="fontfile=/usr/share/fonts/truetype/freefont/FreeSerif.ttf: text='Test Text':\
  1184. x=100: y=50: fontsize=24: fontcolor=yellow@@0.2: box=1: boxcolor=red@@0.2"
  1185. @end example
  1186. Note that the double quotes are not necessary if spaces are not used
  1187. within the parameter list.
  1188. @item
  1189. Show the text at the center of the video frame:
  1190. @example
  1191. drawtext="fontsize=30:fontfile=FreeSerif.ttf:text='hello world':x=(w-text_w)/2:y=(h-text_h-line_h)/2"
  1192. @end example
  1193. @item
  1194. Show a text line sliding from right to left in the last row of the video
  1195. frame. The file @file{LONG_LINE} is assumed to contain a single line
  1196. with no newlines.
  1197. @example
  1198. drawtext="fontsize=15:fontfile=FreeSerif.ttf:text=LONG_LINE:y=h-line_h:x=-50*t"
  1199. @end example
  1200. @item
  1201. Show the content of file @file{CREDITS} off the bottom of the frame and scroll up.
  1202. @example
  1203. drawtext="fontsize=20:fontfile=FreeSerif.ttf:textfile=CREDITS:y=h-20*t"
  1204. @end example
  1205. @item
  1206. Draw a single green letter "g", at the center of the input video.
  1207. The glyph baseline is placed at half screen height.
  1208. @example
  1209. drawtext="fontsize=60:fontfile=FreeSerif.ttf:fontcolor=green:text=g:x=(w-max_glyph_w)/2:y=h/2-ascent"
  1210. @end example
  1211. @item
  1212. Show text for 1 second every 3 seconds:
  1213. @example
  1214. drawtext="fontfile=FreeSerif.ttf:fontcolor=white:x=100:y=x/dar:draw=lt(mod(t\\,3)\\,1):text='blink'"
  1215. @end example
  1216. @item
  1217. Use fontconfig to set the font. Note that the colons need to be escaped.
  1218. @example
  1219. drawtext='fontfile=Linux Libertine O-40\\:style=Semibold:text=FFmpeg'
  1220. @end example
  1221. @end itemize
  1222. For more information about libfreetype, check:
  1223. @url{http://www.freetype.org/}.
  1224. For more information about fontconfig, check:
  1225. @url{http://freedesktop.org/software/fontconfig/fontconfig-user.html}.
  1226. @section fade
  1227. Apply fade-in/out effect to input video.
  1228. It accepts the parameters:
  1229. @var{type}:@var{start_frame}:@var{nb_frames}[:@var{options}]
  1230. @var{type} specifies if the effect type, can be either "in" for
  1231. fade-in, or "out" for a fade-out effect.
  1232. @var{start_frame} specifies the number of the start frame for starting
  1233. to apply the fade effect.
  1234. @var{nb_frames} specifies the number of frames for which the fade
  1235. effect has to last. At the end of the fade-in effect the output video
  1236. will have the same intensity as the input video, at the end of the
  1237. fade-out transition the output video will be completely black.
  1238. @var{options} is an optional sequence of @var{key}=@var{value} pairs,
  1239. separated by ":". The description of the accepted options follows.
  1240. @table @option
  1241. @item type, t
  1242. See @var{type}.
  1243. @item start_frame, s
  1244. See @var{start_frame}.
  1245. @item nb_frames, n
  1246. See @var{nb_frames}.
  1247. @item alpha
  1248. If set to 1, fade only alpha channel, if one exists on the input.
  1249. Default value is 0.
  1250. @end table
  1251. A few usage examples follow, usable too as test scenarios.
  1252. @example
  1253. # fade in first 30 frames of video
  1254. fade=in:0:30
  1255. # fade out last 45 frames of a 200-frame video
  1256. fade=out:155:45
  1257. # fade in first 25 frames and fade out last 25 frames of a 1000-frame video
  1258. fade=in:0:25, fade=out:975:25
  1259. # make first 5 frames black, then fade in from frame 5-24
  1260. fade=in:5:20
  1261. # fade in alpha over first 25 frames of video
  1262. fade=in:0:25:alpha=1
  1263. @end example
  1264. @section fieldorder
  1265. Transform the field order of the input video.
  1266. It accepts one parameter which specifies the required field order that
  1267. the input interlaced video will be transformed to. The parameter can
  1268. assume one of the following values:
  1269. @table @option
  1270. @item 0 or bff
  1271. output bottom field first
  1272. @item 1 or tff
  1273. output top field first
  1274. @end table
  1275. Default value is "tff".
  1276. Transformation is achieved by shifting the picture content up or down
  1277. by one line, and filling the remaining line with appropriate picture content.
  1278. This method is consistent with most broadcast field order converters.
  1279. If the input video is not flagged as being interlaced, or it is already
  1280. flagged as being of the required output field order then this filter does
  1281. not alter the incoming video.
  1282. This filter is very useful when converting to or from PAL DV material,
  1283. which is bottom field first.
  1284. For example:
  1285. @example
  1286. ffmpeg -i in.vob -vf "fieldorder=bff" out.dv
  1287. @end example
  1288. @section fifo
  1289. Buffer input images and send them when they are requested.
  1290. This filter is mainly useful when auto-inserted by the libavfilter
  1291. framework.
  1292. The filter does not take parameters.
  1293. @section format
  1294. Convert the input video to one of the specified pixel formats.
  1295. Libavfilter will try to pick one that is supported for the input to
  1296. the next filter.
  1297. The filter accepts a list of pixel format names, separated by ":",
  1298. for example "yuv420p:monow:rgb24".
  1299. Some examples follow:
  1300. @example
  1301. # convert the input video to the format "yuv420p"
  1302. format=yuv420p
  1303. # convert the input video to any of the formats in the list
  1304. format=yuv420p:yuv444p:yuv410p
  1305. @end example
  1306. @section fps
  1307. Convert the video to specified constant framerate by duplicating or dropping
  1308. frames as necessary.
  1309. This filter accepts the following named parameters:
  1310. @table @option
  1311. @item fps
  1312. Desired output framerate.
  1313. @end table
  1314. @anchor{frei0r}
  1315. @section frei0r
  1316. Apply a frei0r effect to the input video.
  1317. To enable compilation of this filter you need to install the frei0r
  1318. header and configure FFmpeg with @code{--enable-frei0r}.
  1319. The filter supports the syntax:
  1320. @example
  1321. @var{filter_name}[@{:|=@}@var{param1}:@var{param2}:...:@var{paramN}]
  1322. @end example
  1323. @var{filter_name} is the name to the frei0r effect to load. If the
  1324. environment variable @env{FREI0R_PATH} is defined, the frei0r effect
  1325. is searched in each one of the directories specified by the colon
  1326. separated list in @env{FREIOR_PATH}, otherwise in the standard frei0r
  1327. paths, which are in this order: @file{HOME/.frei0r-1/lib/},
  1328. @file{/usr/local/lib/frei0r-1/}, @file{/usr/lib/frei0r-1/}.
  1329. @var{param1}, @var{param2}, ... , @var{paramN} specify the parameters
  1330. for the frei0r effect.
  1331. A frei0r effect parameter can be a boolean (whose values are specified
  1332. with "y" and "n"), a double, a color (specified by the syntax
  1333. @var{R}/@var{G}/@var{B}, @var{R}, @var{G}, and @var{B} being float
  1334. numbers from 0.0 to 1.0) or by an @code{av_parse_color()} color
  1335. description), a position (specified by the syntax @var{X}/@var{Y},
  1336. @var{X} and @var{Y} being float numbers) and a string.
  1337. The number and kind of parameters depend on the loaded effect. If an
  1338. effect parameter is not specified the default value is set.
  1339. Some examples follow:
  1340. @example
  1341. # apply the distort0r effect, set the first two double parameters
  1342. frei0r=distort0r:0.5:0.01
  1343. # apply the colordistance effect, takes a color as first parameter
  1344. frei0r=colordistance:0.2/0.3/0.4
  1345. frei0r=colordistance:violet
  1346. frei0r=colordistance:0x112233
  1347. # apply the perspective effect, specify the top left and top right
  1348. # image positions
  1349. frei0r=perspective:0.2/0.2:0.8/0.2
  1350. @end example
  1351. For more information see:
  1352. @url{http://piksel.org/frei0r}
  1353. @section gradfun
  1354. Fix the banding artifacts that are sometimes introduced into nearly flat
  1355. regions by truncation to 8bit color depth.
  1356. Interpolate the gradients that should go where the bands are, and
  1357. dither them.
  1358. This filter is designed for playback only. Do not use it prior to
  1359. lossy compression, because compression tends to lose the dither and
  1360. bring back the bands.
  1361. The filter takes two optional parameters, separated by ':':
  1362. @var{strength}:@var{radius}
  1363. @var{strength} is the maximum amount by which the filter will change
  1364. any one pixel. Also the threshold for detecting nearly flat
  1365. regions. Acceptable values range from .51 to 255, default value is
  1366. 1.2, out-of-range values will be clipped to the valid range.
  1367. @var{radius} is the neighborhood to fit the gradient to. A larger
  1368. radius makes for smoother gradients, but also prevents the filter from
  1369. modifying the pixels near detailed regions. Acceptable values are
  1370. 8-32, default value is 16, out-of-range values will be clipped to the
  1371. valid range.
  1372. @example
  1373. # default parameters
  1374. gradfun=1.2:16
  1375. # omitting radius
  1376. gradfun=1.2
  1377. @end example
  1378. @section hflip
  1379. Flip the input video horizontally.
  1380. For example to horizontally flip the input video with @command{ffmpeg}:
  1381. @example
  1382. ffmpeg -i in.avi -vf "hflip" out.avi
  1383. @end example
  1384. @section hqdn3d
  1385. High precision/quality 3d denoise filter. This filter aims to reduce
  1386. image noise producing smooth images and making still images really
  1387. still. It should enhance compressibility.
  1388. It accepts the following optional parameters:
  1389. @var{luma_spatial}:@var{chroma_spatial}:@var{luma_tmp}:@var{chroma_tmp}
  1390. @table @option
  1391. @item luma_spatial
  1392. a non-negative float number which specifies spatial luma strength,
  1393. defaults to 4.0
  1394. @item chroma_spatial
  1395. a non-negative float number which specifies spatial chroma strength,
  1396. defaults to 3.0*@var{luma_spatial}/4.0
  1397. @item luma_tmp
  1398. a float number which specifies luma temporal strength, defaults to
  1399. 6.0*@var{luma_spatial}/4.0
  1400. @item chroma_tmp
  1401. a float number which specifies chroma temporal strength, defaults to
  1402. @var{luma_tmp}*@var{chroma_spatial}/@var{luma_spatial}
  1403. @end table
  1404. @section idet
  1405. Interlaceing detect filter. This filter tries to detect if the input is
  1406. interlaced or progressive. Top or bottom field first.
  1407. @section lut, lutrgb, lutyuv
  1408. Compute a look-up table for binding each pixel component input value
  1409. to an output value, and apply it to input video.
  1410. @var{lutyuv} applies a lookup table to a YUV input video, @var{lutrgb}
  1411. to an RGB input video.
  1412. These filters accept in input a ":"-separated list of options, which
  1413. specify the expressions used for computing the lookup table for the
  1414. corresponding pixel component values.
  1415. The @var{lut} filter requires either YUV or RGB pixel formats in
  1416. input, and accepts the options:
  1417. @table @option
  1418. @item c0
  1419. first pixel component
  1420. @item c1
  1421. second pixel component
  1422. @item c2
  1423. third pixel component
  1424. @item c3
  1425. fourth pixel component, corresponds to the alpha component
  1426. @end table
  1427. The exact component associated to each option depends on the format in
  1428. input.
  1429. The @var{lutrgb} filter requires RGB pixel formats in input, and
  1430. accepts the options:
  1431. @table @option
  1432. @item r
  1433. red component
  1434. @item g
  1435. green component
  1436. @item b
  1437. blue component
  1438. @item a
  1439. alpha component
  1440. @end table
  1441. The @var{lutyuv} filter requires YUV pixel formats in input, and
  1442. accepts the options:
  1443. @table @option
  1444. @item y
  1445. Y/luminance component
  1446. @item u
  1447. U/Cb component
  1448. @item v
  1449. V/Cr component
  1450. @item a
  1451. alpha component
  1452. @end table
  1453. The expressions can contain the following constants and functions:
  1454. @table @option
  1455. @item w, h
  1456. the input width and height
  1457. @item val
  1458. input value for the pixel component
  1459. @item clipval
  1460. the input value clipped in the @var{minval}-@var{maxval} range
  1461. @item maxval
  1462. maximum value for the pixel component
  1463. @item minval
  1464. minimum value for the pixel component
  1465. @item negval
  1466. the negated value for the pixel component value clipped in the
  1467. @var{minval}-@var{maxval} range , it corresponds to the expression
  1468. "maxval-clipval+minval"
  1469. @item clip(val)
  1470. the computed value in @var{val} clipped in the
  1471. @var{minval}-@var{maxval} range
  1472. @item gammaval(gamma)
  1473. the computed gamma correction value of the pixel component value
  1474. clipped in the @var{minval}-@var{maxval} range, corresponds to the
  1475. expression
  1476. "pow((clipval-minval)/(maxval-minval)\,@var{gamma})*(maxval-minval)+minval"
  1477. @end table
  1478. All expressions default to "val".
  1479. Some examples follow:
  1480. @example
  1481. # negate input video
  1482. lutrgb="r=maxval+minval-val:g=maxval+minval-val:b=maxval+minval-val"
  1483. lutyuv="y=maxval+minval-val:u=maxval+minval-val:v=maxval+minval-val"
  1484. # the above is the same as
  1485. lutrgb="r=negval:g=negval:b=negval"
  1486. lutyuv="y=negval:u=negval:v=negval"
  1487. # negate luminance
  1488. lutyuv=y=negval
  1489. # remove chroma components, turns the video into a graytone image
  1490. lutyuv="u=128:v=128"
  1491. # apply a luma burning effect
  1492. lutyuv="y=2*val"
  1493. # remove green and blue components
  1494. lutrgb="g=0:b=0"
  1495. # set a constant alpha channel value on input
  1496. format=rgba,lutrgb=a="maxval-minval/2"
  1497. # correct luminance gamma by a 0.5 factor
  1498. lutyuv=y=gammaval(0.5)
  1499. @end example
  1500. @section mp
  1501. Apply an MPlayer filter to the input video.
  1502. This filter provides a wrapper around most of the filters of
  1503. MPlayer/MEncoder.
  1504. This wrapper is considered experimental. Some of the wrapped filters
  1505. may not work properly and we may drop support for them, as they will
  1506. be implemented natively into FFmpeg. Thus you should avoid
  1507. depending on them when writing portable scripts.
  1508. The filters accepts the parameters:
  1509. @var{filter_name}[:=]@var{filter_params}
  1510. @var{filter_name} is the name of a supported MPlayer filter,
  1511. @var{filter_params} is a string containing the parameters accepted by
  1512. the named filter.
  1513. The list of the currently supported filters follows:
  1514. @table @var
  1515. @item decimate
  1516. @item denoise3d
  1517. @item detc
  1518. @item dint
  1519. @item divtc
  1520. @item down3dright
  1521. @item dsize
  1522. @item eq2
  1523. @item eq
  1524. @item field
  1525. @item fil
  1526. @item fixpts
  1527. @item framestep
  1528. @item fspp
  1529. @item geq
  1530. @item harddup
  1531. @item hqdn3d
  1532. @item hue
  1533. @item il
  1534. @item ilpack
  1535. @item ivtc
  1536. @item kerndeint
  1537. @item mcdeint
  1538. @item noise
  1539. @item ow
  1540. @item palette
  1541. @item perspective
  1542. @item phase
  1543. @item pp7
  1544. @item pullup
  1545. @item qp
  1546. @item rectangle
  1547. @item rotate
  1548. @item sab
  1549. @item smartblur
  1550. @item softpulldown
  1551. @item softskip
  1552. @item spp
  1553. @item telecine
  1554. @item tile
  1555. @item tinterlace
  1556. @item unsharp
  1557. @item uspp
  1558. @item yuvcsp
  1559. @item yvu9
  1560. @end table
  1561. The parameter syntax and behavior for the listed filters are the same
  1562. of the corresponding MPlayer filters. For detailed instructions check
  1563. the "VIDEO FILTERS" section in the MPlayer manual.
  1564. Some examples follow:
  1565. @example
  1566. # adjust gamma, brightness, contrast
  1567. mp=eq2=1.0:2:0.5
  1568. # tweak hue and saturation
  1569. mp=hue=100:-10
  1570. @end example
  1571. See also mplayer(1), @url{http://www.mplayerhq.hu/}.
  1572. @section negate
  1573. Negate input video.
  1574. This filter accepts an integer in input, if non-zero it negates the
  1575. alpha component (if available). The default value in input is 0.
  1576. @section noformat
  1577. Force libavfilter not to use any of the specified pixel formats for the
  1578. input to the next filter.
  1579. The filter accepts a list of pixel format names, separated by ":",
  1580. for example "yuv420p:monow:rgb24".
  1581. Some examples follow:
  1582. @example
  1583. # force libavfilter to use a format different from "yuv420p" for the
  1584. # input to the vflip filter
  1585. noformat=yuv420p,vflip
  1586. # convert the input video to any of the formats not contained in the list
  1587. noformat=yuv420p:yuv444p:yuv410p
  1588. @end example
  1589. @section null
  1590. Pass the video source unchanged to the output.
  1591. @section ocv
  1592. Apply video transform using libopencv.
  1593. To enable this filter install libopencv library and headers and
  1594. configure FFmpeg with @code{--enable-libopencv}.
  1595. The filter takes the parameters: @var{filter_name}@{:=@}@var{filter_params}.
  1596. @var{filter_name} is the name of the libopencv filter to apply.
  1597. @var{filter_params} specifies the parameters to pass to the libopencv
  1598. filter. If not specified the default values are assumed.
  1599. Refer to the official libopencv documentation for more precise
  1600. information:
  1601. @url{http://opencv.willowgarage.com/documentation/c/image_filtering.html}
  1602. Follows the list of supported libopencv filters.
  1603. @anchor{dilate}
  1604. @subsection dilate
  1605. Dilate an image by using a specific structuring element.
  1606. This filter corresponds to the libopencv function @code{cvDilate}.
  1607. It accepts the parameters: @var{struct_el}:@var{nb_iterations}.
  1608. @var{struct_el} represents a structuring element, and has the syntax:
  1609. @var{cols}x@var{rows}+@var{anchor_x}x@var{anchor_y}/@var{shape}
  1610. @var{cols} and @var{rows} represent the number of columns and rows of
  1611. the structuring element, @var{anchor_x} and @var{anchor_y} the anchor
  1612. point, and @var{shape} the shape for the structuring element, and
  1613. can be one of the values "rect", "cross", "ellipse", "custom".
  1614. If the value for @var{shape} is "custom", it must be followed by a
  1615. string of the form "=@var{filename}". The file with name
  1616. @var{filename} is assumed to represent a binary image, with each
  1617. printable character corresponding to a bright pixel. When a custom
  1618. @var{shape} is used, @var{cols} and @var{rows} are ignored, the number
  1619. or columns and rows of the read file are assumed instead.
  1620. The default value for @var{struct_el} is "3x3+0x0/rect".
  1621. @var{nb_iterations} specifies the number of times the transform is
  1622. applied to the image, and defaults to 1.
  1623. Follow some example:
  1624. @example
  1625. # use the default values
  1626. ocv=dilate
  1627. # dilate using a structuring element with a 5x5 cross, iterate two times
  1628. ocv=dilate=5x5+2x2/cross:2
  1629. # read the shape from the file diamond.shape, iterate two times
  1630. # the file diamond.shape may contain a pattern of characters like this:
  1631. # *
  1632. # ***
  1633. # *****
  1634. # ***
  1635. # *
  1636. # the specified cols and rows are ignored (but not the anchor point coordinates)
  1637. ocv=0x0+2x2/custom=diamond.shape:2
  1638. @end example
  1639. @subsection erode
  1640. Erode an image by using a specific structuring element.
  1641. This filter corresponds to the libopencv function @code{cvErode}.
  1642. The filter accepts the parameters: @var{struct_el}:@var{nb_iterations},
  1643. with the same syntax and semantics as the @ref{dilate} filter.
  1644. @subsection smooth
  1645. Smooth the input video.
  1646. The filter takes the following parameters:
  1647. @var{type}:@var{param1}:@var{param2}:@var{param3}:@var{param4}.
  1648. @var{type} is the type of smooth filter to apply, and can be one of
  1649. the following values: "blur", "blur_no_scale", "median", "gaussian",
  1650. "bilateral". The default value is "gaussian".
  1651. @var{param1}, @var{param2}, @var{param3}, and @var{param4} are
  1652. parameters whose meanings depend on smooth type. @var{param1} and
  1653. @var{param2} accept integer positive values or 0, @var{param3} and
  1654. @var{param4} accept float values.
  1655. The default value for @var{param1} is 3, the default value for the
  1656. other parameters is 0.
  1657. These parameters correspond to the parameters assigned to the
  1658. libopencv function @code{cvSmooth}.
  1659. @anchor{overlay}
  1660. @section overlay
  1661. Overlay one video on top of another.
  1662. It takes two inputs and one output, the first input is the "main"
  1663. video on which the second input is overlayed.
  1664. It accepts the parameters: @var{x}:@var{y}[:@var{options}].
  1665. @var{x} is the x coordinate of the overlayed video on the main video,
  1666. @var{y} is the y coordinate. @var{x} and @var{y} are expressions containing
  1667. the following parameters:
  1668. @table @option
  1669. @item main_w, main_h
  1670. main input width and height
  1671. @item W, H
  1672. same as @var{main_w} and @var{main_h}
  1673. @item overlay_w, overlay_h
  1674. overlay input width and height
  1675. @item w, h
  1676. same as @var{overlay_w} and @var{overlay_h}
  1677. @end table
  1678. @var{options} is an optional list of @var{key}=@var{value} pairs,
  1679. separated by ":".
  1680. The description of the accepted options follows.
  1681. @table @option
  1682. @item rgb
  1683. If set to 1, force the filter to accept inputs in the RGB
  1684. color space. Default value is 0.
  1685. @end table
  1686. Be aware that frames are taken from each input video in timestamp
  1687. order, hence, if their initial timestamps differ, it is a a good idea
  1688. to pass the two inputs through a @var{setpts=PTS-STARTPTS} filter to
  1689. have them begin in the same zero timestamp, as it does the example for
  1690. the @var{movie} filter.
  1691. Follow some examples:
  1692. @example
  1693. # draw the overlay at 10 pixels from the bottom right
  1694. # corner of the main video.
  1695. overlay=main_w-overlay_w-10:main_h-overlay_h-10
  1696. # insert a transparent PNG logo in the bottom left corner of the input
  1697. ffmpeg -i input -i logo -filter_complex 'overlay=10:main_h-overlay_h-10' output
  1698. # insert 2 different transparent PNG logos (second logo on bottom
  1699. # right corner):
  1700. ffmpeg -i input -i logo1 -i logo2 -filter_complex
  1701. 'overlay=10:H-h-10,overlay=W-w-10:H-h-10' output
  1702. # add a transparent color layer on top of the main video,
  1703. # WxH specifies the size of the main input to the overlay filter
  1704. color=red@.3:WxH [over]; [in][over] overlay [out]
  1705. @end example
  1706. You can chain together more overlays but the efficiency of such
  1707. approach is yet to be tested.
  1708. @section pad
  1709. Add paddings to the input image, and places the original input at the
  1710. given coordinates @var{x}, @var{y}.
  1711. It accepts the following parameters:
  1712. @var{width}:@var{height}:@var{x}:@var{y}:@var{color}.
  1713. The parameters @var{width}, @var{height}, @var{x}, and @var{y} are
  1714. expressions containing the following constants:
  1715. @table @option
  1716. @item in_w, in_h
  1717. the input video width and height
  1718. @item iw, ih
  1719. same as @var{in_w} and @var{in_h}
  1720. @item out_w, out_h
  1721. the output width and height, that is the size of the padded area as
  1722. specified by the @var{width} and @var{height} expressions
  1723. @item ow, oh
  1724. same as @var{out_w} and @var{out_h}
  1725. @item x, y
  1726. x and y offsets as specified by the @var{x} and @var{y}
  1727. expressions, or NAN if not yet specified
  1728. @item a
  1729. same as @var{iw} / @var{ih}
  1730. @item sar
  1731. input sample aspect ratio
  1732. @item dar
  1733. input display aspect ratio, it is the same as (@var{iw} / @var{ih}) * @var{sar}
  1734. @item hsub, vsub
  1735. horizontal and vertical chroma subsample values. For example for the
  1736. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  1737. @end table
  1738. Follows the description of the accepted parameters.
  1739. @table @option
  1740. @item width, height
  1741. Specify the size of the output image with the paddings added. If the
  1742. value for @var{width} or @var{height} is 0, the corresponding input size
  1743. is used for the output.
  1744. The @var{width} expression can reference the value set by the
  1745. @var{height} expression, and vice versa.
  1746. The default value of @var{width} and @var{height} is 0.
  1747. @item x, y
  1748. Specify the offsets where to place the input image in the padded area
  1749. with respect to the top/left border of the output image.
  1750. The @var{x} expression can reference the value set by the @var{y}
  1751. expression, and vice versa.
  1752. The default value of @var{x} and @var{y} is 0.
  1753. @item color
  1754. Specify the color of the padded area, it can be the name of a color
  1755. (case insensitive match) or a 0xRRGGBB[AA] sequence.
  1756. The default value of @var{color} is "black".
  1757. @end table
  1758. Some examples follow:
  1759. @example
  1760. # Add paddings with color "violet" to the input video. Output video
  1761. # size is 640x480, the top-left corner of the input video is placed at
  1762. # column 0, row 40.
  1763. pad=640:480:0:40:violet
  1764. # pad the input to get an output with dimensions increased bt 3/2,
  1765. # and put the input video at the center of the padded area
  1766. pad="3/2*iw:3/2*ih:(ow-iw)/2:(oh-ih)/2"
  1767. # pad the input to get a squared output with size equal to the maximum
  1768. # value between the input width and height, and put the input video at
  1769. # the center of the padded area
  1770. pad="max(iw\,ih):ow:(ow-iw)/2:(oh-ih)/2"
  1771. # pad the input to get a final w/h ratio of 16:9
  1772. pad="ih*16/9:ih:(ow-iw)/2:(oh-ih)/2"
  1773. # for anamorphic video, in order to set the output display aspect ratio,
  1774. # it is necessary to use sar in the expression, according to the relation:
  1775. # (ih * X / ih) * sar = output_dar
  1776. # X = output_dar / sar
  1777. pad="ih*16/9/sar:ih:(ow-iw)/2:(oh-ih)/2"
  1778. # double output size and put the input video in the bottom-right
  1779. # corner of the output padded area
  1780. pad="2*iw:2*ih:ow-iw:oh-ih"
  1781. @end example
  1782. @section pixdesctest
  1783. Pixel format descriptor test filter, mainly useful for internal
  1784. testing. The output video should be equal to the input video.
  1785. For example:
  1786. @example
  1787. format=monow, pixdesctest
  1788. @end example
  1789. can be used to test the monowhite pixel format descriptor definition.
  1790. @section removelogo
  1791. Suppress a TV station logo, using an image file to determine which
  1792. pixels comprise the logo. It works by filling in the pixels that
  1793. comprise the logo with neighboring pixels.
  1794. This filter requires one argument which specifies the filter bitmap
  1795. file, which can be any image format supported by libavformat. The
  1796. width and height of the image file must match those of the video
  1797. stream being processed.
  1798. Pixels in the provided bitmap image with a value of zero are not
  1799. considered part of the logo, non-zero pixels are considered part of
  1800. the logo. If you use white (255) for the logo and black (0) for the
  1801. rest, you will be safe. For making the filter bitmap, it is
  1802. recommended to take a screen capture of a black frame with the logo
  1803. visible, and then using a threshold filter followed by the erode
  1804. filter once or twice.
  1805. If needed, little splotches can be fixed manually. Remember that if
  1806. logo pixels are not covered, the filter quality will be much
  1807. reduced. Marking too many pixels as part of the logo does not hurt as
  1808. much, but it will increase the amount of blurring needed to cover over
  1809. the image and will destroy more information than necessary, and extra
  1810. pixels will slow things down on a large logo.
  1811. @section scale
  1812. Scale the input video to @var{width}:@var{height}[:@var{interl}=@{1|-1@}] and/or convert the image format.
  1813. The scale filter forces the output display aspect ratio to be the same
  1814. of the input, by changing the output sample aspect ratio.
  1815. The parameters @var{width} and @var{height} are expressions containing
  1816. the following constants:
  1817. @table @option
  1818. @item in_w, in_h
  1819. the input width and height
  1820. @item iw, ih
  1821. same as @var{in_w} and @var{in_h}
  1822. @item out_w, out_h
  1823. the output (cropped) width and height
  1824. @item ow, oh
  1825. same as @var{out_w} and @var{out_h}
  1826. @item a
  1827. same as @var{iw} / @var{ih}
  1828. @item sar
  1829. input sample aspect ratio
  1830. @item dar
  1831. input display aspect ratio, it is the same as (@var{iw} / @var{ih}) * @var{sar}
  1832. @item hsub, vsub
  1833. horizontal and vertical chroma subsample values. For example for the
  1834. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  1835. @end table
  1836. If the input image format is different from the format requested by
  1837. the next filter, the scale filter will convert the input to the
  1838. requested format.
  1839. If the value for @var{width} or @var{height} is 0, the respective input
  1840. size is used for the output.
  1841. If the value for @var{width} or @var{height} is -1, the scale filter will
  1842. use, for the respective output size, a value that maintains the aspect
  1843. ratio of the input image.
  1844. The default value of @var{width} and @var{height} is 0.
  1845. Valid values for the optional parameter @var{interl} are:
  1846. @table @option
  1847. @item 1
  1848. force interlaced aware scaling
  1849. @item -1
  1850. select interlaced aware scaling depending on whether the source frames
  1851. are flagged as interlaced or not
  1852. @end table
  1853. Unless @var{interl} is set to one of the above options, interlaced scaling will not be used.
  1854. Some examples follow:
  1855. @example
  1856. # scale the input video to a size of 200x100.
  1857. scale=200:100
  1858. # scale the input to 2x
  1859. scale=2*iw:2*ih
  1860. # the above is the same as
  1861. scale=2*in_w:2*in_h
  1862. # scale the input to 2x with forced interlaced scaling
  1863. scale=2*iw:2*ih:interl=1
  1864. # scale the input to half size
  1865. scale=iw/2:ih/2
  1866. # increase the width, and set the height to the same size
  1867. scale=3/2*iw:ow
  1868. # seek for Greek harmony
  1869. scale=iw:1/PHI*iw
  1870. scale=ih*PHI:ih
  1871. # increase the height, and set the width to 3/2 of the height
  1872. scale=3/2*oh:3/5*ih
  1873. # increase the size, but make the size a multiple of the chroma
  1874. scale="trunc(3/2*iw/hsub)*hsub:trunc(3/2*ih/vsub)*vsub"
  1875. # increase the width to a maximum of 500 pixels, keep the same input aspect ratio
  1876. scale='min(500\, iw*3/2):-1'
  1877. @end example
  1878. @section select
  1879. Select frames to pass in output.
  1880. It accepts in input an expression, which is evaluated for each input
  1881. frame. If the expression is evaluated to a non-zero value, the frame
  1882. is selected and passed to the output, otherwise it is discarded.
  1883. The expression can contain the following constants:
  1884. @table @option
  1885. @item n
  1886. the sequential number of the filtered frame, starting from 0
  1887. @item selected_n
  1888. the sequential number of the selected frame, starting from 0
  1889. @item prev_selected_n
  1890. the sequential number of the last selected frame, NAN if undefined
  1891. @item TB
  1892. timebase of the input timestamps
  1893. @item pts
  1894. the PTS (Presentation TimeStamp) of the filtered video frame,
  1895. expressed in @var{TB} units, NAN if undefined
  1896. @item t
  1897. the PTS (Presentation TimeStamp) of the filtered video frame,
  1898. expressed in seconds, NAN if undefined
  1899. @item prev_pts
  1900. the PTS of the previously filtered video frame, NAN if undefined
  1901. @item prev_selected_pts
  1902. the PTS of the last previously filtered video frame, NAN if undefined
  1903. @item prev_selected_t
  1904. the PTS of the last previously selected video frame, NAN if undefined
  1905. @item start_pts
  1906. the PTS of the first video frame in the video, NAN if undefined
  1907. @item start_t
  1908. the time of the first video frame in the video, NAN if undefined
  1909. @item pict_type
  1910. the type of the filtered frame, can assume one of the following
  1911. values:
  1912. @table @option
  1913. @item I
  1914. @item P
  1915. @item B
  1916. @item S
  1917. @item SI
  1918. @item SP
  1919. @item BI
  1920. @end table
  1921. @item interlace_type
  1922. the frame interlace type, can assume one of the following values:
  1923. @table @option
  1924. @item PROGRESSIVE
  1925. the frame is progressive (not interlaced)
  1926. @item TOPFIRST
  1927. the frame is top-field-first
  1928. @item BOTTOMFIRST
  1929. the frame is bottom-field-first
  1930. @end table
  1931. @item key
  1932. 1 if the filtered frame is a key-frame, 0 otherwise
  1933. @item pos
  1934. the position in the file of the filtered frame, -1 if the information
  1935. is not available (e.g. for synthetic video)
  1936. @item scene
  1937. value between 0 and 1 to indicate a new scene; a low value reflects a low
  1938. probability for the current frame to introduce a new scene, while a higher
  1939. value means the current frame is more likely to be one (see the example below)
  1940. @end table
  1941. The default value of the select expression is "1".
  1942. Some examples follow:
  1943. @example
  1944. # select all frames in input
  1945. select
  1946. # the above is the same as:
  1947. select=1
  1948. # skip all frames:
  1949. select=0
  1950. # select only I-frames
  1951. select='eq(pict_type\,I)'
  1952. # select one frame every 100
  1953. select='not(mod(n\,100))'
  1954. # select only frames contained in the 10-20 time interval
  1955. select='gte(t\,10)*lte(t\,20)'
  1956. # select only I frames contained in the 10-20 time interval
  1957. select='gte(t\,10)*lte(t\,20)*eq(pict_type\,I)'
  1958. # select frames with a minimum distance of 10 seconds
  1959. select='isnan(prev_selected_t)+gte(t-prev_selected_t\,10)'
  1960. @end example
  1961. Complete example to create a mosaic of the first scenes:
  1962. @example
  1963. ffmpeg -i video.avi -vf select='gt(scene\,0.4)',scale=160:120,tile -frames:v 1 preview.png
  1964. @end example
  1965. Comparing @var{scene} against a value between 0.3 and 0.5 is generally a sane
  1966. choice.
  1967. @section setdar, setsar
  1968. The @code{setdar} filter sets the Display Aspect Ratio for the filter
  1969. output video.
  1970. This is done by changing the specified Sample (aka Pixel) Aspect
  1971. Ratio, according to the following equation:
  1972. @example
  1973. @var{DAR} = @var{HORIZONTAL_RESOLUTION} / @var{VERTICAL_RESOLUTION} * @var{SAR}
  1974. @end example
  1975. Keep in mind that the @code{setdar} filter does not modify the pixel
  1976. dimensions of the video frame. Also the display aspect ratio set by
  1977. this filter may be changed by later filters in the filterchain,
  1978. e.g. in case of scaling or if another "setdar" or a "setsar" filter is
  1979. applied.
  1980. The @code{setsar} filter sets the Sample (aka Pixel) Aspect Ratio for
  1981. the filter output video.
  1982. Note that as a consequence of the application of this filter, the
  1983. output display aspect ratio will change according to the equation
  1984. above.
  1985. Keep in mind that the sample aspect ratio set by the @code{setsar}
  1986. filter may be changed by later filters in the filterchain, e.g. if
  1987. another "setsar" or a "setdar" filter is applied.
  1988. The @code{setdar} and @code{setsar} filters accept a parameter string
  1989. which represents the wanted aspect ratio. The parameter can
  1990. be a floating point number string, an expression, or a string of the form
  1991. @var{num}:@var{den}, where @var{num} and @var{den} are the numerator
  1992. and denominator of the aspect ratio. If the parameter is not
  1993. specified, it is assumed the value "0:1".
  1994. For example to change the display aspect ratio to 16:9, specify:
  1995. @example
  1996. setdar=16:9
  1997. @end example
  1998. The example above is equivalent to:
  1999. @example
  2000. setdar=1.77777
  2001. @end example
  2002. To change the sample aspect ratio to 10:11, specify:
  2003. @example
  2004. setsar=10:11
  2005. @end example
  2006. @section setfield
  2007. Force field for the output video frame.
  2008. The @code{setfield} filter marks the interlace type field for the
  2009. output frames. It does not change the input frame, but only sets the
  2010. corresponding property, which affects how the frame is treated by
  2011. following filters (e.g. @code{fieldorder} or @code{yadif}).
  2012. It accepts a string parameter, which can assume the following values:
  2013. @table @samp
  2014. @item auto
  2015. Keep the same field property.
  2016. @item bff
  2017. Mark the frame as bottom-field-first.
  2018. @item tff
  2019. Mark the frame as top-field-first.
  2020. @item prog
  2021. Mark the frame as progressive.
  2022. @end table
  2023. @section setpts
  2024. Change the PTS (presentation timestamp) of the input video frames.
  2025. Accept in input an expression evaluated through the eval API, which
  2026. can contain the following constants:
  2027. @table @option
  2028. @item PTS
  2029. the presentation timestamp in input
  2030. @item N
  2031. the count of the input frame, starting from 0.
  2032. @item STARTPTS
  2033. the PTS of the first video frame
  2034. @item INTERLACED
  2035. tell if the current frame is interlaced
  2036. @item POS
  2037. original position in the file of the frame, or undefined if undefined
  2038. for the current frame
  2039. @item PREV_INPTS
  2040. previous input PTS
  2041. @item PREV_OUTPTS
  2042. previous output PTS
  2043. @end table
  2044. Some examples follow:
  2045. @example
  2046. # start counting PTS from zero
  2047. setpts=PTS-STARTPTS
  2048. # fast motion
  2049. setpts=0.5*PTS
  2050. # slow motion
  2051. setpts=2.0*PTS
  2052. # fixed rate 25 fps
  2053. setpts=N/(25*TB)
  2054. # fixed rate 25 fps with some jitter
  2055. setpts='1/(25*TB) * (N + 0.05 * sin(N*2*PI/25))'
  2056. @end example
  2057. @section settb
  2058. Set the timebase to use for the output frames timestamps.
  2059. It is mainly useful for testing timebase configuration.
  2060. It accepts in input an arithmetic expression representing a rational.
  2061. The expression can contain the constants "AVTB" (the
  2062. default timebase), and "intb" (the input timebase).
  2063. The default value for the input is "intb".
  2064. Follow some examples.
  2065. @example
  2066. # set the timebase to 1/25
  2067. settb=1/25
  2068. # set the timebase to 1/10
  2069. settb=0.1
  2070. #set the timebase to 1001/1000
  2071. settb=1+0.001
  2072. #set the timebase to 2*intb
  2073. settb=2*intb
  2074. #set the default timebase value
  2075. settb=AVTB
  2076. @end example
  2077. @section showinfo
  2078. Show a line containing various information for each input video frame.
  2079. The input video is not modified.
  2080. The shown line contains a sequence of key/value pairs of the form
  2081. @var{key}:@var{value}.
  2082. A description of each shown parameter follows:
  2083. @table @option
  2084. @item n
  2085. sequential number of the input frame, starting from 0
  2086. @item pts
  2087. Presentation TimeStamp of the input frame, expressed as a number of
  2088. time base units. The time base unit depends on the filter input pad.
  2089. @item pts_time
  2090. Presentation TimeStamp of the input frame, expressed as a number of
  2091. seconds
  2092. @item pos
  2093. position of the frame in the input stream, -1 if this information in
  2094. unavailable and/or meaningless (for example in case of synthetic video)
  2095. @item fmt
  2096. pixel format name
  2097. @item sar
  2098. sample aspect ratio of the input frame, expressed in the form
  2099. @var{num}/@var{den}
  2100. @item s
  2101. size of the input frame, expressed in the form
  2102. @var{width}x@var{height}
  2103. @item i
  2104. interlaced mode ("P" for "progressive", "T" for top field first, "B"
  2105. for bottom field first)
  2106. @item iskey
  2107. 1 if the frame is a key frame, 0 otherwise
  2108. @item type
  2109. picture type of the input frame ("I" for an I-frame, "P" for a
  2110. P-frame, "B" for a B-frame, "?" for unknown type).
  2111. Check also the documentation of the @code{AVPictureType} enum and of
  2112. the @code{av_get_picture_type_char} function defined in
  2113. @file{libavutil/avutil.h}.
  2114. @item checksum
  2115. Adler-32 checksum (printed in hexadecimal) of all the planes of the input frame
  2116. @item plane_checksum
  2117. Adler-32 checksum (printed in hexadecimal) of each plane of the input frame,
  2118. expressed in the form "[@var{c0} @var{c1} @var{c2} @var{c3}]"
  2119. @end table
  2120. @section slicify
  2121. Pass the images of input video on to next video filter as multiple
  2122. slices.
  2123. @example
  2124. ffmpeg -i in.avi -vf "slicify=32" out.avi
  2125. @end example
  2126. The filter accepts the slice height as parameter. If the parameter is
  2127. not specified it will use the default value of 16.
  2128. Adding this in the beginning of filter chains should make filtering
  2129. faster due to better use of the memory cache.
  2130. @section split
  2131. Split input video into several identical outputs.
  2132. The filter accepts a single parameter which specifies the number of outputs. If
  2133. unspecified, it defaults to 2.
  2134. For example
  2135. @example
  2136. ffmpeg -i INPUT -filter_complex split=5 OUTPUT
  2137. @end example
  2138. will create 5 copies of the input video.
  2139. For example:
  2140. @example
  2141. [in] split [splitout1][splitout2];
  2142. [splitout1] crop=100:100:0:0 [cropout];
  2143. [splitout2] pad=200:200:100:100 [padout];
  2144. @end example
  2145. will create two separate outputs from the same input, one cropped and
  2146. one padded.
  2147. @section super2xsai
  2148. Scale the input by 2x and smooth using the Super2xSaI (Scale and
  2149. Interpolate) pixel art scaling algorithm.
  2150. Useful for enlarging pixel art images without reducing sharpness.
  2151. @section swapuv
  2152. Swap U & V plane.
  2153. @section thumbnail
  2154. Select the most representative frame in a given sequence of consecutive frames.
  2155. It accepts as argument the frames batch size to analyze (default @var{N}=100);
  2156. in a set of @var{N} frames, the filter will pick one of them, and then handle
  2157. the next batch of @var{N} frames until the end.
  2158. Since the filter keeps track of the whole frames sequence, a bigger @var{N}
  2159. value will result in a higher memory usage, so a high value is not recommended.
  2160. The following example extract one picture each 50 frames:
  2161. @example
  2162. thumbnail=50
  2163. @end example
  2164. Complete example of a thumbnail creation with @command{ffmpeg}:
  2165. @example
  2166. ffmpeg -i in.avi -vf thumbnail,scale=300:200 -frames:v 1 out.png
  2167. @end example
  2168. @section tile
  2169. Tile several successive frames together.
  2170. It accepts as argument the tile size (i.e. the number of lines and columns)
  2171. in the form "@var{w}x@var{h}".
  2172. For example, produce 8×8 PNG tiles of all keyframes (@option{-skip_frame
  2173. nokey}) in a movie:
  2174. @example
  2175. ffmpeg -skip_frame nokey -i file.avi -vf 'scale=128:72,tile=8x8' -an -vsync 0 keyframes%03d.png
  2176. @end example
  2177. The @option{-vsync 0} is necessary to prevent @command{ffmpeg} from
  2178. duplicating each output frame to accomodate the originally detected frame
  2179. rate.
  2180. @section tinterlace
  2181. Perform various types of temporal field interlacing.
  2182. Frames are counted starting from 1, so the first input frame is
  2183. considered odd.
  2184. This filter accepts a single parameter specifying the mode. Available
  2185. modes are:
  2186. @table @samp
  2187. @item merge, 0
  2188. Move odd frames into the upper field, even into the lower field,
  2189. generating a double height frame at half framerate.
  2190. @item drop_odd, 1
  2191. Only output even frames, odd frames are dropped, generating a frame with
  2192. unchanged height at half framerate.
  2193. @item drop_even, 2
  2194. Only output odd frames, even frames are dropped, generating a frame with
  2195. unchanged height at half framerate.
  2196. @item pad, 3
  2197. Expand each frame to full height, but pad alternate lines with black,
  2198. generating a frame with double height at the same input framerate.
  2199. @item interleave_top, 4
  2200. Interleave the upper field from odd frames with the lower field from
  2201. even frames, generating a frame with unchanged height at half framerate.
  2202. @item interleave_bottom, 5
  2203. Interleave the lower field from odd frames with the upper field from
  2204. even frames, generating a frame with unchanged height at half framerate.
  2205. @item interlacex2, 6
  2206. Double frame rate with unchanged height. Frames are inserted each
  2207. containing the second temporal field from the previous input frame and
  2208. the first temporal field from the next input frame. This mode relies on
  2209. the top_field_first flag. Useful for interlaced video displays with no
  2210. field synchronisation.
  2211. @end table
  2212. Numeric values are deprecated but are accepted for backward
  2213. compatibility reasons.
  2214. Default mode is @code{merge}.
  2215. @section transpose
  2216. Transpose rows with columns in the input video and optionally flip it.
  2217. It accepts a parameter representing an integer, which can assume the
  2218. values:
  2219. @table @samp
  2220. @item 0
  2221. Rotate by 90 degrees counterclockwise and vertically flip (default), that is:
  2222. @example
  2223. L.R L.l
  2224. . . -> . .
  2225. l.r R.r
  2226. @end example
  2227. @item 1
  2228. Rotate by 90 degrees clockwise, that is:
  2229. @example
  2230. L.R l.L
  2231. . . -> . .
  2232. l.r r.R
  2233. @end example
  2234. @item 2
  2235. Rotate by 90 degrees counterclockwise, that is:
  2236. @example
  2237. L.R R.r
  2238. . . -> . .
  2239. l.r L.l
  2240. @end example
  2241. @item 3
  2242. Rotate by 90 degrees clockwise and vertically flip, that is:
  2243. @example
  2244. L.R r.R
  2245. . . -> . .
  2246. l.r l.L
  2247. @end example
  2248. @end table
  2249. @section unsharp
  2250. Sharpen or blur the input video.
  2251. It accepts the following parameters:
  2252. @var{luma_msize_x}:@var{luma_msize_y}:@var{luma_amount}:@var{chroma_msize_x}:@var{chroma_msize_y}:@var{chroma_amount}
  2253. Negative values for the amount will blur the input video, while positive
  2254. values will sharpen. All parameters are optional and default to the
  2255. equivalent of the string '5:5:1.0:5:5:0.0'.
  2256. @table @option
  2257. @item luma_msize_x
  2258. Set the luma matrix horizontal size. It can be an integer between 3
  2259. and 13, default value is 5.
  2260. @item luma_msize_y
  2261. Set the luma matrix vertical size. It can be an integer between 3
  2262. and 13, default value is 5.
  2263. @item luma_amount
  2264. Set the luma effect strength. It can be a float number between -2.0
  2265. and 5.0, default value is 1.0.
  2266. @item chroma_msize_x
  2267. Set the chroma matrix horizontal size. It can be an integer between 3
  2268. and 13, default value is 5.
  2269. @item chroma_msize_y
  2270. Set the chroma matrix vertical size. It can be an integer between 3
  2271. and 13, default value is 5.
  2272. @item chroma_amount
  2273. Set the chroma effect strength. It can be a float number between -2.0
  2274. and 5.0, default value is 0.0.
  2275. @end table
  2276. @example
  2277. # Strong luma sharpen effect parameters
  2278. unsharp=7:7:2.5
  2279. # Strong blur of both luma and chroma parameters
  2280. unsharp=7:7:-2:7:7:-2
  2281. # Use the default values with @command{ffmpeg}
  2282. ffmpeg -i in.avi -vf "unsharp" out.mp4
  2283. @end example
  2284. @section vflip
  2285. Flip the input video vertically.
  2286. @example
  2287. ffmpeg -i in.avi -vf "vflip" out.avi
  2288. @end example
  2289. @section yadif
  2290. Deinterlace the input video ("yadif" means "yet another deinterlacing
  2291. filter").
  2292. It accepts the optional parameters: @var{mode}:@var{parity}:@var{auto}.
  2293. @var{mode} specifies the interlacing mode to adopt, accepts one of the
  2294. following values:
  2295. @table @option
  2296. @item 0
  2297. output 1 frame for each frame
  2298. @item 1
  2299. output 1 frame for each field
  2300. @item 2
  2301. like 0 but skips spatial interlacing check
  2302. @item 3
  2303. like 1 but skips spatial interlacing check
  2304. @end table
  2305. Default value is 0.
  2306. @var{parity} specifies the picture field parity assumed for the input
  2307. interlaced video, accepts one of the following values:
  2308. @table @option
  2309. @item 0
  2310. assume top field first
  2311. @item 1
  2312. assume bottom field first
  2313. @item -1
  2314. enable automatic detection
  2315. @end table
  2316. Default value is -1.
  2317. If interlacing is unknown or decoder does not export this information,
  2318. top field first will be assumed.
  2319. @var{auto} specifies if deinterlacer should trust the interlaced flag
  2320. and only deinterlace frames marked as interlaced
  2321. @table @option
  2322. @item 0
  2323. deinterlace all frames
  2324. @item 1
  2325. only deinterlace frames marked as interlaced
  2326. @end table
  2327. Default value is 0.
  2328. @c man end VIDEO FILTERS
  2329. @chapter Video Sources
  2330. @c man begin VIDEO SOURCES
  2331. Below is a description of the currently available video sources.
  2332. @section buffer
  2333. Buffer video frames, and make them available to the filter chain.
  2334. This source is mainly intended for a programmatic use, in particular
  2335. through the interface defined in @file{libavfilter/vsrc_buffer.h}.
  2336. It accepts a list of options in the form of @var{key}=@var{value} pairs
  2337. separated by ":". A descroption of the accepted options follows.
  2338. @table @option
  2339. @item video_size
  2340. Specify the size (width and height) of the buffered video frames.
  2341. @item pix_fmt
  2342. A string representing the pixel format of the buffered video frames.
  2343. It may be a number corresponding to a pixel format, or a pixel format
  2344. name.
  2345. @item time_base
  2346. Specify the timebase assumed by the timestamps of the buffered frames.
  2347. @item time_base
  2348. Specify the frame rate expected for the video stream.
  2349. @item pixel_aspect
  2350. Specify the sample aspect ratio assumed by the video frames.
  2351. @item sws_param
  2352. Specify the optional parameters to be used for the scale filter which
  2353. is automatically inserted when an input change is detected in the
  2354. input size or format.
  2355. @end table
  2356. For example:
  2357. @example
  2358. buffer=size=320x240:pix_fmt=yuv410p:time_base=1/24:pixel_aspect=1/1
  2359. @end example
  2360. will instruct the source to accept video frames with size 320x240 and
  2361. with format "yuv410p", assuming 1/24 as the timestamps timebase and
  2362. square pixels (1:1 sample aspect ratio).
  2363. Since the pixel format with name "yuv410p" corresponds to the number 6
  2364. (check the enum PixelFormat definition in @file{libavutil/pixfmt.h}),
  2365. this example corresponds to:
  2366. @example
  2367. buffer=size=320x240:pixfmt=6:time_base=1/24:pixel_aspect=1/1
  2368. @end example
  2369. Alternatively, the options can be specified as a flat string, but this
  2370. syntax is deprecated:
  2371. @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}]
  2372. @section cellauto
  2373. Create a pattern generated by an elementary cellular automaton.
  2374. The initial state of the cellular automaton can be defined through the
  2375. @option{filename}, and @option{pattern} options. If such options are
  2376. not specified an initial state is created randomly.
  2377. At each new frame a new row in the video is filled with the result of
  2378. the cellular automaton next generation. The behavior when the whole
  2379. frame is filled is defined by the @option{scroll} option.
  2380. This source accepts a list of options in the form of
  2381. @var{key}=@var{value} pairs separated by ":". A description of the
  2382. accepted options follows.
  2383. @table @option
  2384. @item filename, f
  2385. Read the initial cellular automaton state, i.e. the starting row, from
  2386. the specified file.
  2387. In the file, each non-whitespace character is considered an alive
  2388. cell, a newline will terminate the row, and further characters in the
  2389. file will be ignored.
  2390. @item pattern, p
  2391. Read the initial cellular automaton state, i.e. the starting row, from
  2392. the specified string.
  2393. Each non-whitespace character in the string is considered an alive
  2394. cell, a newline will terminate the row, and further characters in the
  2395. string will be ignored.
  2396. @item rate, r
  2397. Set the video rate, that is the number of frames generated per second.
  2398. Default is 25.
  2399. @item random_fill_ratio, ratio
  2400. Set the random fill ratio for the initial cellular automaton row. It
  2401. is a floating point number value ranging from 0 to 1, defaults to
  2402. 1/PHI.
  2403. This option is ignored when a file or a pattern is specified.
  2404. @item random_seed, seed
  2405. Set the seed for filling randomly the initial row, must be an integer
  2406. included between 0 and UINT32_MAX. If not specified, or if explicitly
  2407. set to -1, the filter will try to use a good random seed on a best
  2408. effort basis.
  2409. @item rule
  2410. Set the cellular automaton rule, it is a number ranging from 0 to 255.
  2411. Default value is 110.
  2412. @item size, s
  2413. Set the size of the output video.
  2414. If @option{filename} or @option{pattern} is specified, the size is set
  2415. by default to the width of the specified initial state row, and the
  2416. height is set to @var{width} * PHI.
  2417. If @option{size} is set, it must contain the width of the specified
  2418. pattern string, and the specified pattern will be centered in the
  2419. larger row.
  2420. If a filename or a pattern string is not specified, the size value
  2421. defaults to "320x518" (used for a randomly generated initial state).
  2422. @item scroll
  2423. If set to 1, scroll the output upward when all the rows in the output
  2424. have been already filled. If set to 0, the new generated row will be
  2425. written over the top row just after the bottom row is filled.
  2426. Defaults to 1.
  2427. @item start_full, full
  2428. If set to 1, completely fill the output with generated rows before
  2429. outputting the first frame.
  2430. This is the default behavior, for disabling set the value to 0.
  2431. @item stitch
  2432. If set to 1, stitch the left and right row edges together.
  2433. This is the default behavior, for disabling set the value to 0.
  2434. @end table
  2435. @subsection Examples
  2436. @itemize
  2437. @item
  2438. Read the initial state from @file{pattern}, and specify an output of
  2439. size 200x400.
  2440. @example
  2441. cellauto=f=pattern:s=200x400
  2442. @end example
  2443. @item
  2444. Generate a random initial row with a width of 200 cells, with a fill
  2445. ratio of 2/3:
  2446. @example
  2447. cellauto=ratio=2/3:s=200x200
  2448. @end example
  2449. @item
  2450. Create a pattern generated by rule 18 starting by a single alive cell
  2451. centered on an initial row with width 100:
  2452. @example
  2453. cellauto=p=@@:s=100x400:full=0:rule=18
  2454. @end example
  2455. @item
  2456. Specify a more elaborated initial pattern:
  2457. @example
  2458. cellauto=p='@@@@ @@ @@@@':s=100x400:full=0:rule=18
  2459. @end example
  2460. @end itemize
  2461. @section color
  2462. Provide an uniformly colored input.
  2463. It accepts the following parameters:
  2464. @var{color}:@var{frame_size}:@var{frame_rate}
  2465. Follows the description of the accepted parameters.
  2466. @table @option
  2467. @item color
  2468. Specify the color of the source. It can be the name of a color (case
  2469. insensitive match) or a 0xRRGGBB[AA] sequence, possibly followed by an
  2470. alpha specifier. The default value is "black".
  2471. @item frame_size
  2472. Specify the size of the sourced video, it may be a string of the form
  2473. @var{width}x@var{height}, or the name of a size abbreviation. The
  2474. default value is "320x240".
  2475. @item frame_rate
  2476. Specify the frame rate of the sourced video, as the number of frames
  2477. generated per second. It has to be a string in the format
  2478. @var{frame_rate_num}/@var{frame_rate_den}, an integer number, a float
  2479. number or a valid video frame rate abbreviation. The default value is
  2480. "25".
  2481. @end table
  2482. For example the following graph description will generate a red source
  2483. with an opacity of 0.2, with size "qcif" and a frame rate of 10
  2484. frames per second, which will be overlayed over the source connected
  2485. to the pad with identifier "in".
  2486. @example
  2487. "color=red@@0.2:qcif:10 [color]; [in][color] overlay [out]"
  2488. @end example
  2489. @section movie
  2490. Read a video stream from a movie container.
  2491. It accepts the syntax: @var{movie_name}[:@var{options}] where
  2492. @var{movie_name} is the name of the resource to read (not necessarily
  2493. a file but also a device or a stream accessed through some protocol),
  2494. and @var{options} is an optional sequence of @var{key}=@var{value}
  2495. pairs, separated by ":".
  2496. The description of the accepted options follows.
  2497. @table @option
  2498. @item format_name, f
  2499. Specifies the format assumed for the movie to read, and can be either
  2500. the name of a container or an input device. If not specified the
  2501. format is guessed from @var{movie_name} or by probing.
  2502. @item seek_point, sp
  2503. Specifies the seek point in seconds, the frames will be output
  2504. starting from this seek point, the parameter is evaluated with
  2505. @code{av_strtod} so the numerical value may be suffixed by an IS
  2506. postfix. Default value is "0".
  2507. @item stream_index, si
  2508. Specifies the index of the video stream to read. If the value is -1,
  2509. the best suited video stream will be automatically selected. Default
  2510. value is "-1".
  2511. @item loop
  2512. Specifies how many times to read the video stream in sequence.
  2513. If the value is less than 1, the stream will be read again and again.
  2514. Default value is "1".
  2515. Note that when the movie is looped the source timestamps are not
  2516. changed, so it will generate non monotonically increasing timestamps.
  2517. @end table
  2518. This filter allows to overlay a second video on top of main input of
  2519. a filtergraph as shown in this graph:
  2520. @example
  2521. input -----------> deltapts0 --> overlay --> output
  2522. ^
  2523. |
  2524. movie --> scale--> deltapts1 -------+
  2525. @end example
  2526. Some examples follow:
  2527. @example
  2528. # skip 3.2 seconds from the start of the avi file in.avi, and overlay it
  2529. # on top of the input labelled as "in".
  2530. movie=in.avi:seek_point=3.2, scale=180:-1, setpts=PTS-STARTPTS [movie];
  2531. [in] setpts=PTS-STARTPTS, [movie] overlay=16:16 [out]
  2532. # read from a video4linux2 device, and overlay it on top of the input
  2533. # labelled as "in"
  2534. movie=/dev/video0:f=video4linux2, scale=180:-1, setpts=PTS-STARTPTS [movie];
  2535. [in] setpts=PTS-STARTPTS, [movie] overlay=16:16 [out]
  2536. @end example
  2537. @section mptestsrc
  2538. Generate various test patterns, as generated by the MPlayer test filter.
  2539. The size of the generated video is fixed, and is 256x256.
  2540. This source is useful in particular for testing encoding features.
  2541. This source accepts an optional sequence of @var{key}=@var{value} pairs,
  2542. separated by ":". The description of the accepted options follows.
  2543. @table @option
  2544. @item rate, r
  2545. Specify the frame rate of the sourced video, as the number of frames
  2546. generated per second. It has to be a string in the format
  2547. @var{frame_rate_num}/@var{frame_rate_den}, an integer number, a float
  2548. number or a valid video frame rate abbreviation. The default value is
  2549. "25".
  2550. @item duration, d
  2551. Set the video duration of the sourced video. The accepted syntax is:
  2552. @example
  2553. [-]HH:MM:SS[.m...]
  2554. [-]S+[.m...]
  2555. @end example
  2556. See also the function @code{av_parse_time()}.
  2557. If not specified, or the expressed duration is negative, the video is
  2558. supposed to be generated forever.
  2559. @item test, t
  2560. Set the number or the name of the test to perform. Supported tests are:
  2561. @table @option
  2562. @item dc_luma
  2563. @item dc_chroma
  2564. @item freq_luma
  2565. @item freq_chroma
  2566. @item amp_luma
  2567. @item amp_chroma
  2568. @item cbp
  2569. @item mv
  2570. @item ring1
  2571. @item ring2
  2572. @item all
  2573. @end table
  2574. Default value is "all", which will cycle through the list of all tests.
  2575. @end table
  2576. For example the following:
  2577. @example
  2578. testsrc=t=dc_luma
  2579. @end example
  2580. will generate a "dc_luma" test pattern.
  2581. @section frei0r_src
  2582. Provide a frei0r source.
  2583. To enable compilation of this filter you need to install the frei0r
  2584. header and configure FFmpeg with @code{--enable-frei0r}.
  2585. The source supports the syntax:
  2586. @example
  2587. @var{size}:@var{rate}:@var{src_name}[@{=|:@}@var{param1}:@var{param2}:...:@var{paramN}]
  2588. @end example
  2589. @var{size} is the size of the video to generate, may be a string of the
  2590. form @var{width}x@var{height} or a frame size abbreviation.
  2591. @var{rate} is the rate of the video to generate, may be a string of
  2592. the form @var{num}/@var{den} or a frame rate abbreviation.
  2593. @var{src_name} is the name to the frei0r source to load. For more
  2594. information regarding frei0r and how to set the parameters read the
  2595. section @ref{frei0r} in the description of the video filters.
  2596. Some examples follow:
  2597. @example
  2598. # generate a frei0r partik0l source with size 200x200 and frame rate 10
  2599. # which is overlayed on the overlay filter main input
  2600. frei0r_src=200x200:10:partik0l=1234 [overlay]; [in][overlay] overlay
  2601. @end example
  2602. @section life
  2603. Generate a life pattern.
  2604. This source is based on a generalization of John Conway's life game.
  2605. The sourced input represents a life grid, each pixel represents a cell
  2606. which can be in one of two possible states, alive or dead. Every cell
  2607. interacts with its eight neighbours, which are the cells that are
  2608. horizontally, vertically, or diagonally adjacent.
  2609. At each interaction the grid evolves according to the adopted rule,
  2610. which specifies the number of neighbor alive cells which will make a
  2611. cell stay alive or born. The @option{rule} option allows to specify
  2612. the rule to adopt.
  2613. This source accepts a list of options in the form of
  2614. @var{key}=@var{value} pairs separated by ":". A description of the
  2615. accepted options follows.
  2616. @table @option
  2617. @item filename, f
  2618. Set the file from which to read the initial grid state. In the file,
  2619. each non-whitespace character is considered an alive cell, and newline
  2620. is used to delimit the end of each row.
  2621. If this option is not specified, the initial grid is generated
  2622. randomly.
  2623. @item rate, r
  2624. Set the video rate, that is the number of frames generated per second.
  2625. Default is 25.
  2626. @item random_fill_ratio, ratio
  2627. Set the random fill ratio for the initial random grid. It is a
  2628. floating point number value ranging from 0 to 1, defaults to 1/PHI.
  2629. It is ignored when a file is specified.
  2630. @item random_seed, seed
  2631. Set the seed for filling the initial random grid, must be an integer
  2632. included between 0 and UINT32_MAX. If not specified, or if explicitly
  2633. set to -1, the filter will try to use a good random seed on a best
  2634. effort basis.
  2635. @item rule
  2636. Set the life rule.
  2637. A rule can be specified with a code of the kind "S@var{NS}/B@var{NB}",
  2638. where @var{NS} and @var{NB} are sequences of numbers in the range 0-8,
  2639. @var{NS} specifies the number of alive neighbor cells which make a
  2640. live cell stay alive, and @var{NB} the number of alive neighbor cells
  2641. which make a dead cell to become alive (i.e. to "born").
  2642. "s" and "b" can be used in place of "S" and "B", respectively.
  2643. Alternatively a rule can be specified by an 18-bits integer. The 9
  2644. high order bits are used to encode the next cell state if it is alive
  2645. for each number of neighbor alive cells, the low order bits specify
  2646. the rule for "borning" new cells. Higher order bits encode for an
  2647. higher number of neighbor cells.
  2648. For example the number 6153 = @code{(12<<9)+9} specifies a stay alive
  2649. rule of 12 and a born rule of 9, which corresponds to "S23/B03".
  2650. Default value is "S23/B3", which is the original Conway's game of life
  2651. rule, and will keep a cell alive if it has 2 or 3 neighbor alive
  2652. cells, and will born a new cell if there are three alive cells around
  2653. a dead cell.
  2654. @item size, s
  2655. Set the size of the output video.
  2656. If @option{filename} is specified, the size is set by default to the
  2657. same size of the input file. If @option{size} is set, it must contain
  2658. the size specified in the input file, and the initial grid defined in
  2659. that file is centered in the larger resulting area.
  2660. If a filename is not specified, the size value defaults to "320x240"
  2661. (used for a randomly generated initial grid).
  2662. @item stitch
  2663. If set to 1, stitch the left and right grid edges together, and the
  2664. top and bottom edges also. Defaults to 1.
  2665. @item mold
  2666. Set cell mold speed. If set, a dead cell will go from @option{death_color} to
  2667. @option{mold_color} with a step of @option{mold}. @option{mold} can have a
  2668. value from 0 to 255.
  2669. @item life_color
  2670. Set the color of living (or new born) cells.
  2671. @item death_color
  2672. Set the color of dead cells. If @option{mold} is set, this is the first color
  2673. used to represent a dead cell.
  2674. @item mold_color
  2675. Set mold color, for definitely dead and moldy cells.
  2676. @end table
  2677. @subsection Examples
  2678. @itemize
  2679. @item
  2680. Read a grid from @file{pattern}, and center it on a grid of size
  2681. 300x300 pixels:
  2682. @example
  2683. life=f=pattern:s=300x300
  2684. @end example
  2685. @item
  2686. Generate a random grid of size 200x200, with a fill ratio of 2/3:
  2687. @example
  2688. life=ratio=2/3:s=200x200
  2689. @end example
  2690. @item
  2691. Specify a custom rule for evolving a randomly generated grid:
  2692. @example
  2693. life=rule=S14/B34
  2694. @end example
  2695. @item
  2696. Full example with slow death effect (mold) using @command{ffplay}:
  2697. @example
  2698. ffplay -f lavfi life=s=300x200:mold=10:r=60:ratio=0.1:death_color=#C83232:life_color=#00ff00,scale=1200:800:flags=16
  2699. @end example
  2700. @end itemize
  2701. @section nullsrc, rgbtestsrc, testsrc
  2702. The @code{nullsrc} source returns unprocessed video frames. It is
  2703. mainly useful to be employed in analysis / debugging tools, or as the
  2704. source for filters which ignore the input data.
  2705. The @code{rgbtestsrc} source generates an RGB test pattern useful for
  2706. detecting RGB vs BGR issues. You should see a red, green and blue
  2707. stripe from top to bottom.
  2708. The @code{testsrc} source generates a test video pattern, showing a
  2709. color pattern, a scrolling gradient and a timestamp. This is mainly
  2710. intended for testing purposes.
  2711. These sources accept an optional sequence of @var{key}=@var{value} pairs,
  2712. separated by ":". The description of the accepted options follows.
  2713. @table @option
  2714. @item size, s
  2715. Specify the size of the sourced video, it may be a string of the form
  2716. @var{width}x@var{height}, or the name of a size abbreviation. The
  2717. default value is "320x240".
  2718. @item rate, r
  2719. Specify the frame rate of the sourced video, as the number of frames
  2720. generated per second. It has to be a string in the format
  2721. @var{frame_rate_num}/@var{frame_rate_den}, an integer number, a float
  2722. number or a valid video frame rate abbreviation. The default value is
  2723. "25".
  2724. @item sar
  2725. Set the sample aspect ratio of the sourced video.
  2726. @item duration, d
  2727. Set the video duration of the sourced video. The accepted syntax is:
  2728. @example
  2729. [-]HH[:MM[:SS[.m...]]]
  2730. [-]S+[.m...]
  2731. @end example
  2732. See also the function @code{av_parse_time()}.
  2733. If not specified, or the expressed duration is negative, the video is
  2734. supposed to be generated forever.
  2735. @item decimals, n
  2736. Set the number of decimals to show in the timestamp, only used in the
  2737. @code{testsrc} source.
  2738. The displayed timestamp value will correspond to the original
  2739. timestamp value multiplied by the power of 10 of the specified
  2740. value. Default value is 0.
  2741. @end table
  2742. For example the following:
  2743. @example
  2744. testsrc=duration=5.3:size=qcif:rate=10
  2745. @end example
  2746. will generate a video with a duration of 5.3 seconds, with size
  2747. 176x144 and a frame rate of 10 frames per second.
  2748. If the input content is to be ignored, @code{nullsrc} can be used. The
  2749. following command generates noise in the luminance plane by employing
  2750. the @code{mp=geq} filter:
  2751. @example
  2752. nullsrc=s=256x256, mp=geq=random(1)*255:128:128
  2753. @end example
  2754. @c man end VIDEO SOURCES
  2755. @chapter Video Sinks
  2756. @c man begin VIDEO SINKS
  2757. Below is a description of the currently available video sinks.
  2758. @section buffersink
  2759. Buffer video frames, and make them available to the end of the filter
  2760. graph.
  2761. This sink is mainly intended for a programmatic use, in particular
  2762. through the interface defined in @file{libavfilter/buffersink.h}.
  2763. It does not require a string parameter in input, but you need to
  2764. specify a pointer to a list of supported pixel formats terminated by
  2765. -1 in the opaque parameter provided to @code{avfilter_init_filter}
  2766. when initializing this sink.
  2767. @section nullsink
  2768. Null video sink, do absolutely nothing with the input video. It is
  2769. mainly useful as a template and to be employed in analysis / debugging
  2770. tools.
  2771. @c man end VIDEO SINKS