filters.texi 104 KB

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