filters.texi 161 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753
  1. @chapter Filtering Introduction
  2. @c man begin FILTERING INTRODUCTION
  3. Filtering in FFmpeg is enabled through the libavfilter library.
  4. In libavfilter, a filter can have multiple inputs and multiple
  5. outputs.
  6. To illustrate the sorts of things that are possible, we consider the
  7. following filtergraph.
  8. @example
  9. input --> split ---------------------> overlay --> output
  10. | ^
  11. | |
  12. +-----> crop --> vflip -------+
  13. @end example
  14. This filtergraph splits the input stream in two streams, sends one
  15. stream through the crop filter and the vflip filter before merging it
  16. back with the other stream by overlaying it on top. You can use the
  17. following command to achieve this:
  18. @example
  19. ffmpeg -i INPUT -vf "split [main][tmp]; [tmp] crop=iw:ih/2:0:0, vflip [flip]; [main][flip] overlay=0:H/2" OUTPUT
  20. @end example
  21. The result will be that in output the top half of the video is mirrored
  22. onto the bottom half.
  23. Filters in the same linear chain are separated by commas, and distinct
  24. linear chains of filters are separated by semicolons. In our example,
  25. @var{crop,vflip} are in one linear chain, @var{split} and
  26. @var{overlay} are separately in another. The points where the linear
  27. chains join are labelled by names enclosed in square brackets. In the
  28. example, the split filter generates two outputs that are associated to
  29. the labels @var{[main]} and @var{[tmp]}.
  30. The stream sent to the second output of @var{split}, labelled as
  31. @var{[tmp]}, is processed through the @var{crop} filter, which crops
  32. away the lower half part of the video, and then vertically flipped. The
  33. @var{overlay} filter takes in input the first unchanged output of the
  34. split filter (which was labelled as @var{[main]}), and overlay on its
  35. lower half the output generated by the @var{crop,vflip} filterchain.
  36. Some filters take in input a list of parameters: they are specified
  37. after the filter name and an equal sign, and are separated from each other
  38. by a colon.
  39. There exist so-called @var{source filters} that do not have an
  40. audio/video input, and @var{sink filters} that will not have audio/video
  41. output.
  42. @c man end FILTERING INTRODUCTION
  43. @chapter graph2dot
  44. @c man begin GRAPH2DOT
  45. The @file{graph2dot} program included in the FFmpeg @file{tools}
  46. directory can be used to parse a filter graph description and issue a
  47. corresponding textual representation in the dot language.
  48. Invoke the command:
  49. @example
  50. graph2dot -h
  51. @end example
  52. to see how to use @file{graph2dot}.
  53. You can then pass the dot description to the @file{dot} program (from
  54. the graphviz suite of programs) and obtain a graphical representation
  55. of the filter graph.
  56. For example the sequence of commands:
  57. @example
  58. echo @var{GRAPH_DESCRIPTION} | \
  59. tools/graph2dot -o graph.tmp && \
  60. dot -Tpng graph.tmp -o graph.png && \
  61. display graph.png
  62. @end example
  63. can be used to create and display an image representing the graph
  64. described by the @var{GRAPH_DESCRIPTION} string. Note that this string must be
  65. a complete self-contained graph, with its inputs and outputs explicitly defined.
  66. For example if your command line is of the form:
  67. @example
  68. ffmpeg -i infile -vf scale=640:360 outfile
  69. @end example
  70. your @var{GRAPH_DESCRIPTION} string will need to be of the form:
  71. @example
  72. nullsrc,scale=640:360,nullsink
  73. @end example
  74. you may also need to set the @var{nullsrc} parameters and add a @var{format}
  75. filter in order to simulate a specific input file.
  76. @c man end GRAPH2DOT
  77. @chapter Filtergraph description
  78. @c man begin FILTERGRAPH DESCRIPTION
  79. A filtergraph is a directed graph of connected filters. It can contain
  80. cycles, and there can be multiple links between a pair of
  81. filters. Each link has one input pad on one side connecting it to one
  82. filter from which it takes its input, and one output pad on the other
  83. side connecting it to the one filter accepting its output.
  84. Each filter in a filtergraph is an instance of a filter class
  85. registered in the application, which defines the features and the
  86. number of input and output pads of the filter.
  87. A filter with no input pads is called a "source", a filter with no
  88. output pads is called a "sink".
  89. @anchor{Filtergraph syntax}
  90. @section Filtergraph syntax
  91. A filtergraph can be represented using a textual representation, which is
  92. recognized by the @option{-filter}/@option{-vf} and @option{-filter_complex}
  93. options in @command{ffmpeg} and @option{-vf} in @command{ffplay}, and by the
  94. @code{avfilter_graph_parse()}/@code{avfilter_graph_parse2()} function defined in
  95. @file{libavfilter/avfiltergraph.h}.
  96. A filterchain consists of a sequence of connected filters, each one
  97. connected to the previous one in the sequence. A filterchain is
  98. represented by a list of ","-separated filter descriptions.
  99. A filtergraph consists of a sequence of filterchains. A sequence of
  100. filterchains is represented by a list of ";"-separated filterchain
  101. descriptions.
  102. A filter is represented by a string of the form:
  103. [@var{in_link_1}]...[@var{in_link_N}]@var{filter_name}=@var{arguments}[@var{out_link_1}]...[@var{out_link_M}]
  104. @var{filter_name} is the name of the filter class of which the
  105. described filter is an instance of, and has to be the name of one of
  106. the filter classes registered in the program.
  107. The name of the filter class is optionally followed by a string
  108. "=@var{arguments}".
  109. @var{arguments} is a string which contains the parameters used to
  110. initialize the filter instance, and are described in the filter
  111. descriptions below.
  112. The list of arguments can be quoted using the character "'" as initial
  113. and ending mark, and the character '\' for escaping the characters
  114. within the quoted text; otherwise the argument string is considered
  115. terminated when the next special character (belonging to the set
  116. "[]=;,") is encountered.
  117. The name and arguments of the filter are optionally preceded and
  118. followed by a list of link labels.
  119. A link label allows to name a link and associate it to a filter output
  120. or input pad. The preceding labels @var{in_link_1}
  121. ... @var{in_link_N}, are associated to the filter input pads,
  122. the following labels @var{out_link_1} ... @var{out_link_M}, are
  123. associated to the output pads.
  124. When two link labels with the same name are found in the
  125. filtergraph, a link between the corresponding input and output pad is
  126. created.
  127. If an output pad is not labelled, it is linked by default to the first
  128. unlabelled input pad of the next filter in the filterchain.
  129. For example in the filterchain:
  130. @example
  131. nullsrc, split[L1], [L2]overlay, nullsink
  132. @end example
  133. the split filter instance has two output pads, and the overlay filter
  134. instance two input pads. The first output pad of split is labelled
  135. "L1", the first input pad of overlay is labelled "L2", and the second
  136. output pad of split is linked to the second input pad of overlay,
  137. which are both unlabelled.
  138. In a complete filterchain all the unlabelled filter input and output
  139. pads must be connected. A filtergraph is considered valid if all the
  140. filter input and output pads of all the filterchains are connected.
  141. Libavfilter will automatically insert scale filters where format
  142. conversion is required. It is possible to specify swscale flags
  143. for those automatically inserted scalers by prepending
  144. @code{sws_flags=@var{flags};}
  145. to the filtergraph description.
  146. Follows a BNF description for the filtergraph syntax:
  147. @example
  148. @var{NAME} ::= sequence of alphanumeric characters and '_'
  149. @var{LINKLABEL} ::= "[" @var{NAME} "]"
  150. @var{LINKLABELS} ::= @var{LINKLABEL} [@var{LINKLABELS}]
  151. @var{FILTER_ARGUMENTS} ::= sequence of chars (eventually quoted)
  152. @var{FILTER} ::= [@var{LINKLABELS}] @var{NAME} ["=" @var{FILTER_ARGUMENTS}] [@var{LINKLABELS}]
  153. @var{FILTERCHAIN} ::= @var{FILTER} [,@var{FILTERCHAIN}]
  154. @var{FILTERGRAPH} ::= [sws_flags=@var{flags};] @var{FILTERCHAIN} [;@var{FILTERGRAPH}]
  155. @end example
  156. @section Notes on filtergraph escaping
  157. Some filter arguments require the use of special characters, typically
  158. @code{:} to separate key=value pairs in a named options list. In this
  159. case the user should perform a first level escaping when specifying
  160. the filter arguments. For example, consider the following literal
  161. string to be embedded in the @ref{drawtext} filter arguments:
  162. @example
  163. this is a 'string': may contain one, or more, special characters
  164. @end example
  165. Since @code{:} is special for the filter arguments syntax, it needs to
  166. be escaped, so you get:
  167. @example
  168. text=this is a \'string\'\: may contain one, or more, special characters
  169. @end example
  170. A second level of escaping is required when embedding the filter
  171. arguments in a filtergraph description, in order to escape all the
  172. filtergraph special characters. Thus the example above becomes:
  173. @example
  174. drawtext=text=this is a \\\'string\\\'\\: may contain one\, or more\, special characters
  175. @end example
  176. Finally an additional level of escaping may be needed when writing the
  177. filtergraph description in a shell command, which depends on the
  178. escaping rules of the adopted shell. For example, assuming that
  179. @code{\} is special and needs to be escaped with another @code{\}, the
  180. previous string will finally result in:
  181. @example
  182. -vf "drawtext=text=this is a \\\\\\'string\\\\\\'\\\\: may contain one\\, or more\\, special characters"
  183. @end example
  184. Sometimes, it might be more convenient to employ quoting in place of
  185. escaping. For example the string:
  186. @example
  187. Caesar: tu quoque, Brute, fili mi
  188. @end example
  189. Can be quoted in the filter arguments as:
  190. @example
  191. text='Caesar: tu quoque, Brute, fili mi'
  192. @end example
  193. And finally inserted in a filtergraph like:
  194. @example
  195. drawtext=text=\'Caesar: tu quoque\, Brute\, fili mi\'
  196. @end example
  197. See the ``Quoting and escaping'' section in the ffmpeg-utils manual
  198. for more information about the escaping and quoting rules adopted by
  199. FFmpeg.
  200. @c man end FILTERGRAPH DESCRIPTION
  201. @chapter Audio Filters
  202. @c man begin AUDIO FILTERS
  203. When you configure your FFmpeg build, you can disable any of the
  204. existing filters using @code{--disable-filters}.
  205. The configure output will show the audio filters included in your
  206. build.
  207. Below is a description of the currently available audio filters.
  208. @section aconvert
  209. Convert the input audio format to the specified formats.
  210. The filter accepts a string of the form:
  211. "@var{sample_format}:@var{channel_layout}".
  212. @var{sample_format} specifies the sample format, and can be a string or the
  213. corresponding numeric value defined in @file{libavutil/samplefmt.h}. Use 'p'
  214. suffix for a planar sample format.
  215. @var{channel_layout} specifies the channel layout, and can be a string
  216. or the corresponding number value defined in @file{libavutil/channel_layout.h}.
  217. The special parameter "auto", signifies that the filter will
  218. automatically select the output format depending on the output filter.
  219. Some examples follow.
  220. @itemize
  221. @item
  222. Convert input to float, planar, stereo:
  223. @example
  224. aconvert=fltp:stereo
  225. @end example
  226. @item
  227. Convert input to unsigned 8-bit, automatically select out channel layout:
  228. @example
  229. aconvert=u8:auto
  230. @end example
  231. @end itemize
  232. @section aformat
  233. Set output format constraints for the input audio. The framework will
  234. negotiate the most appropriate format to minimize conversions.
  235. The filter accepts the following named parameters:
  236. @table @option
  237. @item sample_fmts
  238. A comma-separated list of requested sample formats.
  239. @item sample_rates
  240. A comma-separated list of requested sample rates.
  241. @item channel_layouts
  242. A comma-separated list of requested channel layouts.
  243. @end table
  244. If a parameter is omitted, all values are allowed.
  245. For example to force the output to either unsigned 8-bit or signed 16-bit stereo:
  246. @example
  247. aformat='sample_fmts=u8,s16:channel_layouts=stereo'
  248. @end example
  249. @section amerge
  250. Merge two or more audio streams into a single multi-channel stream.
  251. The filter accepts the following named options:
  252. @table @option
  253. @item inputs
  254. Set the number of inputs. Default is 2.
  255. @end table
  256. If the channel layouts of the inputs are disjoint, and therefore compatible,
  257. the channel layout of the output will be set accordingly and the channels
  258. will be reordered as necessary. If the channel layouts of the inputs are not
  259. disjoint, the output will have all the channels of the first input then all
  260. the channels of the second input, in that order, and the channel layout of
  261. the output will be the default value corresponding to the total number of
  262. channels.
  263. For example, if the first input is in 2.1 (FL+FR+LF) and the second input
  264. is FC+BL+BR, then the output will be in 5.1, with the channels in the
  265. following order: a1, a2, b1, a3, b2, b3 (a1 is the first channel of the
  266. first input, b1 is the first channel of the second input).
  267. On the other hand, if both input are in stereo, the output channels will be
  268. in the default order: a1, a2, b1, b2, and the channel layout will be
  269. arbitrarily set to 4.0, which may or may not be the expected value.
  270. All inputs must have the same sample rate, and format.
  271. If inputs do not have the same duration, the output will stop with the
  272. shortest.
  273. Example: merge two mono files into a stereo stream:
  274. @example
  275. amovie=left.wav [l] ; amovie=right.mp3 [r] ; [l] [r] amerge
  276. @end example
  277. Example: multiple merges:
  278. @example
  279. ffmpeg -f lavfi -i "
  280. amovie=input.mkv:si=0 [a0];
  281. amovie=input.mkv:si=1 [a1];
  282. amovie=input.mkv:si=2 [a2];
  283. amovie=input.mkv:si=3 [a3];
  284. amovie=input.mkv:si=4 [a4];
  285. amovie=input.mkv:si=5 [a5];
  286. [a0][a1][a2][a3][a4][a5] amerge=inputs=6" -c:a pcm_s16le output.mkv
  287. @end example
  288. @section amix
  289. Mixes multiple audio inputs into a single output.
  290. For example
  291. @example
  292. ffmpeg -i INPUT1 -i INPUT2 -i INPUT3 -filter_complex amix=inputs=3:duration=first:dropout_transition=3 OUTPUT
  293. @end example
  294. will mix 3 input audio streams to a single output with the same duration as the
  295. first input and a dropout transition time of 3 seconds.
  296. The filter accepts the following named parameters:
  297. @table @option
  298. @item inputs
  299. Number of inputs. If unspecified, it defaults to 2.
  300. @item duration
  301. How to determine the end-of-stream.
  302. @table @option
  303. @item longest
  304. Duration of longest input. (default)
  305. @item shortest
  306. Duration of shortest input.
  307. @item first
  308. Duration of first input.
  309. @end table
  310. @item dropout_transition
  311. Transition time, in seconds, for volume renormalization when an input
  312. stream ends. The default value is 2 seconds.
  313. @end table
  314. @section anull
  315. Pass the audio source unchanged to the output.
  316. @section apad
  317. Pad the end of a audio stream with silence, this can be used together with
  318. -shortest to extend audio streams to the same length as the video stream.
  319. @anchor{aresample}
  320. @section aresample
  321. Resample the input audio to the specified parameters, using the
  322. libswresample library. If none are specified then the filter will
  323. automatically convert between its input and output.
  324. This filter is also able to stretch/squeeze the audio data to make it match
  325. the timestamps or to inject silence / cut out audio to make it match the
  326. timestamps, do a combination of both or do neither.
  327. The filter accepts the syntax
  328. [@var{sample_rate}:]@var{resampler_options}, where @var{sample_rate}
  329. expresses a sample rate and @var{resampler_options} is a list of
  330. @var{key}=@var{value} pairs, separated by ":". See the
  331. ffmpeg-resampler manual for the complete list of supported options.
  332. For example, to resample the input audio to 44100Hz:
  333. @example
  334. aresample=44100
  335. @end example
  336. To stretch/squeeze samples to the given timestamps, with a maximum of 1000
  337. samples per second compensation:
  338. @example
  339. aresample=async=1000
  340. @end example
  341. @section asetnsamples
  342. Set the number of samples per each output audio frame.
  343. The last output packet may contain a different number of samples, as
  344. the filter will flush all the remaining samples when the input audio
  345. signal its end.
  346. The filter accepts parameters as a list of @var{key}=@var{value} pairs,
  347. separated by ":".
  348. @table @option
  349. @item nb_out_samples, n
  350. Set the number of frames per each output audio frame. The number is
  351. intended as the number of samples @emph{per each channel}.
  352. Default value is 1024.
  353. @item pad, p
  354. If set to 1, the filter will pad the last audio frame with zeroes, so
  355. that the last frame will contain the same number of samples as the
  356. previous ones. Default value is 1.
  357. @end table
  358. For example, to set the number of per-frame samples to 1234 and
  359. disable padding for the last frame, use:
  360. @example
  361. asetnsamples=n=1234:p=0
  362. @end example
  363. @section ashowinfo
  364. Show a line containing various information for each input audio frame.
  365. The input audio is not modified.
  366. The shown line contains a sequence of key/value pairs of the form
  367. @var{key}:@var{value}.
  368. A description of each shown parameter follows:
  369. @table @option
  370. @item n
  371. sequential number of the input frame, starting from 0
  372. @item pts
  373. Presentation timestamp of the input frame, in time base units; the time base
  374. depends on the filter input pad, and is usually 1/@var{sample_rate}.
  375. @item pts_time
  376. presentation timestamp of the input frame in seconds
  377. @item pos
  378. position of the frame in the input stream, -1 if this information in
  379. unavailable and/or meaningless (for example in case of synthetic audio)
  380. @item fmt
  381. sample format
  382. @item chlayout
  383. channel layout
  384. @item rate
  385. sample rate for the audio frame
  386. @item nb_samples
  387. number of samples (per channel) in the frame
  388. @item checksum
  389. Adler-32 checksum (printed in hexadecimal) of the audio data. For planar audio
  390. the data is treated as if all the planes were concatenated.
  391. @item plane_checksums
  392. A list of Adler-32 checksums for each data plane.
  393. @end table
  394. @section asplit
  395. Split input audio into several identical outputs.
  396. The filter accepts a single parameter which specifies the number of outputs. If
  397. unspecified, it defaults to 2.
  398. For example:
  399. @example
  400. [in] asplit [out0][out1]
  401. @end example
  402. will create two separate outputs from the same input.
  403. To create 3 or more outputs, you need to specify the number of
  404. outputs, like in:
  405. @example
  406. [in] asplit=3 [out0][out1][out2]
  407. @end example
  408. @example
  409. ffmpeg -i INPUT -filter_complex asplit=5 OUTPUT
  410. @end example
  411. will create 5 copies of the input audio.
  412. @section astreamsync
  413. Forward two audio streams and control the order the buffers are forwarded.
  414. The argument to the filter is an expression deciding which stream should be
  415. forwarded next: if the result is negative, the first stream is forwarded; if
  416. the result is positive or zero, the second stream is forwarded. It can use
  417. the following variables:
  418. @table @var
  419. @item b1 b2
  420. number of buffers forwarded so far on each stream
  421. @item s1 s2
  422. number of samples forwarded so far on each stream
  423. @item t1 t2
  424. current timestamp of each stream
  425. @end table
  426. The default value is @code{t1-t2}, which means to always forward the stream
  427. that has a smaller timestamp.
  428. Example: stress-test @code{amerge} by randomly sending buffers on the wrong
  429. input, while avoiding too much of a desynchronization:
  430. @example
  431. amovie=file.ogg [a] ; amovie=file.mp3 [b] ;
  432. [a] [b] astreamsync=(2*random(1))-1+tanh(5*(t1-t2)) [a2] [b2] ;
  433. [a2] [b2] amerge
  434. @end example
  435. @section atempo
  436. Adjust audio tempo.
  437. The filter accepts exactly one parameter, the audio tempo. If not
  438. specified then the filter will assume nominal 1.0 tempo. Tempo must
  439. be in the [0.5, 2.0] range.
  440. For example, to slow down audio to 80% tempo:
  441. @example
  442. atempo=0.8
  443. @end example
  444. For example, to speed up audio to 125% tempo:
  445. @example
  446. atempo=1.25
  447. @end example
  448. @section earwax
  449. Make audio easier to listen to on headphones.
  450. This filter adds `cues' to 44.1kHz stereo (i.e. audio CD format) audio
  451. so that when listened to on headphones the stereo image is moved from
  452. inside your head (standard for headphones) to outside and in front of
  453. the listener (standard for speakers).
  454. Ported from SoX.
  455. @section pan
  456. Mix channels with specific gain levels. The filter accepts the output
  457. channel layout followed by a set of channels definitions.
  458. This filter is also designed to remap efficiently the channels of an audio
  459. stream.
  460. The filter accepts parameters of the form:
  461. "@var{l}:@var{outdef}:@var{outdef}:..."
  462. @table @option
  463. @item l
  464. output channel layout or number of channels
  465. @item outdef
  466. output channel specification, of the form:
  467. "@var{out_name}=[@var{gain}*]@var{in_name}[+[@var{gain}*]@var{in_name}...]"
  468. @item out_name
  469. output channel to define, either a channel name (FL, FR, etc.) or a channel
  470. number (c0, c1, etc.)
  471. @item gain
  472. multiplicative coefficient for the channel, 1 leaving the volume unchanged
  473. @item in_name
  474. input channel to use, see out_name for details; it is not possible to mix
  475. named and numbered input channels
  476. @end table
  477. If the `=' in a channel specification is replaced by `<', then the gains for
  478. that specification will be renormalized so that the total is 1, thus
  479. avoiding clipping noise.
  480. @subsection Mixing examples
  481. For example, if you want to down-mix from stereo to mono, but with a bigger
  482. factor for the left channel:
  483. @example
  484. pan=1:c0=0.9*c0+0.1*c1
  485. @end example
  486. A customized down-mix to stereo that works automatically for 3-, 4-, 5- and
  487. 7-channels surround:
  488. @example
  489. pan=stereo: FL < FL + 0.5*FC + 0.6*BL + 0.6*SL : FR < FR + 0.5*FC + 0.6*BR + 0.6*SR
  490. @end example
  491. Note that @command{ffmpeg} integrates a default down-mix (and up-mix) system
  492. that should be preferred (see "-ac" option) unless you have very specific
  493. needs.
  494. @subsection Remapping examples
  495. The channel remapping will be effective if, and only if:
  496. @itemize
  497. @item gain coefficients are zeroes or ones,
  498. @item only one input per channel output,
  499. @end itemize
  500. If all these conditions are satisfied, the filter will notify the user ("Pure
  501. channel mapping detected"), and use an optimized and lossless method to do the
  502. remapping.
  503. For example, if you have a 5.1 source and want a stereo audio stream by
  504. dropping the extra channels:
  505. @example
  506. pan="stereo: c0=FL : c1=FR"
  507. @end example
  508. Given the same source, you can also switch front left and front right channels
  509. and keep the input channel layout:
  510. @example
  511. pan="5.1: c0=c1 : c1=c0 : c2=c2 : c3=c3 : c4=c4 : c5=c5"
  512. @end example
  513. If the input is a stereo audio stream, you can mute the front left channel (and
  514. still keep the stereo channel layout) with:
  515. @example
  516. pan="stereo:c1=c1"
  517. @end example
  518. Still with a stereo audio stream input, you can copy the right channel in both
  519. front left and right:
  520. @example
  521. pan="stereo: c0=FR : c1=FR"
  522. @end example
  523. @section silencedetect
  524. Detect silence in an audio stream.
  525. This filter logs a message when it detects that the input audio volume is less
  526. or equal to a noise tolerance value for a duration greater or equal to the
  527. minimum detected noise duration.
  528. The printed times and duration are expressed in seconds.
  529. @table @option
  530. @item duration, d
  531. Set silence duration until notification (default is 2 seconds).
  532. @item noise, n
  533. Set noise tolerance. Can be specified in dB (in case "dB" is appended to the
  534. specified value) or amplitude ratio. Default is -60dB, or 0.001.
  535. @end table
  536. Detect 5 seconds of silence with -50dB noise tolerance:
  537. @example
  538. silencedetect=n=-50dB:d=5
  539. @end example
  540. Complete example with @command{ffmpeg} to detect silence with 0.0001 noise
  541. tolerance in @file{silence.mp3}:
  542. @example
  543. ffmpeg -f lavfi -i amovie=silence.mp3,silencedetect=noise=0.0001 -f null -
  544. @end example
  545. @section asyncts
  546. Synchronize audio data with timestamps by squeezing/stretching it and/or
  547. dropping samples/adding silence when needed.
  548. As an alternative, you can use @ref{aresample} to do squeezing/stretching.
  549. The filter accepts the following named parameters:
  550. @table @option
  551. @item compensate
  552. Enable stretching/squeezing the data to make it match the timestamps. Disabled
  553. by default. When disabled, time gaps are covered with silence.
  554. @item min_delta
  555. Minimum difference between timestamps and audio data (in seconds) to trigger
  556. adding/dropping samples. Default value is 0.1. If you get non-perfect sync with
  557. this filter, try setting this parameter to 0.
  558. @item max_comp
  559. Maximum compensation in samples per second. Relevant only with compensate=1.
  560. Default value 500.
  561. @item first_pts
  562. Assume the first pts should be this value. The time base is 1 / sample rate.
  563. This allows for padding/trimming at the start of stream. By default, no
  564. assumption is made about the first frame's expected pts, so no padding or
  565. trimming is done. For example, this could be set to 0 to pad the beginning with
  566. silence if an audio stream starts after the video stream or to trim any samples
  567. with a negative pts due to encoder delay.
  568. @end table
  569. @section channelsplit
  570. Split each channel in input audio stream into a separate output stream.
  571. This filter accepts the following named parameters:
  572. @table @option
  573. @item channel_layout
  574. Channel layout of the input stream. Default is "stereo".
  575. @end table
  576. For example, assuming a stereo input MP3 file
  577. @example
  578. ffmpeg -i in.mp3 -filter_complex channelsplit out.mkv
  579. @end example
  580. will create an output Matroska file with two audio streams, one containing only
  581. the left channel and the other the right channel.
  582. To split a 5.1 WAV file into per-channel files
  583. @example
  584. ffmpeg -i in.wav -filter_complex
  585. 'channelsplit=channel_layout=5.1[FL][FR][FC][LFE][SL][SR]'
  586. -map '[FL]' front_left.wav -map '[FR]' front_right.wav -map '[FC]'
  587. front_center.wav -map '[LFE]' lfe.wav -map '[SL]' side_left.wav -map '[SR]'
  588. side_right.wav
  589. @end example
  590. @section channelmap
  591. Remap input channels to new locations.
  592. This filter accepts the following named parameters:
  593. @table @option
  594. @item channel_layout
  595. Channel layout of the output stream.
  596. @item map
  597. Map channels from input to output. The argument is a comma-separated list of
  598. mappings, each in the @code{@var{in_channel}-@var{out_channel}} or
  599. @var{in_channel} form. @var{in_channel} can be either the name of the input
  600. channel (e.g. FL for front left) or its index in the input channel layout.
  601. @var{out_channel} is the name of the output channel or its index in the output
  602. channel layout. If @var{out_channel} is not given then it is implicitly an
  603. index, starting with zero and increasing by one for each mapping.
  604. @end table
  605. If no mapping is present, the filter will implicitly map input channels to
  606. output channels preserving index.
  607. For example, assuming a 5.1+downmix input MOV file
  608. @example
  609. ffmpeg -i in.mov -filter 'channelmap=map=DL-FL\,DR-FR' out.wav
  610. @end example
  611. will create an output WAV file tagged as stereo from the downmix channels of
  612. the input.
  613. To fix a 5.1 WAV improperly encoded in AAC's native channel order
  614. @example
  615. ffmpeg -i in.wav -filter 'channelmap=1\,2\,0\,5\,3\,4:channel_layout=5.1' out.wav
  616. @end example
  617. @section join
  618. Join multiple input streams into one multi-channel stream.
  619. The filter accepts the following named parameters:
  620. @table @option
  621. @item inputs
  622. Number of input streams. Defaults to 2.
  623. @item channel_layout
  624. Desired output channel layout. Defaults to stereo.
  625. @item map
  626. Map channels from inputs to output. The argument is a comma-separated list of
  627. mappings, each in the @code{@var{input_idx}.@var{in_channel}-@var{out_channel}}
  628. form. @var{input_idx} is the 0-based index of the input stream. @var{in_channel}
  629. can be either the name of the input channel (e.g. FL for front left) or its
  630. index in the specified input stream. @var{out_channel} is the name of the output
  631. channel.
  632. @end table
  633. The filter will attempt to guess the mappings when those are not specified
  634. explicitly. It does so by first trying to find an unused matching input channel
  635. and if that fails it picks the first unused input channel.
  636. E.g. to join 3 inputs (with properly set channel layouts)
  637. @example
  638. ffmpeg -i INPUT1 -i INPUT2 -i INPUT3 -filter_complex join=inputs=3 OUTPUT
  639. @end example
  640. To build a 5.1 output from 6 single-channel streams:
  641. @example
  642. ffmpeg -i fl -i fr -i fc -i sl -i sr -i lfe -filter_complex
  643. 'join=inputs=6:channel_layout=5.1:map=0.0-FL\,1.0-FR\,2.0-FC\,3.0-SL\,4.0-SR\,5.0-LFE'
  644. out
  645. @end example
  646. @section resample
  647. Convert the audio sample format, sample rate and channel layout. This filter is
  648. not meant to be used directly.
  649. @section volume
  650. Adjust the input audio volume.
  651. The filter accepts the following named parameters. If the key of the
  652. first options is omitted, the arguments are interpreted according to
  653. the following syntax:
  654. @example
  655. volume=@var{volume}:@var{precision}
  656. @end example
  657. @table @option
  658. @item volume
  659. Expresses how the audio volume will be increased or decreased.
  660. Output values are clipped to the maximum value.
  661. The output audio volume is given by the relation:
  662. @example
  663. @var{output_volume} = @var{volume} * @var{input_volume}
  664. @end example
  665. Default value for @var{volume} is 1.0.
  666. @item precision
  667. Set the mathematical precision.
  668. This determines which input sample formats will be allowed, which affects the
  669. precision of the volume scaling.
  670. @table @option
  671. @item fixed
  672. 8-bit fixed-point; limits input sample format to U8, S16, and S32.
  673. @item float
  674. 32-bit floating-point; limits input sample format to FLT. (default)
  675. @item double
  676. 64-bit floating-point; limits input sample format to DBL.
  677. @end table
  678. @end table
  679. @subsection Examples
  680. @itemize
  681. @item
  682. Halve the input audio volume:
  683. @example
  684. volume=volume=0.5
  685. volume=volume=1/2
  686. volume=volume=-6.0206dB
  687. @end example
  688. In all the above example the named key for @option{volume} can be
  689. omitted, for example like in:
  690. @example
  691. volume=0.5
  692. @end example
  693. @item
  694. Increase input audio power by 6 decibels using fixed-point precision:
  695. @example
  696. volume=volume=6dB:precision=fixed
  697. @end example
  698. @end itemize
  699. @section volumedetect
  700. Detect the volume of the input video.
  701. The filter has no parameters. The input is not modified. Statistics about
  702. the volume will be printed in the log when the input stream end is reached.
  703. In particular it will show the mean volume (root mean square), maximum
  704. volume (on a per-sample basis), and the beginning of an histogram of the
  705. registered volume values (from the maximum value to a cumulated 1/1000 of
  706. the samples).
  707. All volumes are in decibels relative to the maximum PCM value.
  708. Here is an excerpt of the output:
  709. @example
  710. [Parsed_volumedetect_0 @ 0xa23120] mean_volume: -27 dB
  711. [Parsed_volumedetect_0 @ 0xa23120] max_volume: -4 dB
  712. [Parsed_volumedetect_0 @ 0xa23120] histogram_4db: 6
  713. [Parsed_volumedetect_0 @ 0xa23120] histogram_5db: 62
  714. [Parsed_volumedetect_0 @ 0xa23120] histogram_6db: 286
  715. [Parsed_volumedetect_0 @ 0xa23120] histogram_7db: 1042
  716. [Parsed_volumedetect_0 @ 0xa23120] histogram_8db: 2551
  717. [Parsed_volumedetect_0 @ 0xa23120] histogram_9db: 4609
  718. [Parsed_volumedetect_0 @ 0xa23120] histogram_10db: 8409
  719. @end example
  720. It means that:
  721. @itemize
  722. @item
  723. The mean square energy is approximately -27 dB, or 10^-2.7.
  724. @item
  725. The largest sample is at -4 dB, or more precisely between -4 dB and -5 dB.
  726. @item
  727. There are 6 samples at -4 dB, 62 at -5 dB, 286 at -6 dB, etc.
  728. @end itemize
  729. In other words, raising the volume by +4 dB does not cause any clipping,
  730. raising it by +5 dB causes clipping for 6 samples, etc.
  731. @c man end AUDIO FILTERS
  732. @chapter Audio Sources
  733. @c man begin AUDIO SOURCES
  734. Below is a description of the currently available audio sources.
  735. @section abuffer
  736. Buffer audio frames, and make them available to the filter chain.
  737. This source is mainly intended for a programmatic use, in particular
  738. through the interface defined in @file{libavfilter/asrc_abuffer.h}.
  739. It accepts the following mandatory parameters:
  740. @var{sample_rate}:@var{sample_fmt}:@var{channel_layout}
  741. @table @option
  742. @item sample_rate
  743. The sample rate of the incoming audio buffers.
  744. @item sample_fmt
  745. The sample format of the incoming audio buffers.
  746. Either a sample format name or its corresponging integer representation from
  747. the enum AVSampleFormat in @file{libavutil/samplefmt.h}
  748. @item channel_layout
  749. The channel layout of the incoming audio buffers.
  750. Either a channel layout name from channel_layout_map in
  751. @file{libavutil/channel_layout.c} or its corresponding integer representation
  752. from the AV_CH_LAYOUT_* macros in @file{libavutil/channel_layout.h}
  753. @end table
  754. For example:
  755. @example
  756. abuffer=44100:s16p:stereo
  757. @end example
  758. will instruct the source to accept planar 16bit signed stereo at 44100Hz.
  759. Since the sample format with name "s16p" corresponds to the number
  760. 6 and the "stereo" channel layout corresponds to the value 0x3, this is
  761. equivalent to:
  762. @example
  763. abuffer=44100:6:0x3
  764. @end example
  765. @section aevalsrc
  766. Generate an audio signal specified by an expression.
  767. This source accepts in input one or more expressions (one for each
  768. channel), which are evaluated and used to generate a corresponding
  769. audio signal.
  770. It accepts the syntax: @var{exprs}[::@var{options}].
  771. @var{exprs} is a list of expressions separated by ":", one for each
  772. separate channel. In case the @var{channel_layout} is not
  773. specified, the selected channel layout depends on the number of
  774. provided expressions.
  775. @var{options} is an optional sequence of @var{key}=@var{value} pairs,
  776. separated by ":".
  777. The description of the accepted options follows.
  778. @table @option
  779. @item channel_layout, c
  780. Set the channel layout. The number of channels in the specified layout
  781. must be equal to the number of specified expressions.
  782. @item duration, d
  783. Set the minimum duration of the sourced audio. See the function
  784. @code{av_parse_time()} for the accepted format.
  785. Note that the resulting duration may be greater than the specified
  786. duration, as the generated audio is always cut at the end of a
  787. complete frame.
  788. If not specified, or the expressed duration is negative, the audio is
  789. supposed to be generated forever.
  790. @item nb_samples, n
  791. Set the number of samples per channel per each output frame,
  792. default to 1024.
  793. @item sample_rate, s
  794. Specify the sample rate, default to 44100.
  795. @end table
  796. Each expression in @var{exprs} can contain the following constants:
  797. @table @option
  798. @item n
  799. number of the evaluated sample, starting from 0
  800. @item t
  801. time of the evaluated sample expressed in seconds, starting from 0
  802. @item s
  803. sample rate
  804. @end table
  805. @subsection Examples
  806. @itemize
  807. @item
  808. Generate silence:
  809. @example
  810. aevalsrc=0
  811. @end example
  812. @item
  813. Generate a sin signal with frequency of 440 Hz, set sample rate to
  814. 8000 Hz:
  815. @example
  816. aevalsrc="sin(440*2*PI*t)::s=8000"
  817. @end example
  818. @item
  819. Generate a two channels signal, specify the channel layout (Front
  820. Center + Back Center) explicitly:
  821. @example
  822. aevalsrc="sin(420*2*PI*t):cos(430*2*PI*t)::c=FC|BC"
  823. @end example
  824. @item
  825. Generate white noise:
  826. @example
  827. aevalsrc="-2+random(0)"
  828. @end example
  829. @item
  830. Generate an amplitude modulated signal:
  831. @example
  832. aevalsrc="sin(10*2*PI*t)*sin(880*2*PI*t)"
  833. @end example
  834. @item
  835. Generate 2.5 Hz binaural beats on a 360 Hz carrier:
  836. @example
  837. aevalsrc="0.1*sin(2*PI*(360-2.5/2)*t) : 0.1*sin(2*PI*(360+2.5/2)*t)"
  838. @end example
  839. @end itemize
  840. @section anullsrc
  841. Null audio source, return unprocessed audio frames. It is mainly useful
  842. as a template and to be employed in analysis / debugging tools, or as
  843. the source for filters which ignore the input data (for example the sox
  844. synth filter).
  845. It accepts an optional sequence of @var{key}=@var{value} pairs,
  846. separated by ":".
  847. The description of the accepted options follows.
  848. @table @option
  849. @item sample_rate, s
  850. Specify the sample rate, and defaults to 44100.
  851. @item channel_layout, cl
  852. Specify the channel layout, and can be either an integer or a string
  853. representing a channel layout. The default value of @var{channel_layout}
  854. is "stereo".
  855. Check the channel_layout_map definition in
  856. @file{libavutil/channel_layout.c} for the mapping between strings and
  857. channel layout values.
  858. @item nb_samples, n
  859. Set the number of samples per requested frames.
  860. @end table
  861. Follow some examples:
  862. @example
  863. # set the sample rate to 48000 Hz and the channel layout to AV_CH_LAYOUT_MONO.
  864. anullsrc=r=48000:cl=4
  865. # same as
  866. anullsrc=r=48000:cl=mono
  867. @end example
  868. @section abuffer
  869. Buffer audio frames, and make them available to the filter chain.
  870. This source is not intended to be part of user-supplied graph descriptions but
  871. for insertion by calling programs through the interface defined in
  872. @file{libavfilter/buffersrc.h}.
  873. It accepts the following named parameters:
  874. @table @option
  875. @item time_base
  876. Timebase which will be used for timestamps of submitted frames. It must be
  877. either a floating-point number or in @var{numerator}/@var{denominator} form.
  878. @item sample_rate
  879. Audio sample rate.
  880. @item sample_fmt
  881. Name of the sample format, as returned by @code{av_get_sample_fmt_name()}.
  882. @item channel_layout
  883. Channel layout of the audio data, in the form that can be accepted by
  884. @code{av_get_channel_layout()}.
  885. @end table
  886. All the parameters need to be explicitly defined.
  887. @section flite
  888. Synthesize a voice utterance using the libflite library.
  889. To enable compilation of this filter you need to configure FFmpeg with
  890. @code{--enable-libflite}.
  891. Note that the flite library is not thread-safe.
  892. The source accepts parameters as a list of @var{key}=@var{value} pairs,
  893. separated by ":".
  894. The description of the accepted parameters follows.
  895. @table @option
  896. @item list_voices
  897. If set to 1, list the names of the available voices and exit
  898. immediately. Default value is 0.
  899. @item nb_samples, n
  900. Set the maximum number of samples per frame. Default value is 512.
  901. @item textfile
  902. Set the filename containing the text to speak.
  903. @item text
  904. Set the text to speak.
  905. @item voice, v
  906. Set the voice to use for the speech synthesis. Default value is
  907. @code{kal}. See also the @var{list_voices} option.
  908. @end table
  909. @subsection Examples
  910. @itemize
  911. @item
  912. Read from file @file{speech.txt}, and synthetize the text using the
  913. standard flite voice:
  914. @example
  915. flite=textfile=speech.txt
  916. @end example
  917. @item
  918. Read the specified text selecting the @code{slt} voice:
  919. @example
  920. flite=text='So fare thee well, poor devil of a Sub-Sub, whose commentator I am':voice=slt
  921. @end example
  922. @item
  923. Input text to ffmpeg:
  924. @example
  925. ffmpeg -f lavfi -i flite=text='So fare thee well, poor devil of a Sub-Sub, whose commentator I am':voice=slt
  926. @end example
  927. @item
  928. Make @file{ffplay} speak the specified text, using @code{flite} and
  929. the @code{lavfi} device:
  930. @example
  931. ffplay -f lavfi flite=text='No more be grieved for which that thou hast done.'
  932. @end example
  933. @end itemize
  934. For more information about libflite, check:
  935. @url{http://www.speech.cs.cmu.edu/flite/}
  936. @c man end AUDIO SOURCES
  937. @chapter Audio Sinks
  938. @c man begin AUDIO SINKS
  939. Below is a description of the currently available audio sinks.
  940. @section abuffersink
  941. Buffer audio frames, and make them available to the end of filter chain.
  942. This sink is mainly intended for programmatic use, in particular
  943. through the interface defined in @file{libavfilter/buffersink.h}.
  944. It requires a pointer to an AVABufferSinkContext structure, which
  945. defines the incoming buffers' formats, to be passed as the opaque
  946. parameter to @code{avfilter_init_filter} for initialization.
  947. @section anullsink
  948. Null audio sink, do absolutely nothing with the input audio. It is
  949. mainly useful as a template and to be employed in analysis / debugging
  950. tools.
  951. @section abuffersink
  952. This sink is intended for programmatic use. Frames that arrive on this sink can
  953. be retrieved by the calling program using the interface defined in
  954. @file{libavfilter/buffersink.h}.
  955. This filter accepts no parameters.
  956. @c man end AUDIO SINKS
  957. @chapter Video Filters
  958. @c man begin VIDEO FILTERS
  959. When you configure your FFmpeg build, you can disable any of the
  960. existing filters using @code{--disable-filters}.
  961. The configure output will show the video filters included in your
  962. build.
  963. Below is a description of the currently available video filters.
  964. @section alphaextract
  965. Extract the alpha component from the input as a grayscale video. This
  966. is especially useful with the @var{alphamerge} filter.
  967. @section alphamerge
  968. Add or replace the alpha component of the primary input with the
  969. grayscale value of a second input. This is intended for use with
  970. @var{alphaextract} to allow the transmission or storage of frame
  971. sequences that have alpha in a format that doesn't support an alpha
  972. channel.
  973. For example, to reconstruct full frames from a normal YUV-encoded video
  974. and a separate video created with @var{alphaextract}, you might use:
  975. @example
  976. movie=in_alpha.mkv [alpha]; [in][alpha] alphamerge [out]
  977. @end example
  978. Since this filter is designed for reconstruction, it operates on frame
  979. sequences without considering timestamps, and terminates when either
  980. input reaches end of stream. This will cause problems if your encoding
  981. pipeline drops frames. If you're trying to apply an image as an
  982. overlay to a video stream, consider the @var{overlay} filter instead.
  983. @section ass
  984. Same as the @ref{subtitles} filter, except that it doesn't require libavcodec
  985. and libavformat to work. On the other hand, it is limited to ASS (Advanced
  986. Substation Alpha) subtitles files.
  987. @section bbox
  988. Compute the bounding box for the non-black pixels in the input frame
  989. luminance plane.
  990. This filter computes the bounding box containing all the pixels with a
  991. luminance value greater than the minimum allowed value.
  992. The parameters describing the bounding box are printed on the filter
  993. log.
  994. @section blackdetect
  995. Detect video intervals that are (almost) completely black. Can be
  996. useful to detect chapter transitions, commercials, or invalid
  997. recordings. Output lines contains the time for the start, end and
  998. duration of the detected black interval expressed in seconds.
  999. In order to display the output lines, you need to set the loglevel at
  1000. least to the AV_LOG_INFO value.
  1001. This filter accepts a list of options in the form of
  1002. @var{key}=@var{value} pairs separated by ":". A description of the
  1003. accepted options follows.
  1004. @table @option
  1005. @item black_min_duration, d
  1006. Set the minimum detected black duration expressed in seconds. It must
  1007. be a non-negative floating point number.
  1008. Default value is 2.0.
  1009. @item picture_black_ratio_th, pic_th
  1010. Set the threshold for considering a picture "black".
  1011. Express the minimum value for the ratio:
  1012. @example
  1013. @var{nb_black_pixels} / @var{nb_pixels}
  1014. @end example
  1015. for which a picture is considered black.
  1016. Default value is 0.98.
  1017. @item pixel_black_th, pix_th
  1018. Set the threshold for considering a pixel "black".
  1019. The threshold expresses the maximum pixel luminance value for which a
  1020. pixel is considered "black". The provided value is scaled according to
  1021. the following equation:
  1022. @example
  1023. @var{absolute_threshold} = @var{luminance_minimum_value} + @var{pixel_black_th} * @var{luminance_range_size}
  1024. @end example
  1025. @var{luminance_range_size} and @var{luminance_minimum_value} depend on
  1026. the input video format, the range is [0-255] for YUV full-range
  1027. formats and [16-235] for YUV non full-range formats.
  1028. Default value is 0.10.
  1029. @end table
  1030. The following example sets the maximum pixel threshold to the minimum
  1031. value, and detects only black intervals of 2 or more seconds:
  1032. @example
  1033. blackdetect=d=2:pix_th=0.00
  1034. @end example
  1035. @section blackframe
  1036. Detect frames that are (almost) completely black. Can be useful to
  1037. detect chapter transitions or commercials. Output lines consist of
  1038. the frame number of the detected frame, the percentage of blackness,
  1039. the position in the file if known or -1 and the timestamp in seconds.
  1040. In order to display the output lines, you need to set the loglevel at
  1041. least to the AV_LOG_INFO value.
  1042. The filter accepts the syntax:
  1043. @example
  1044. blackframe[=@var{amount}:[@var{threshold}]]
  1045. @end example
  1046. @var{amount} is the percentage of the pixels that have to be below the
  1047. threshold, and defaults to 98.
  1048. @var{threshold} is the threshold below which a pixel value is
  1049. considered black, and defaults to 32.
  1050. @section boxblur
  1051. Apply boxblur algorithm to the input video.
  1052. This filter accepts the parameters:
  1053. @var{luma_radius}:@var{luma_power}:@var{chroma_radius}:@var{chroma_power}:@var{alpha_radius}:@var{alpha_power}
  1054. Chroma and alpha parameters are optional, if not specified they default
  1055. to the corresponding values set for @var{luma_radius} and
  1056. @var{luma_power}.
  1057. @var{luma_radius}, @var{chroma_radius}, and @var{alpha_radius} represent
  1058. the radius in pixels of the box used for blurring the corresponding
  1059. input plane. They are expressions, and can contain the following
  1060. constants:
  1061. @table @option
  1062. @item w, h
  1063. the input width and height in pixels
  1064. @item cw, ch
  1065. the input chroma image width and height in pixels
  1066. @item hsub, vsub
  1067. horizontal and vertical chroma subsample values. For example for the
  1068. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  1069. @end table
  1070. The radius must be a non-negative number, and must not be greater than
  1071. the value of the expression @code{min(w,h)/2} for the luma and alpha planes,
  1072. and of @code{min(cw,ch)/2} for the chroma planes.
  1073. @var{luma_power}, @var{chroma_power}, and @var{alpha_power} represent
  1074. how many times the boxblur filter is applied to the corresponding
  1075. plane.
  1076. Some examples follow:
  1077. @itemize
  1078. @item
  1079. Apply a boxblur filter with luma, chroma, and alpha radius
  1080. set to 2:
  1081. @example
  1082. boxblur=2:1
  1083. @end example
  1084. @item
  1085. Set luma radius to 2, alpha and chroma radius to 0
  1086. @example
  1087. boxblur=2:1:0:0:0:0
  1088. @end example
  1089. @item
  1090. Set luma and chroma radius to a fraction of the video dimension
  1091. @example
  1092. boxblur=min(h\,w)/10:1:min(cw\,ch)/10:1
  1093. @end example
  1094. @end itemize
  1095. @section colormatrix
  1096. The colormatrix filter allows conversion between any of the following color
  1097. space: BT.709 (@var{bt709}), BT.601 (@var{bt601}), SMPTE-240M (@var{smpte240m})
  1098. and FCC (@var{fcc}).
  1099. The syntax of the parameters is @var{source}:@var{destination}:
  1100. @example
  1101. colormatrix=bt601:smpte240m
  1102. @end example
  1103. @section copy
  1104. Copy the input source unchanged to the output. Mainly useful for
  1105. testing purposes.
  1106. @section crop
  1107. Crop the input video.
  1108. This filter accepts a list of @var{key}=@var{value} pairs as argument,
  1109. separated by ':'. If the key of the first options is omitted, the
  1110. arguments are interpreted according to the syntax
  1111. @var{out_w}:@var{out_h}:@var{x}:@var{y}:@var{keep_aspect}.
  1112. A description of the accepted options follows:
  1113. @table @option
  1114. @item w, out_w
  1115. Set the crop area width. It defaults to @code{iw}.
  1116. This expression is evaluated only once during the filter
  1117. configuration.
  1118. @item h, out_h
  1119. Set the crop area width. It defaults to @code{ih}.
  1120. This expression is evaluated only once during the filter
  1121. configuration.
  1122. @item x
  1123. Set the expression for the x top-left coordinate of the cropped area.
  1124. It defaults to @code{(in_w-out_w)/2}.
  1125. This expression is evaluated per-frame.
  1126. @item y
  1127. Set the expression for the y top-left coordinate of the cropped area.
  1128. It defaults to @code{(in_h-out_h)/2}.
  1129. This expression is evaluated per-frame.
  1130. @item keep_aspect
  1131. If set to 1 will force the output display aspect ratio
  1132. to be the same of the input, by changing the output sample aspect
  1133. ratio. It defaults to 0.
  1134. @end table
  1135. The @var{out_w}, @var{out_h}, @var{x}, @var{y} parameters are
  1136. expressions containing the following constants:
  1137. @table @option
  1138. @item x, y
  1139. the computed values for @var{x} and @var{y}. They are evaluated for
  1140. each new frame.
  1141. @item in_w, in_h
  1142. the input width and height
  1143. @item iw, ih
  1144. same as @var{in_w} and @var{in_h}
  1145. @item out_w, out_h
  1146. the output (cropped) width and height
  1147. @item ow, oh
  1148. same as @var{out_w} and @var{out_h}
  1149. @item a
  1150. same as @var{iw} / @var{ih}
  1151. @item sar
  1152. input sample aspect ratio
  1153. @item dar
  1154. input display aspect ratio, it is the same as (@var{iw} / @var{ih}) * @var{sar}
  1155. @item hsub, vsub
  1156. horizontal and vertical chroma subsample values. For example for the
  1157. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  1158. @item n
  1159. the number of input frame, starting from 0
  1160. @item pos
  1161. the position in the file of the input frame, NAN if unknown
  1162. @item t
  1163. timestamp expressed in seconds, NAN if the input timestamp is unknown
  1164. @end table
  1165. The expression for @var{out_w} may depend on the value of @var{out_h},
  1166. and the expression for @var{out_h} may depend on @var{out_w}, but they
  1167. cannot depend on @var{x} and @var{y}, as @var{x} and @var{y} are
  1168. evaluated after @var{out_w} and @var{out_h}.
  1169. The @var{x} and @var{y} parameters specify the expressions for the
  1170. position of the top-left corner of the output (non-cropped) area. They
  1171. are evaluated for each frame. If the evaluated value is not valid, it
  1172. is approximated to the nearest valid value.
  1173. The expression for @var{x} may depend on @var{y}, and the expression
  1174. for @var{y} may depend on @var{x}.
  1175. @subsection Examples
  1176. @itemize
  1177. @item
  1178. Crop area with size 100x100 at position (12,34).
  1179. @example
  1180. crop=100:100:12:34
  1181. @end example
  1182. Using named options, the example above becomes:
  1183. @example
  1184. crop=w=100:h=100:x=12:y=34
  1185. @end example
  1186. @item
  1187. Crop the central input area with size 100x100:
  1188. @example
  1189. crop=100:100
  1190. @end example
  1191. @item
  1192. Crop the central input area with size 2/3 of the input video:
  1193. @example
  1194. crop=2/3*in_w:2/3*in_h
  1195. @end example
  1196. @item
  1197. Crop the input video central square:
  1198. @example
  1199. crop=in_h
  1200. @end example
  1201. @item
  1202. Delimit the rectangle with the top-left corner placed at position
  1203. 100:100 and the right-bottom corner corresponding to the right-bottom
  1204. corner of the input image:
  1205. @example
  1206. crop=in_w-100:in_h-100:100:100
  1207. @end example
  1208. @item
  1209. Crop 10 pixels from the left and right borders, and 20 pixels from
  1210. the top and bottom borders
  1211. @example
  1212. crop=in_w-2*10:in_h-2*20
  1213. @end example
  1214. @item
  1215. Keep only the bottom right quarter of the input image:
  1216. @example
  1217. crop=in_w/2:in_h/2:in_w/2:in_h/2
  1218. @end example
  1219. @item
  1220. Crop height for getting Greek harmony:
  1221. @example
  1222. crop=in_w:1/PHI*in_w
  1223. @end example
  1224. @item
  1225. Appply trembling effect:
  1226. @example
  1227. 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)
  1228. @end example
  1229. @item
  1230. Apply erratic camera effect depending on timestamp:
  1231. @example
  1232. 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)"
  1233. @end example
  1234. @item
  1235. Set x depending on the value of y:
  1236. @example
  1237. crop=in_w/2:in_h/2:y:10+10*sin(n/10)
  1238. @end example
  1239. @end itemize
  1240. @section cropdetect
  1241. Auto-detect crop size.
  1242. Calculate necessary cropping parameters and prints the recommended
  1243. parameters through the logging system. The detected dimensions
  1244. correspond to the non-black area of the input video.
  1245. It accepts the syntax:
  1246. @example
  1247. cropdetect[=@var{limit}[:@var{round}[:@var{reset}]]]
  1248. @end example
  1249. @table @option
  1250. @item limit
  1251. Threshold, which can be optionally specified from nothing (0) to
  1252. everything (255), defaults to 24.
  1253. @item round
  1254. Value which the width/height should be divisible by, defaults to
  1255. 16. The offset is automatically adjusted to center the video. Use 2 to
  1256. get only even dimensions (needed for 4:2:2 video). 16 is best when
  1257. encoding to most video codecs.
  1258. @item reset
  1259. Counter that determines after how many frames cropdetect will reset
  1260. the previously detected largest video area and start over to detect
  1261. the current optimal crop area. Defaults to 0.
  1262. This can be useful when channel logos distort the video area. 0
  1263. indicates never reset and return the largest area encountered during
  1264. playback.
  1265. @end table
  1266. @section decimate
  1267. This filter drops frames that do not differ greatly from the previous
  1268. frame in order to reduce framerate. The main use of this filter is
  1269. for very-low-bitrate encoding (e.g. streaming over dialup modem), but
  1270. it could in theory be used for fixing movies that were
  1271. inverse-telecined incorrectly.
  1272. It accepts the following parameters:
  1273. @var{max}:@var{hi}:@var{lo}:@var{frac}.
  1274. @table @option
  1275. @item max
  1276. Set the maximum number of consecutive frames which can be dropped (if
  1277. positive), or the minimum interval between dropped frames (if
  1278. negative). If the value is 0, the frame is dropped unregarding the
  1279. number of previous sequentially dropped frames.
  1280. Default value is 0.
  1281. @item hi, lo, frac
  1282. Set the dropping threshold values.
  1283. Values for @var{hi} and @var{lo} are for 8x8 pixel blocks and
  1284. represent actual pixel value differences, so a threshold of 64
  1285. corresponds to 1 unit of difference for each pixel, or the same spread
  1286. out differently over the block.
  1287. A frame is a candidate for dropping if no 8x8 blocks differ by more
  1288. than a threshold of @var{hi}, and if no more than @var{frac} blocks (1
  1289. meaning the whole image) differ by more than a threshold of @var{lo}.
  1290. Default value for @var{hi} is 64*12, default value for @var{lo} is
  1291. 64*5, and default value for @var{frac} is 0.33.
  1292. @end table
  1293. @section delogo
  1294. Suppress a TV station logo by a simple interpolation of the surrounding
  1295. pixels. Just set a rectangle covering the logo and watch it disappear
  1296. (and sometimes something even uglier appear - your mileage may vary).
  1297. The filter accepts parameters as a string of the form
  1298. "@var{x}:@var{y}:@var{w}:@var{h}:@var{band}", or as a list of
  1299. @var{key}=@var{value} pairs, separated by ":".
  1300. The description of the accepted parameters follows.
  1301. @table @option
  1302. @item x, y
  1303. Specify the top left corner coordinates of the logo. They must be
  1304. specified.
  1305. @item w, h
  1306. Specify the width and height of the logo to clear. They must be
  1307. specified.
  1308. @item band, t
  1309. Specify the thickness of the fuzzy edge of the rectangle (added to
  1310. @var{w} and @var{h}). The default value is 4.
  1311. @item show
  1312. When set to 1, a green rectangle is drawn on the screen to simplify
  1313. finding the right @var{x}, @var{y}, @var{w}, @var{h} parameters, and
  1314. @var{band} is set to 4. The default value is 0.
  1315. @end table
  1316. Some examples follow.
  1317. @itemize
  1318. @item
  1319. Set a rectangle covering the area with top left corner coordinates 0,0
  1320. and size 100x77, setting a band of size 10:
  1321. @example
  1322. delogo=0:0:100:77:10
  1323. @end example
  1324. @item
  1325. As the previous example, but use named options:
  1326. @example
  1327. delogo=x=0:y=0:w=100:h=77:band=10
  1328. @end example
  1329. @end itemize
  1330. @section deshake
  1331. Attempt to fix small changes in horizontal and/or vertical shift. This
  1332. filter helps remove camera shake from hand-holding a camera, bumping a
  1333. tripod, moving on a vehicle, etc.
  1334. The filter accepts parameters as a string of the form
  1335. "@var{x}:@var{y}:@var{w}:@var{h}:@var{rx}:@var{ry}:@var{edge}:@var{blocksize}:@var{contrast}:@var{search}:@var{filename}"
  1336. A description of the accepted parameters follows.
  1337. @table @option
  1338. @item x, y, w, h
  1339. Specify a rectangular area where to limit the search for motion
  1340. vectors.
  1341. If desired the search for motion vectors can be limited to a
  1342. rectangular area of the frame defined by its top left corner, width
  1343. and height. These parameters have the same meaning as the drawbox
  1344. filter which can be used to visualise the position of the bounding
  1345. box.
  1346. This is useful when simultaneous movement of subjects within the frame
  1347. might be confused for camera motion by the motion vector search.
  1348. If any or all of @var{x}, @var{y}, @var{w} and @var{h} are set to -1
  1349. then the full frame is used. This allows later options to be set
  1350. without specifying the bounding box for the motion vector search.
  1351. Default - search the whole frame.
  1352. @item rx, ry
  1353. Specify the maximum extent of movement in x and y directions in the
  1354. range 0-64 pixels. Default 16.
  1355. @item edge
  1356. Specify how to generate pixels to fill blanks at the edge of the
  1357. frame. An integer from 0 to 3 as follows:
  1358. @table @option
  1359. @item 0
  1360. Fill zeroes at blank locations
  1361. @item 1
  1362. Original image at blank locations
  1363. @item 2
  1364. Extruded edge value at blank locations
  1365. @item 3
  1366. Mirrored edge at blank locations
  1367. @end table
  1368. The default setting is mirror edge at blank locations.
  1369. @item blocksize
  1370. Specify the blocksize to use for motion search. Range 4-128 pixels,
  1371. default 8.
  1372. @item contrast
  1373. Specify the contrast threshold for blocks. Only blocks with more than
  1374. the specified contrast (difference between darkest and lightest
  1375. pixels) will be considered. Range 1-255, default 125.
  1376. @item search
  1377. Specify the search strategy 0 = exhaustive search, 1 = less exhaustive
  1378. search. Default - exhaustive search.
  1379. @item filename
  1380. If set then a detailed log of the motion search is written to the
  1381. specified file.
  1382. @end table
  1383. @section drawbox
  1384. Draw a colored box on the input image.
  1385. The filter accepts parameters as a list of @var{key}=@var{value} pairs,
  1386. separated by ":".
  1387. The description of the accepted parameters follows.
  1388. @table @option
  1389. @item x, y
  1390. Specify the top left corner coordinates of the box. Default to 0.
  1391. @item width, w
  1392. @item height, h
  1393. Specify the width and height of the box, if 0 they are interpreted as
  1394. the input width and height. Default to 0.
  1395. @item color, c
  1396. Specify the color of the box to write, it can be the name of a color
  1397. (case insensitive match) or a 0xRRGGBB[AA] sequence. If the special
  1398. value @code{invert} is used, the box edge color is the same as the
  1399. video with inverted luma.
  1400. @item thickness, t
  1401. Set the thickness of the box edge. Default value is @code{4}.
  1402. @end table
  1403. If the key of the first options is omitted, the arguments are
  1404. interpreted according to the following syntax:
  1405. @example
  1406. drawbox=@var{x}:@var{y}:@var{width}:@var{height}:@var{color}:@var{thickness}
  1407. @end example
  1408. Some examples follow:
  1409. @itemize
  1410. @item
  1411. Draw a black box around the edge of the input image:
  1412. @example
  1413. drawbox
  1414. @end example
  1415. @item
  1416. Draw a box with color red and an opacity of 50%:
  1417. @example
  1418. drawbox=10:20:200:60:red@@0.5
  1419. @end example
  1420. The previous example can be specified as:
  1421. @example
  1422. drawbox=x=10:y=20:w=200:h=60:color=red@@0.5
  1423. @end example
  1424. @item
  1425. Fill the box with pink color:
  1426. @example
  1427. drawbox=x=10:y=10:w=100:h=100:color=pink@@0.5:t=max
  1428. @end example
  1429. @end itemize
  1430. @anchor{drawtext}
  1431. @section drawtext
  1432. Draw text string or text from specified file on top of video using the
  1433. libfreetype library.
  1434. To enable compilation of this filter you need to configure FFmpeg with
  1435. @code{--enable-libfreetype}.
  1436. @subsection Syntax
  1437. The filter accepts parameters as a list of @var{key}=@var{value} pairs,
  1438. separated by ":".
  1439. The description of the accepted parameters follows.
  1440. @table @option
  1441. @item box
  1442. Used to draw a box around text using background color.
  1443. Value should be either 1 (enable) or 0 (disable).
  1444. The default value of @var{box} is 0.
  1445. @item boxcolor
  1446. The color to be used for drawing box around text.
  1447. Either a string (e.g. "yellow") or in 0xRRGGBB[AA] format
  1448. (e.g. "0xff00ff"), possibly followed by an alpha specifier.
  1449. The default value of @var{boxcolor} is "white".
  1450. @item draw
  1451. Set an expression which specifies if the text should be drawn. If the
  1452. expression evaluates to 0, the text is not drawn. This is useful for
  1453. specifying that the text should be drawn only when specific conditions
  1454. are met.
  1455. Default value is "1".
  1456. See below for the list of accepted constants and functions.
  1457. @item expansion
  1458. Select how the @var{text} is expanded. Can be either @code{none},
  1459. @code{strftime} (default for compatibity reasons but deprecated) or
  1460. @code{normal}. See the @ref{drawtext_expansion, Text expansion} section
  1461. below for details.
  1462. @item fix_bounds
  1463. If true, check and fix text coords to avoid clipping.
  1464. @item fontcolor
  1465. The color to be used for drawing fonts.
  1466. Either a string (e.g. "red") or in 0xRRGGBB[AA] format
  1467. (e.g. "0xff000033"), possibly followed by an alpha specifier.
  1468. The default value of @var{fontcolor} is "black".
  1469. @item fontfile
  1470. The font file to be used for drawing text. Path must be included.
  1471. This parameter is mandatory.
  1472. @item fontsize
  1473. The font size to be used for drawing text.
  1474. The default value of @var{fontsize} is 16.
  1475. @item ft_load_flags
  1476. Flags to be used for loading the fonts.
  1477. The flags map the corresponding flags supported by libfreetype, and are
  1478. a combination of the following values:
  1479. @table @var
  1480. @item default
  1481. @item no_scale
  1482. @item no_hinting
  1483. @item render
  1484. @item no_bitmap
  1485. @item vertical_layout
  1486. @item force_autohint
  1487. @item crop_bitmap
  1488. @item pedantic
  1489. @item ignore_global_advance_width
  1490. @item no_recurse
  1491. @item ignore_transform
  1492. @item monochrome
  1493. @item linear_design
  1494. @item no_autohint
  1495. @item end table
  1496. @end table
  1497. Default value is "render".
  1498. For more information consult the documentation for the FT_LOAD_*
  1499. libfreetype flags.
  1500. @item shadowcolor
  1501. The color to be used for drawing a shadow behind the drawn text. It
  1502. can be a color name (e.g. "yellow") or a string in the 0xRRGGBB[AA]
  1503. form (e.g. "0xff00ff"), possibly followed by an alpha specifier.
  1504. The default value of @var{shadowcolor} is "black".
  1505. @item shadowx, shadowy
  1506. The x and y offsets for the text shadow position with respect to the
  1507. position of the text. They can be either positive or negative
  1508. values. Default value for both is "0".
  1509. @item tabsize
  1510. The size in number of spaces to use for rendering the tab.
  1511. Default value is 4.
  1512. @item timecode
  1513. Set the initial timecode representation in "hh:mm:ss[:;.]ff"
  1514. format. It can be used with or without text parameter. @var{timecode_rate}
  1515. option must be specified.
  1516. @item timecode_rate, rate, r
  1517. Set the timecode frame rate (timecode only).
  1518. @item text
  1519. The text string to be drawn. The text must be a sequence of UTF-8
  1520. encoded characters.
  1521. This parameter is mandatory if no file is specified with the parameter
  1522. @var{textfile}.
  1523. @item textfile
  1524. A text file containing text to be drawn. The text must be a sequence
  1525. of UTF-8 encoded characters.
  1526. This parameter is mandatory if no text string is specified with the
  1527. parameter @var{text}.
  1528. If both @var{text} and @var{textfile} are specified, an error is thrown.
  1529. @item reload
  1530. If set to 1, the @var{textfile} will be reloaded before each frame.
  1531. Be sure to update it atomically, or it may be read partially, or even fail.
  1532. @item x, y
  1533. The expressions which specify the offsets where text will be drawn
  1534. within the video frame. They are relative to the top/left border of the
  1535. output image.
  1536. The default value of @var{x} and @var{y} is "0".
  1537. See below for the list of accepted constants and functions.
  1538. @end table
  1539. The parameters for @var{x} and @var{y} are expressions containing the
  1540. following constants and functions:
  1541. @table @option
  1542. @item dar
  1543. input display aspect ratio, it is the same as (@var{w} / @var{h}) * @var{sar}
  1544. @item hsub, vsub
  1545. horizontal and vertical chroma subsample values. For example for the
  1546. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  1547. @item line_h, lh
  1548. the height of each text line
  1549. @item main_h, h, H
  1550. the input height
  1551. @item main_w, w, W
  1552. the input width
  1553. @item max_glyph_a, ascent
  1554. the maximum distance from the baseline to the highest/upper grid
  1555. coordinate used to place a glyph outline point, for all the rendered
  1556. glyphs.
  1557. It is a positive value, due to the grid's orientation with the Y axis
  1558. upwards.
  1559. @item max_glyph_d, descent
  1560. the maximum distance from the baseline to the lowest grid coordinate
  1561. used to place a glyph outline point, for all the rendered glyphs.
  1562. This is a negative value, due to the grid's orientation, with the Y axis
  1563. upwards.
  1564. @item max_glyph_h
  1565. maximum glyph height, that is the maximum height for all the glyphs
  1566. contained in the rendered text, it is equivalent to @var{ascent} -
  1567. @var{descent}.
  1568. @item max_glyph_w
  1569. maximum glyph width, that is the maximum width for all the glyphs
  1570. contained in the rendered text
  1571. @item n
  1572. the number of input frame, starting from 0
  1573. @item rand(min, max)
  1574. return a random number included between @var{min} and @var{max}
  1575. @item sar
  1576. input sample aspect ratio
  1577. @item t
  1578. timestamp expressed in seconds, NAN if the input timestamp is unknown
  1579. @item text_h, th
  1580. the height of the rendered text
  1581. @item text_w, tw
  1582. the width of the rendered text
  1583. @item x, y
  1584. the x and y offset coordinates where the text is drawn.
  1585. These parameters allow the @var{x} and @var{y} expressions to refer
  1586. each other, so you can for example specify @code{y=x/dar}.
  1587. @end table
  1588. If libavfilter was built with @code{--enable-fontconfig}, then
  1589. @option{fontfile} can be a fontconfig pattern or omitted.
  1590. @anchor{drawtext_expansion}
  1591. @subsection Text expansion
  1592. If @option{expansion} is set to @code{strftime} (which is the default for
  1593. now), the filter recognizes strftime() sequences in the provided text and
  1594. expands them accordingly. Check the documentation of strftime(). This
  1595. feature is deprecated.
  1596. If @option{expansion} is set to @code{none}, the text is printed verbatim.
  1597. If @option{expansion} is set to @code{normal} (which will be the default),
  1598. the following expansion mechanism is used.
  1599. The backslash character '\', followed by any character, always expands to
  1600. the second character.
  1601. Sequence of the form @code{%@{...@}} are expanded. The text between the
  1602. braces is a function name, possibly followed by arguments separated by ':'.
  1603. If the arguments contain special characters or delimiters (':' or '@}'),
  1604. they should be escaped.
  1605. Note that they probably must also be escaped as the value for the
  1606. @option{text} option in the filter argument string and as the filter
  1607. argument in the filter graph description, and possibly also for the shell,
  1608. that makes up to four levels of escaping; using a text file avoids these
  1609. problems.
  1610. The following functions are available:
  1611. @table @command
  1612. @item expr, e
  1613. The expression evaluation result.
  1614. It must take one argument specifying the expression to be evaluated,
  1615. which accepts the same constants and functions as the @var{x} and
  1616. @var{y} values. Note that not all constants should be used, for
  1617. example the text size is not known when evaluating the expression, so
  1618. the constants @var{text_w} and @var{text_h} will have an undefined
  1619. value.
  1620. @item gmtime
  1621. The time at which the filter is running, expressed in UTC.
  1622. It can accept an argument: a strftime() format string.
  1623. @item localtime
  1624. The time at which the filter is running, expressed in the local time zone.
  1625. It can accept an argument: a strftime() format string.
  1626. @item n, frame_num
  1627. The frame number, starting from 0.
  1628. @item pts
  1629. The timestamp of the current frame, in seconds, with microsecond accuracy.
  1630. @end table
  1631. @subsection Examples
  1632. Some examples follow.
  1633. @itemize
  1634. @item
  1635. Draw "Test Text" with font FreeSerif, using the default values for the
  1636. optional parameters.
  1637. @example
  1638. drawtext="fontfile=/usr/share/fonts/truetype/freefont/FreeSerif.ttf: text='Test Text'"
  1639. @end example
  1640. @item
  1641. Draw 'Test Text' with font FreeSerif of size 24 at position x=100
  1642. and y=50 (counting from the top-left corner of the screen), text is
  1643. yellow with a red box around it. Both the text and the box have an
  1644. opacity of 20%.
  1645. @example
  1646. drawtext="fontfile=/usr/share/fonts/truetype/freefont/FreeSerif.ttf: text='Test Text':\
  1647. x=100: y=50: fontsize=24: fontcolor=yellow@@0.2: box=1: boxcolor=red@@0.2"
  1648. @end example
  1649. Note that the double quotes are not necessary if spaces are not used
  1650. within the parameter list.
  1651. @item
  1652. Show the text at the center of the video frame:
  1653. @example
  1654. drawtext="fontsize=30:fontfile=FreeSerif.ttf:text='hello world':x=(w-text_w)/2:y=(h-text_h-line_h)/2"
  1655. @end example
  1656. @item
  1657. Show a text line sliding from right to left in the last row of the video
  1658. frame. The file @file{LONG_LINE} is assumed to contain a single line
  1659. with no newlines.
  1660. @example
  1661. drawtext="fontsize=15:fontfile=FreeSerif.ttf:text=LONG_LINE:y=h-line_h:x=-50*t"
  1662. @end example
  1663. @item
  1664. Show the content of file @file{CREDITS} off the bottom of the frame and scroll up.
  1665. @example
  1666. drawtext="fontsize=20:fontfile=FreeSerif.ttf:textfile=CREDITS:y=h-20*t"
  1667. @end example
  1668. @item
  1669. Draw a single green letter "g", at the center of the input video.
  1670. The glyph baseline is placed at half screen height.
  1671. @example
  1672. drawtext="fontsize=60:fontfile=FreeSerif.ttf:fontcolor=green:text=g:x=(w-max_glyph_w)/2:y=h/2-ascent"
  1673. @end example
  1674. @item
  1675. Show text for 1 second every 3 seconds:
  1676. @example
  1677. drawtext="fontfile=FreeSerif.ttf:fontcolor=white:x=100:y=x/dar:draw=lt(mod(t\,3)\,1):text='blink'"
  1678. @end example
  1679. @item
  1680. Use fontconfig to set the font. Note that the colons need to be escaped.
  1681. @example
  1682. drawtext='fontfile=Linux Libertine O-40\:style=Semibold:text=FFmpeg'
  1683. @end example
  1684. @item
  1685. Print the date of a real-time encoding (see strftime(3)):
  1686. @example
  1687. drawtext='fontfile=FreeSans.ttf:expansion=normal:text=%@{localtime:%a %b %d %Y@}'
  1688. @end example
  1689. @end itemize
  1690. For more information about libfreetype, check:
  1691. @url{http://www.freetype.org/}.
  1692. For more information about fontconfig, check:
  1693. @url{http://freedesktop.org/software/fontconfig/fontconfig-user.html}.
  1694. @section edgedetect
  1695. Detect and draw edges. The filter uses the Canny Edge Detection algorithm.
  1696. This filter accepts the following optional named parameters:
  1697. @table @option
  1698. @item low, high
  1699. Set low and high threshold values used by the Canny thresholding
  1700. algorithm.
  1701. The high threshold selects the "strong" edge pixels, which are then
  1702. connected through 8-connectivity with the "weak" edge pixels selected
  1703. by the low threshold.
  1704. @var{low} and @var{high} threshold values must be choosen in the range
  1705. [0,1], and @var{low} should be lesser or equal to @var{high}.
  1706. Default value for @var{low} is @code{20/255}, and default value for @var{high}
  1707. is @code{50/255}.
  1708. @end table
  1709. Example:
  1710. @example
  1711. edgedetect=low=0.1:high=0.4
  1712. @end example
  1713. @section fade
  1714. Apply fade-in/out effect to input video.
  1715. It accepts the parameters:
  1716. @var{type}:@var{start_frame}:@var{nb_frames}[:@var{options}]
  1717. @var{type} specifies if the effect type, can be either "in" for
  1718. fade-in, or "out" for a fade-out effect.
  1719. @var{start_frame} specifies the number of the start frame for starting
  1720. to apply the fade effect.
  1721. @var{nb_frames} specifies the number of frames for which the fade
  1722. effect has to last. At the end of the fade-in effect the output video
  1723. will have the same intensity as the input video, at the end of the
  1724. fade-out transition the output video will be completely black.
  1725. @var{options} is an optional sequence of @var{key}=@var{value} pairs,
  1726. separated by ":". The description of the accepted options follows.
  1727. @table @option
  1728. @item type, t
  1729. See @var{type}.
  1730. @item start_frame, s
  1731. See @var{start_frame}.
  1732. @item nb_frames, n
  1733. See @var{nb_frames}.
  1734. @item alpha
  1735. If set to 1, fade only alpha channel, if one exists on the input.
  1736. Default value is 0.
  1737. @end table
  1738. A few usage examples follow, usable too as test scenarios.
  1739. @example
  1740. # fade in first 30 frames of video
  1741. fade=in:0:30
  1742. # fade out last 45 frames of a 200-frame video
  1743. fade=out:155:45
  1744. # fade in first 25 frames and fade out last 25 frames of a 1000-frame video
  1745. fade=in:0:25, fade=out:975:25
  1746. # make first 5 frames black, then fade in from frame 5-24
  1747. fade=in:5:20
  1748. # fade in alpha over first 25 frames of video
  1749. fade=in:0:25:alpha=1
  1750. @end example
  1751. @section field
  1752. Extract a single field from an interlaced image using stride
  1753. arithmetic to avoid wasting CPU time. The output frames are marked as
  1754. non-interlaced.
  1755. This filter accepts the following named options:
  1756. @table @option
  1757. @item type
  1758. Specify whether to extract the top (if the value is @code{0} or
  1759. @code{top}) or the bottom field (if the value is @code{1} or
  1760. @code{bottom}).
  1761. @end table
  1762. If the option key is not specified, the first value sets the @var{type}
  1763. option. For example:
  1764. @example
  1765. field=bottom
  1766. @end example
  1767. is equivalent to:
  1768. @example
  1769. field=type=bottom
  1770. @end example
  1771. @section fieldorder
  1772. Transform the field order of the input video.
  1773. It accepts one parameter which specifies the required field order that
  1774. the input interlaced video will be transformed to. The parameter can
  1775. assume one of the following values:
  1776. @table @option
  1777. @item 0 or bff
  1778. output bottom field first
  1779. @item 1 or tff
  1780. output top field first
  1781. @end table
  1782. Default value is "tff".
  1783. Transformation is achieved by shifting the picture content up or down
  1784. by one line, and filling the remaining line with appropriate picture content.
  1785. This method is consistent with most broadcast field order converters.
  1786. If the input video is not flagged as being interlaced, or it is already
  1787. flagged as being of the required output field order then this filter does
  1788. not alter the incoming video.
  1789. This filter is very useful when converting to or from PAL DV material,
  1790. which is bottom field first.
  1791. For example:
  1792. @example
  1793. ffmpeg -i in.vob -vf "fieldorder=bff" out.dv
  1794. @end example
  1795. @section fifo
  1796. Buffer input images and send them when they are requested.
  1797. This filter is mainly useful when auto-inserted by the libavfilter
  1798. framework.
  1799. The filter does not take parameters.
  1800. @section format
  1801. Convert the input video to one of the specified pixel formats.
  1802. Libavfilter will try to pick one that is supported for the input to
  1803. the next filter.
  1804. The filter accepts a list of pixel format names, separated by ":",
  1805. for example "yuv420p:monow:rgb24".
  1806. Some examples follow:
  1807. @example
  1808. # convert the input video to the format "yuv420p"
  1809. format=yuv420p
  1810. # convert the input video to any of the formats in the list
  1811. format=yuv420p:yuv444p:yuv410p
  1812. @end example
  1813. @section fps
  1814. Convert the video to specified constant framerate by duplicating or dropping
  1815. frames as necessary.
  1816. This filter accepts the following named parameters:
  1817. @table @option
  1818. @item fps
  1819. Desired output framerate. The default is @code{25}.
  1820. @item round
  1821. Rounding method.
  1822. Possible values are:
  1823. @table @option
  1824. @item zero
  1825. zero round towards 0
  1826. @item inf
  1827. round away from 0
  1828. @item down
  1829. round towards -infinity
  1830. @item up
  1831. round towards +infinity
  1832. @item near
  1833. round to nearest
  1834. @end table
  1835. The default is @code{near}.
  1836. @end table
  1837. Alternatively, the options can be specified as a flat string:
  1838. @var{fps}[:@var{round}].
  1839. See also the @ref{setpts} filter.
  1840. @section framestep
  1841. Select one frame every N.
  1842. This filter accepts in input a string representing a positive
  1843. integer. Default argument is @code{1}.
  1844. @anchor{frei0r}
  1845. @section frei0r
  1846. Apply a frei0r effect to the input video.
  1847. To enable compilation of this filter you need to install the frei0r
  1848. header and configure FFmpeg with @code{--enable-frei0r}.
  1849. The filter supports the syntax:
  1850. @example
  1851. @var{filter_name}[@{:|=@}@var{param1}:@var{param2}:...:@var{paramN}]
  1852. @end example
  1853. @var{filter_name} is the name of the frei0r effect to load. If the
  1854. environment variable @env{FREI0R_PATH} is defined, the frei0r effect
  1855. is searched in each one of the directories specified by the colon (or
  1856. semicolon on Windows platforms) separated list in @env{FREIOR_PATH},
  1857. otherwise in the standard frei0r paths, which are in this order:
  1858. @file{HOME/.frei0r-1/lib/}, @file{/usr/local/lib/frei0r-1/},
  1859. @file{/usr/lib/frei0r-1/}.
  1860. @var{param1}, @var{param2}, ... , @var{paramN} specify the parameters
  1861. for the frei0r effect.
  1862. A frei0r effect parameter can be a boolean (whose values are specified
  1863. with "y" and "n"), a double, a color (specified by the syntax
  1864. @var{R}/@var{G}/@var{B}, @var{R}, @var{G}, and @var{B} being float
  1865. numbers from 0.0 to 1.0) or by an @code{av_parse_color()} color
  1866. description), a position (specified by the syntax @var{X}/@var{Y},
  1867. @var{X} and @var{Y} being float numbers) and a string.
  1868. The number and kind of parameters depend on the loaded effect. If an
  1869. effect parameter is not specified the default value is set.
  1870. Some examples follow:
  1871. @itemize
  1872. @item
  1873. Apply the distort0r effect, set the first two double parameters:
  1874. @example
  1875. frei0r=distort0r:0.5:0.01
  1876. @end example
  1877. @item
  1878. Apply the colordistance effect, take a color as first parameter:
  1879. @example
  1880. frei0r=colordistance:0.2/0.3/0.4
  1881. frei0r=colordistance:violet
  1882. frei0r=colordistance:0x112233
  1883. @end example
  1884. @item
  1885. Apply the perspective effect, specify the top left and top right image
  1886. positions:
  1887. @example
  1888. frei0r=perspective:0.2/0.2:0.8/0.2
  1889. @end example
  1890. @end itemize
  1891. For more information see:
  1892. @url{http://frei0r.dyne.org}
  1893. @section geq
  1894. The filter takes one, two or three equations as parameter, separated by ':'.
  1895. The first equation is mandatory and applies to the luma plane. The two
  1896. following are respectively for chroma blue and chroma red planes.
  1897. The filter syntax allows named parameters:
  1898. @table @option
  1899. @item lum_expr
  1900. the luminance expression
  1901. @item cb_expr
  1902. the chrominance blue expression
  1903. @item cr_expr
  1904. the chrominance red expression
  1905. @end table
  1906. If one of the chrominance expression is not defined, it falls back on the other
  1907. one. If none of them are specified, they will evaluate the luminance
  1908. expression.
  1909. The expressions can use the following variables and functions:
  1910. @table @option
  1911. @item N
  1912. The sequential number of the filtered frame, starting from @code{0}.
  1913. @item X, Y
  1914. The coordinates of the current sample.
  1915. @item W, H
  1916. The width and height of the image.
  1917. @item SW, SH
  1918. Width and height scale depending on the currently filtered plane. It is the
  1919. ratio between the corresponding luma plane number of pixels and the current
  1920. plane ones. E.g. for YUV4:2:0 the values are @code{1,1} for the luma plane, and
  1921. @code{0.5,0.5} for chroma planes.
  1922. @item T
  1923. Time of the current frame, expressed in seconds.
  1924. @item p(x, y)
  1925. Return the value of the pixel at location (@var{x},@var{y}) of the current
  1926. plane.
  1927. @item lum(x, y)
  1928. Return the value of the pixel at location (@var{x},@var{y}) of the luminance
  1929. plane.
  1930. @item cb(x, y)
  1931. Return the value of the pixel at location (@var{x},@var{y}) of the
  1932. blue-difference chroma plane.
  1933. @item cr(x, y)
  1934. Return the value of the pixel at location (@var{x},@var{y}) of the
  1935. red-difference chroma plane.
  1936. @end table
  1937. For functions, if @var{x} and @var{y} are outside the area, the value will be
  1938. automatically clipped to the closer edge.
  1939. Some examples follow:
  1940. @itemize
  1941. @item
  1942. Flip the image horizontally:
  1943. @example
  1944. geq=p(W-X\,Y)
  1945. @end example
  1946. @item
  1947. Generate a bidimensional sine wave, with angle @code{PI/3} and a
  1948. wavelength of 100 pixels:
  1949. @example
  1950. geq=128 + 100*sin(2*(PI/100)*(cos(PI/3)*(X-50*T) + sin(PI/3)*Y)):128:128
  1951. @end example
  1952. @item
  1953. Generate a fancy enigmatic moving light:
  1954. @example
  1955. nullsrc=s=256x256,geq=random(1)/hypot(X-cos(N*0.07)*W/2-W/2\,Y-sin(N*0.09)*H/2-H/2)^2*1000000*sin(N*0.02):128:128
  1956. @end example
  1957. @end itemize
  1958. @section gradfun
  1959. Fix the banding artifacts that are sometimes introduced into nearly flat
  1960. regions by truncation to 8bit color depth.
  1961. Interpolate the gradients that should go where the bands are, and
  1962. dither them.
  1963. This filter is designed for playback only. Do not use it prior to
  1964. lossy compression, because compression tends to lose the dither and
  1965. bring back the bands.
  1966. The filter accepts a list of options in the form of @var{key}=@var{value} pairs
  1967. separated by ":". A description of the accepted options follows.
  1968. @table @option
  1969. @item strength
  1970. The maximum amount by which the filter will change
  1971. any one pixel. Also the threshold for detecting nearly flat
  1972. regions. Acceptable values range from @code{0.51} to @code{64}, default value
  1973. is @code{1.2}.
  1974. @item radius
  1975. The neighborhood to fit the gradient to. A larger
  1976. radius makes for smoother gradients, but also prevents the filter from
  1977. modifying the pixels near detailed regions. Acceptable values are
  1978. @code{8-32}, default value is @code{16}.
  1979. @end table
  1980. Alternatively, the options can be specified as a flat string:
  1981. @var{strength}[:@var{radius}]
  1982. @subsection Examples
  1983. @itemize
  1984. @item
  1985. Apply the filter with a @code{3.5} strength and radius of @code{8}:
  1986. @example
  1987. gradfun=3.5:8
  1988. @end example
  1989. @item
  1990. Specify radius, omitting the strength (which will fall-back to the default
  1991. value):
  1992. @example
  1993. gradfun=radius=8
  1994. @end example
  1995. @end itemize
  1996. @section hflip
  1997. Flip the input video horizontally.
  1998. For example to horizontally flip the input video with @command{ffmpeg}:
  1999. @example
  2000. ffmpeg -i in.avi -vf "hflip" out.avi
  2001. @end example
  2002. @section histeq
  2003. This filter applies a global color histogram equalization on a
  2004. per-frame basis.
  2005. It can be used to correct video that has a compressed range of pixel
  2006. intensities. The filter redistributes the pixel intensities to
  2007. equalize their distribution across the intensity range. It may be
  2008. viewed as an "automatically adjusting contrast filter". This filter is
  2009. useful only for correcting degraded or poorly captured source
  2010. video.
  2011. The filter accepts parameters as a list of @var{key}=@var{value}
  2012. pairs, separated by ":". If the key of the first options is omitted,
  2013. the arguments are interpreted according to syntax
  2014. @var{strength}:@var{intensity}:@var{antibanding}.
  2015. This filter accepts the following named options:
  2016. @table @option
  2017. @item strength
  2018. Determine the amount of equalization to be applied. As the strength
  2019. is reduced, the distribution of pixel intensities more-and-more
  2020. approaches that of the input frame. The value must be a float number
  2021. in the range [0,1] and defaults to 0.200.
  2022. @item intensity
  2023. Set the maximum intensity that can generated and scale the output
  2024. values appropriately. The strength should be set as desired and then
  2025. the intensity can be limited if needed to avoid washing-out. The value
  2026. must be a float number in the range [0,1] and defaults to 0.210.
  2027. @item antibanding
  2028. Set the antibanding level. If enabled the filter will randomly vary
  2029. the luminance of output pixels by a small amount to avoid banding of
  2030. the histogram. Possible values are @code{none}, @code{weak} or
  2031. @code{strong}. It defaults to @code{none}.
  2032. @end table
  2033. @section hqdn3d
  2034. High precision/quality 3d denoise filter. This filter aims to reduce
  2035. image noise producing smooth images and making still images really
  2036. still. It should enhance compressibility.
  2037. It accepts the following optional parameters:
  2038. @var{luma_spatial}:@var{chroma_spatial}:@var{luma_tmp}:@var{chroma_tmp}
  2039. @table @option
  2040. @item luma_spatial
  2041. a non-negative float number which specifies spatial luma strength,
  2042. defaults to 4.0
  2043. @item chroma_spatial
  2044. a non-negative float number which specifies spatial chroma strength,
  2045. defaults to 3.0*@var{luma_spatial}/4.0
  2046. @item luma_tmp
  2047. a float number which specifies luma temporal strength, defaults to
  2048. 6.0*@var{luma_spatial}/4.0
  2049. @item chroma_tmp
  2050. a float number which specifies chroma temporal strength, defaults to
  2051. @var{luma_tmp}*@var{chroma_spatial}/@var{luma_spatial}
  2052. @end table
  2053. @section hue
  2054. Modify the hue and/or the saturation of the input.
  2055. This filter accepts the following optional named options:
  2056. @table @option
  2057. @item h
  2058. Specify the hue angle as a number of degrees. It accepts a float
  2059. number or an expression, and defaults to 0.0.
  2060. @item H
  2061. Specify the hue angle as a number of degrees. It accepts a float
  2062. number or an expression, and defaults to 0.0.
  2063. @item s
  2064. Specify the saturation in the [-10,10] range. It accepts a float number and
  2065. defaults to 1.0.
  2066. @end table
  2067. The @var{h}, @var{H} and @var{s} parameters are expressions containing the
  2068. following constants:
  2069. @table @option
  2070. @item n
  2071. frame count of the input frame starting from 0
  2072. @item pts
  2073. presentation timestamp of the input frame expressed in time base units
  2074. @item r
  2075. frame rate of the input video, NAN if the input frame rate is unknown
  2076. @item t
  2077. timestamp expressed in seconds, NAN if the input timestamp is unknown
  2078. @item tb
  2079. time base of the input video
  2080. @end table
  2081. The options can also be set using the syntax: @var{hue}:@var{saturation}
  2082. In this case @var{hue} is expressed in degrees.
  2083. Some examples follow:
  2084. @itemize
  2085. @item
  2086. Set the hue to 90 degrees and the saturation to 1.0:
  2087. @example
  2088. hue=h=90:s=1
  2089. @end example
  2090. @item
  2091. Same command but expressing the hue in radians:
  2092. @example
  2093. hue=H=PI/2:s=1
  2094. @end example
  2095. @item
  2096. Same command without named options, hue must be expressed in degrees:
  2097. @example
  2098. hue=90:1
  2099. @end example
  2100. @item
  2101. Note that "h:s" syntax does not support expressions for the values of
  2102. h and s, so the following example will issue an error:
  2103. @example
  2104. hue=PI/2:1
  2105. @end example
  2106. @item
  2107. Rotate hue and make the saturation swing between 0
  2108. and 2 over a period of 1 second:
  2109. @example
  2110. hue="H=2*PI*t: s=sin(2*PI*t)+1"
  2111. @end example
  2112. @item
  2113. Apply a 3 seconds saturation fade-in effect starting at 0:
  2114. @example
  2115. hue="s=min(t/3\,1)"
  2116. @end example
  2117. The general fade-in expression can be written as:
  2118. @example
  2119. hue="s=min(0\, max((t-START)/DURATION\, 1))"
  2120. @end example
  2121. @item
  2122. Apply a 3 seconds saturation fade-out effect starting at 5 seconds:
  2123. @example
  2124. hue="s=max(0\, min(1\, (8-t)/3))"
  2125. @end example
  2126. The general fade-out expression can be written as:
  2127. @example
  2128. hue="s=max(0\, min(1\, (START+DURATION-t)/DURATION))"
  2129. @end example
  2130. @end itemize
  2131. @subsection Commands
  2132. This filter supports the following command:
  2133. @table @option
  2134. @item reinit
  2135. Modify the hue and/or the saturation of the input video.
  2136. The command accepts the same named options and syntax than when calling the
  2137. filter from the command-line.
  2138. If a parameter is omitted, it is kept at its current value.
  2139. @end table
  2140. @section idet
  2141. Interlaceing detect filter. This filter tries to detect if the input is
  2142. interlaced or progressive. Top or bottom field first.
  2143. @section kerndeint
  2144. Deinterlace input video by applying Donald Graft's adaptive kernel
  2145. deinterling. Work on interlaced parts of a video to produce
  2146. progressive frames.
  2147. This filter accepts parameters as a list of @var{key}=@var{value}
  2148. pairs, separated by ":". If the key of the first options is omitted,
  2149. the arguments are interpreted according to the following syntax:
  2150. @var{thresh}:@var{map}:@var{order}:@var{sharp}:@var{twoway}.
  2151. The description of the accepted parameters follows.
  2152. @table @option
  2153. @item thresh
  2154. Set the threshold which affects the filter's tolerance when
  2155. determining if a pixel line must be processed. It must be an integer
  2156. in the range [0,255] and defaults to 10. A value of 0 will result in
  2157. applying the process on every pixels.
  2158. @item map
  2159. Paint pixels exceeding the threshold value to white if set to 1.
  2160. Default is 0.
  2161. @item order
  2162. Set the fields order. Swap fields if set to 1, leave fields alone if
  2163. 0. Default is 0.
  2164. @item sharp
  2165. Enable additional sharpening if set to 1. Default is 0.
  2166. @item twoway
  2167. Enable twoway sharpening if set to 1. Default is 0.
  2168. @end table
  2169. @subsection Examples
  2170. @itemize
  2171. @item
  2172. Apply default values:
  2173. @example
  2174. kerndeint=thresh=10:map=0:order=0:sharp=0:twoway=0
  2175. @end example
  2176. @item
  2177. Enable additional sharpening:
  2178. @example
  2179. kerndeint=sharp=1
  2180. @end example
  2181. @item
  2182. Paint processed pixels in white:
  2183. @example
  2184. kerndeint=map=1
  2185. @end example
  2186. @end itemize
  2187. @section lut, lutrgb, lutyuv
  2188. Compute a look-up table for binding each pixel component input value
  2189. to an output value, and apply it to input video.
  2190. @var{lutyuv} applies a lookup table to a YUV input video, @var{lutrgb}
  2191. to an RGB input video.
  2192. These filters accept in input a ":"-separated list of options, which
  2193. specify the expressions used for computing the lookup table for the
  2194. corresponding pixel component values.
  2195. The @var{lut} filter requires either YUV or RGB pixel formats in
  2196. input, and accepts the options:
  2197. @table @option
  2198. @item @var{c0} (first pixel component)
  2199. @item @var{c1} (second pixel component)
  2200. @item @var{c2} (third pixel component)
  2201. @item @var{c3} (fourth pixel component, corresponds to the alpha component)
  2202. @end table
  2203. The exact component associated to each option depends on the format in
  2204. input.
  2205. The @var{lutrgb} filter requires RGB pixel formats in input, and
  2206. accepts the options:
  2207. @table @option
  2208. @item @var{r} (red component)
  2209. @item @var{g} (green component)
  2210. @item @var{b} (blue component)
  2211. @item @var{a} (alpha component)
  2212. @end table
  2213. The @var{lutyuv} filter requires YUV pixel formats in input, and
  2214. accepts the options:
  2215. @table @option
  2216. @item @var{y} (Y/luminance component)
  2217. @item @var{u} (U/Cb component)
  2218. @item @var{v} (V/Cr component)
  2219. @item @var{a} (alpha component)
  2220. @end table
  2221. The expressions can contain the following constants and functions:
  2222. @table @option
  2223. @item w, h
  2224. the input width and height
  2225. @item val
  2226. input value for the pixel component
  2227. @item clipval
  2228. the input value clipped in the @var{minval}-@var{maxval} range
  2229. @item maxval
  2230. maximum value for the pixel component
  2231. @item minval
  2232. minimum value for the pixel component
  2233. @item negval
  2234. the negated value for the pixel component value clipped in the
  2235. @var{minval}-@var{maxval} range , it corresponds to the expression
  2236. "maxval-clipval+minval"
  2237. @item clip(val)
  2238. the computed value in @var{val} clipped in the
  2239. @var{minval}-@var{maxval} range
  2240. @item gammaval(gamma)
  2241. the computed gamma correction value of the pixel component value
  2242. clipped in the @var{minval}-@var{maxval} range, corresponds to the
  2243. expression
  2244. "pow((clipval-minval)/(maxval-minval)\,@var{gamma})*(maxval-minval)+minval"
  2245. @end table
  2246. All expressions default to "val".
  2247. Some examples follow:
  2248. @example
  2249. # negate input video
  2250. lutrgb="r=maxval+minval-val:g=maxval+minval-val:b=maxval+minval-val"
  2251. lutyuv="y=maxval+minval-val:u=maxval+minval-val:v=maxval+minval-val"
  2252. # the above is the same as
  2253. lutrgb="r=negval:g=negval:b=negval"
  2254. lutyuv="y=negval:u=negval:v=negval"
  2255. # negate luminance
  2256. lutyuv=y=negval
  2257. # remove chroma components, turns the video into a graytone image
  2258. lutyuv="u=128:v=128"
  2259. # apply a luma burning effect
  2260. lutyuv="y=2*val"
  2261. # remove green and blue components
  2262. lutrgb="g=0:b=0"
  2263. # set a constant alpha channel value on input
  2264. format=rgba,lutrgb=a="maxval-minval/2"
  2265. # correct luminance gamma by a 0.5 factor
  2266. lutyuv=y=gammaval(0.5)
  2267. @end example
  2268. @section mp
  2269. Apply an MPlayer filter to the input video.
  2270. This filter provides a wrapper around most of the filters of
  2271. MPlayer/MEncoder.
  2272. This wrapper is considered experimental. Some of the wrapped filters
  2273. may not work properly and we may drop support for them, as they will
  2274. be implemented natively into FFmpeg. Thus you should avoid
  2275. depending on them when writing portable scripts.
  2276. The filters accepts the parameters:
  2277. @var{filter_name}[:=]@var{filter_params}
  2278. @var{filter_name} is the name of a supported MPlayer filter,
  2279. @var{filter_params} is a string containing the parameters accepted by
  2280. the named filter.
  2281. The list of the currently supported filters follows:
  2282. @table @var
  2283. @item detc
  2284. @item dint
  2285. @item divtc
  2286. @item down3dright
  2287. @item dsize
  2288. @item eq2
  2289. @item eq
  2290. @item fil
  2291. @item fspp
  2292. @item harddup
  2293. @item il
  2294. @item ilpack
  2295. @item ivtc
  2296. @item kerndeint
  2297. @item mcdeint
  2298. @item noise
  2299. @item ow
  2300. @item perspective
  2301. @item phase
  2302. @item pp7
  2303. @item pullup
  2304. @item qp
  2305. @item sab
  2306. @item softpulldown
  2307. @item softskip
  2308. @item spp
  2309. @item telecine
  2310. @item tinterlace
  2311. @item unsharp
  2312. @item uspp
  2313. @end table
  2314. The parameter syntax and behavior for the listed filters are the same
  2315. of the corresponding MPlayer filters. For detailed instructions check
  2316. the "VIDEO FILTERS" section in the MPlayer manual.
  2317. Some examples follow:
  2318. @itemize
  2319. @item
  2320. Adjust gamma, brightness, contrast:
  2321. @example
  2322. mp=eq2=1.0:2:0.5
  2323. @end example
  2324. @item
  2325. Add temporal noise to input video:
  2326. @example
  2327. mp=noise=20t
  2328. @end example
  2329. @end itemize
  2330. See also mplayer(1), @url{http://www.mplayerhq.hu/}.
  2331. @section negate
  2332. Negate input video.
  2333. This filter accepts an integer in input, if non-zero it negates the
  2334. alpha component (if available). The default value in input is 0.
  2335. @section noformat
  2336. Force libavfilter not to use any of the specified pixel formats for the
  2337. input to the next filter.
  2338. The filter accepts a list of pixel format names, separated by ":",
  2339. for example "yuv420p:monow:rgb24".
  2340. Some examples follow:
  2341. @example
  2342. # force libavfilter to use a format different from "yuv420p" for the
  2343. # input to the vflip filter
  2344. noformat=yuv420p,vflip
  2345. # convert the input video to any of the formats not contained in the list
  2346. noformat=yuv420p:yuv444p:yuv410p
  2347. @end example
  2348. @section null
  2349. Pass the video source unchanged to the output.
  2350. @section ocv
  2351. Apply video transform using libopencv.
  2352. To enable this filter install libopencv library and headers and
  2353. configure FFmpeg with @code{--enable-libopencv}.
  2354. The filter takes the parameters: @var{filter_name}@{:=@}@var{filter_params}.
  2355. @var{filter_name} is the name of the libopencv filter to apply.
  2356. @var{filter_params} specifies the parameters to pass to the libopencv
  2357. filter. If not specified the default values are assumed.
  2358. Refer to the official libopencv documentation for more precise
  2359. information:
  2360. @url{http://opencv.willowgarage.com/documentation/c/image_filtering.html}
  2361. Follows the list of supported libopencv filters.
  2362. @anchor{dilate}
  2363. @subsection dilate
  2364. Dilate an image by using a specific structuring element.
  2365. This filter corresponds to the libopencv function @code{cvDilate}.
  2366. It accepts the parameters: @var{struct_el}:@var{nb_iterations}.
  2367. @var{struct_el} represents a structuring element, and has the syntax:
  2368. @var{cols}x@var{rows}+@var{anchor_x}x@var{anchor_y}/@var{shape}
  2369. @var{cols} and @var{rows} represent the number of columns and rows of
  2370. the structuring element, @var{anchor_x} and @var{anchor_y} the anchor
  2371. point, and @var{shape} the shape for the structuring element, and
  2372. can be one of the values "rect", "cross", "ellipse", "custom".
  2373. If the value for @var{shape} is "custom", it must be followed by a
  2374. string of the form "=@var{filename}". The file with name
  2375. @var{filename} is assumed to represent a binary image, with each
  2376. printable character corresponding to a bright pixel. When a custom
  2377. @var{shape} is used, @var{cols} and @var{rows} are ignored, the number
  2378. or columns and rows of the read file are assumed instead.
  2379. The default value for @var{struct_el} is "3x3+0x0/rect".
  2380. @var{nb_iterations} specifies the number of times the transform is
  2381. applied to the image, and defaults to 1.
  2382. Follow some example:
  2383. @example
  2384. # use the default values
  2385. ocv=dilate
  2386. # dilate using a structuring element with a 5x5 cross, iterate two times
  2387. ocv=dilate=5x5+2x2/cross:2
  2388. # read the shape from the file diamond.shape, iterate two times
  2389. # the file diamond.shape may contain a pattern of characters like this:
  2390. # *
  2391. # ***
  2392. # *****
  2393. # ***
  2394. # *
  2395. # the specified cols and rows are ignored (but not the anchor point coordinates)
  2396. ocv=0x0+2x2/custom=diamond.shape:2
  2397. @end example
  2398. @subsection erode
  2399. Erode an image by using a specific structuring element.
  2400. This filter corresponds to the libopencv function @code{cvErode}.
  2401. The filter accepts the parameters: @var{struct_el}:@var{nb_iterations},
  2402. with the same syntax and semantics as the @ref{dilate} filter.
  2403. @subsection smooth
  2404. Smooth the input video.
  2405. The filter takes the following parameters:
  2406. @var{type}:@var{param1}:@var{param2}:@var{param3}:@var{param4}.
  2407. @var{type} is the type of smooth filter to apply, and can be one of
  2408. the following values: "blur", "blur_no_scale", "median", "gaussian",
  2409. "bilateral". The default value is "gaussian".
  2410. @var{param1}, @var{param2}, @var{param3}, and @var{param4} are
  2411. parameters whose meanings depend on smooth type. @var{param1} and
  2412. @var{param2} accept integer positive values or 0, @var{param3} and
  2413. @var{param4} accept float values.
  2414. The default value for @var{param1} is 3, the default value for the
  2415. other parameters is 0.
  2416. These parameters correspond to the parameters assigned to the
  2417. libopencv function @code{cvSmooth}.
  2418. @anchor{overlay}
  2419. @section overlay
  2420. Overlay one video on top of another.
  2421. It takes two inputs and one output, the first input is the "main"
  2422. video on which the second input is overlayed.
  2423. This filter accepts a list of @var{key}=@var{value} pairs as argument,
  2424. separated by ":". If the key of the first options is omitted, the
  2425. arguments are interpreted according to the syntax @var{x}:@var{y}.
  2426. A description of the accepted options follows.
  2427. @table @option
  2428. @item x, y
  2429. Set the expression for the x and y coordinates of the overlayed video
  2430. on the main video. Default value is 0.
  2431. The @var{x} and @var{y} expressions can contain the following
  2432. parameters:
  2433. @table @option
  2434. @item main_w, main_h
  2435. main input width and height
  2436. @item W, H
  2437. same as @var{main_w} and @var{main_h}
  2438. @item overlay_w, overlay_h
  2439. overlay input width and height
  2440. @item w, h
  2441. same as @var{overlay_w} and @var{overlay_h}
  2442. @end table
  2443. @item rgb
  2444. If set to 1, force the filter to accept inputs in the RGB
  2445. color space. Default value is 0.
  2446. @end table
  2447. Be aware that frames are taken from each input video in timestamp
  2448. order, hence, if their initial timestamps differ, it is a a good idea
  2449. to pass the two inputs through a @var{setpts=PTS-STARTPTS} filter to
  2450. have them begin in the same zero timestamp, as it does the example for
  2451. the @var{movie} filter.
  2452. You can chain together more overlays but you should test the
  2453. efficiency of such approach.
  2454. @subsection Examples
  2455. @itemize
  2456. @item
  2457. Draw the overlay at 10 pixels from the bottom right corner of the main
  2458. video:
  2459. @example
  2460. overlay=main_w-overlay_w-10:main_h-overlay_h-10
  2461. @end example
  2462. Using named options the example above becomes:
  2463. @example
  2464. overlay=x=main_w-overlay_w-10:y=main_h-overlay_h-10
  2465. @end example
  2466. @item
  2467. Insert a transparent PNG logo in the bottom left corner of the input,
  2468. using the @command{ffmpeg} tool with the @code{-filter_complex} option:
  2469. @example
  2470. ffmpeg -i input -i logo -filter_complex 'overlay=10:main_h-overlay_h-10' output
  2471. @end example
  2472. @item
  2473. Insert 2 different transparent PNG logos (second logo on bottom
  2474. right corner) using the @command{ffmpeg} tool:
  2475. @example
  2476. ffmpeg -i input -i logo1 -i logo2 -filter_complex 'overlay=10:H-h-10,overlay=W-w-10:H-h-10' output
  2477. @end example
  2478. @item
  2479. Add a transparent color layer on top of the main video, WxH specifies
  2480. the size of the main input to the overlay filter:
  2481. @example
  2482. color=red@@.3:WxH [over]; [in][over] overlay [out]
  2483. @end example
  2484. @item
  2485. Play an original video and a filtered version (here with the deshake
  2486. filter) side by side using the @command{ffplay} tool:
  2487. @example
  2488. ffplay input.avi -vf 'split[a][b]; [a]pad=iw*2:ih[src]; [b]deshake[filt]; [src][filt]overlay=w'
  2489. @end example
  2490. The above command is the same as:
  2491. @example
  2492. ffplay input.avi -vf 'split[b], pad=iw*2[src], [b]deshake, [src]overlay=w'
  2493. @end example
  2494. @item
  2495. Chain several overlays in cascade:
  2496. @example
  2497. nullsrc=s=200x200 [bg];
  2498. testsrc=s=100x100, split=4 [in0][in1][in2][in3];
  2499. [in0] lutrgb=r=0, [bg] overlay=0:0 [mid0];
  2500. [in1] lutrgb=g=0, [mid0] overlay=100:0 [mid1];
  2501. [in2] lutrgb=b=0, [mid1] overlay=0:100 [mid2];
  2502. [in3] null, [mid2] overlay=100:100 [out0]
  2503. @end example
  2504. @end itemize
  2505. @section pad
  2506. Add paddings to the input image, and places the original input at the
  2507. given coordinates @var{x}, @var{y}.
  2508. It accepts the following parameters:
  2509. @var{width}:@var{height}:@var{x}:@var{y}:@var{color}.
  2510. The parameters @var{width}, @var{height}, @var{x}, and @var{y} are
  2511. expressions containing the following constants:
  2512. @table @option
  2513. @item in_w, in_h
  2514. the input video width and height
  2515. @item iw, ih
  2516. same as @var{in_w} and @var{in_h}
  2517. @item out_w, out_h
  2518. the output width and height, that is the size of the padded area as
  2519. specified by the @var{width} and @var{height} expressions
  2520. @item ow, oh
  2521. same as @var{out_w} and @var{out_h}
  2522. @item x, y
  2523. x and y offsets as specified by the @var{x} and @var{y}
  2524. expressions, or NAN if not yet specified
  2525. @item a
  2526. same as @var{iw} / @var{ih}
  2527. @item sar
  2528. input sample aspect ratio
  2529. @item dar
  2530. input display aspect ratio, it is the same as (@var{iw} / @var{ih}) * @var{sar}
  2531. @item hsub, vsub
  2532. horizontal and vertical chroma subsample values. For example for the
  2533. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  2534. @end table
  2535. Follows the description of the accepted parameters.
  2536. @table @option
  2537. @item width, height
  2538. Specify the size of the output image with the paddings added. If the
  2539. value for @var{width} or @var{height} is 0, the corresponding input size
  2540. is used for the output.
  2541. The @var{width} expression can reference the value set by the
  2542. @var{height} expression, and vice versa.
  2543. The default value of @var{width} and @var{height} is 0.
  2544. @item x, y
  2545. Specify the offsets where to place the input image in the padded area
  2546. with respect to the top/left border of the output image.
  2547. The @var{x} expression can reference the value set by the @var{y}
  2548. expression, and vice versa.
  2549. The default value of @var{x} and @var{y} is 0.
  2550. @item color
  2551. Specify the color of the padded area, it can be the name of a color
  2552. (case insensitive match) or a 0xRRGGBB[AA] sequence.
  2553. The default value of @var{color} is "black".
  2554. @end table
  2555. @subsection Examples
  2556. @itemize
  2557. @item
  2558. Add paddings with color "violet" to the input video. Output video
  2559. size is 640x480, the top-left corner of the input video is placed at
  2560. column 0, row 40:
  2561. @example
  2562. pad=640:480:0:40:violet
  2563. @end example
  2564. @item
  2565. Pad the input to get an output with dimensions increased by 3/2,
  2566. and put the input video at the center of the padded area:
  2567. @example
  2568. pad="3/2*iw:3/2*ih:(ow-iw)/2:(oh-ih)/2"
  2569. @end example
  2570. @item
  2571. Pad the input to get a squared output with size equal to the maximum
  2572. value between the input width and height, and put the input video at
  2573. the center of the padded area:
  2574. @example
  2575. pad="max(iw\,ih):ow:(ow-iw)/2:(oh-ih)/2"
  2576. @end example
  2577. @item
  2578. Pad the input to get a final w/h ratio of 16:9:
  2579. @example
  2580. pad="ih*16/9:ih:(ow-iw)/2:(oh-ih)/2"
  2581. @end example
  2582. @item
  2583. In case of anamorphic video, in order to set the output display aspect
  2584. correctly, it is necessary to use @var{sar} in the expression,
  2585. according to the relation:
  2586. @example
  2587. (ih * X / ih) * sar = output_dar
  2588. X = output_dar / sar
  2589. @end example
  2590. Thus the previous example needs to be modified to:
  2591. @example
  2592. pad="ih*16/9/sar:ih:(ow-iw)/2:(oh-ih)/2"
  2593. @end example
  2594. @item
  2595. Double output size and put the input video in the bottom-right
  2596. corner of the output padded area:
  2597. @example
  2598. pad="2*iw:2*ih:ow-iw:oh-ih"
  2599. @end example
  2600. @end itemize
  2601. @section pixdesctest
  2602. Pixel format descriptor test filter, mainly useful for internal
  2603. testing. The output video should be equal to the input video.
  2604. For example:
  2605. @example
  2606. format=monow, pixdesctest
  2607. @end example
  2608. can be used to test the monowhite pixel format descriptor definition.
  2609. @section pp
  2610. Enable the specified chain of postprocessing subfilters using libpostproc. This
  2611. library should be automatically selected with a GPL build (@code{--enable-gpl}).
  2612. Subfilters must be separated by '/' and can be disabled by prepending a '-'.
  2613. Each subfilter and some options have a short and a long name that can be used
  2614. interchangeably, i.e. dr/dering are the same.
  2615. All subfilters share common options to determine their scope:
  2616. @table @option
  2617. @item a/autoq
  2618. Honor the quality commands for this subfilter.
  2619. @item c/chrom
  2620. Do chrominance filtering, too (default).
  2621. @item y/nochrom
  2622. Do luminance filtering only (no chrominance).
  2623. @item n/noluma
  2624. Do chrominance filtering only (no luminance).
  2625. @end table
  2626. These options can be appended after the subfilter name, separated by a ':'.
  2627. Available subfilters are:
  2628. @table @option
  2629. @item hb/hdeblock[:difference[:flatness]]
  2630. Horizontal deblocking filter
  2631. @table @option
  2632. @item difference
  2633. Difference factor where higher values mean more deblocking (default: @code{32}).
  2634. @item flatness
  2635. Flatness threshold where lower values mean more deblocking (default: @code{39}).
  2636. @end table
  2637. @item vb/vdeblock[:difference[:flatness]]
  2638. Vertical deblocking filter
  2639. @table @option
  2640. @item difference
  2641. Difference factor where higher values mean more deblocking (default: @code{32}).
  2642. @item flatness
  2643. Flatness threshold where lower values mean more deblocking (default: @code{39}).
  2644. @end table
  2645. @item ha/hadeblock[:difference[:flatness]]
  2646. Accurate horizontal deblocking filter
  2647. @table @option
  2648. @item difference
  2649. Difference factor where higher values mean more deblocking (default: @code{32}).
  2650. @item flatness
  2651. Flatness threshold where lower values mean more deblocking (default: @code{39}).
  2652. @end table
  2653. @item va/vadeblock[:difference[:flatness]]
  2654. Accurate vertical deblocking filter
  2655. @table @option
  2656. @item difference
  2657. Difference factor where higher values mean more deblocking (default: @code{32}).
  2658. @item flatness
  2659. Flatness threshold where lower values mean more deblocking (default: @code{39}).
  2660. @end table
  2661. @end table
  2662. The horizontal and vertical deblocking filters share the difference and
  2663. flatness values so you cannot set different horizontal and vertical
  2664. thresholds.
  2665. @table @option
  2666. @item h1/x1hdeblock
  2667. Experimental horizontal deblocking filter
  2668. @item v1/x1vdeblock
  2669. Experimental vertical deblocking filter
  2670. @item dr/dering
  2671. Deringing filter
  2672. @item tn/tmpnoise[:threshold1[:threshold2[:threshold3]]], temporal noise reducer
  2673. @table @option
  2674. @item threshold1
  2675. larger -> stronger filtering
  2676. @item threshold2
  2677. larger -> stronger filtering
  2678. @item threshold3
  2679. larger -> stronger filtering
  2680. @end table
  2681. @item al/autolevels[:f/fullyrange], automatic brightness / contrast correction
  2682. @table @option
  2683. @item f/fullyrange
  2684. Stretch luminance to @code{0-255}.
  2685. @end table
  2686. @item lb/linblenddeint
  2687. Linear blend deinterlacing filter that deinterlaces the given block by
  2688. filtering all lines with a @code{(1 2 1)} filter.
  2689. @item li/linipoldeint
  2690. Linear interpolating deinterlacing filter that deinterlaces the given block by
  2691. linearly interpolating every second line.
  2692. @item ci/cubicipoldeint
  2693. Cubic interpolating deinterlacing filter deinterlaces the given block by
  2694. cubically interpolating every second line.
  2695. @item md/mediandeint
  2696. Median deinterlacing filter that deinterlaces the given block by applying a
  2697. median filter to every second line.
  2698. @item fd/ffmpegdeint
  2699. FFmpeg deinterlacing filter that deinterlaces the given block by filtering every
  2700. second line with a @code{(-1 4 2 4 -1)} filter.
  2701. @item l5/lowpass5
  2702. Vertically applied FIR lowpass deinterlacing filter that deinterlaces the given
  2703. block by filtering all lines with a @code{(-1 2 6 2 -1)} filter.
  2704. @item fq/forceQuant[:quantizer]
  2705. Overrides the quantizer table from the input with the constant quantizer you
  2706. specify.
  2707. @table @option
  2708. @item quantizer
  2709. Quantizer to use
  2710. @end table
  2711. @item de/default
  2712. Default pp filter combination (@code{hb:a,vb:a,dr:a})
  2713. @item fa/fast
  2714. Fast pp filter combination (@code{h1:a,v1:a,dr:a})
  2715. @item ac
  2716. High quality pp filter combination (@code{ha:a:128:7,va:a,dr:a})
  2717. @end table
  2718. @subsection Examples
  2719. @itemize
  2720. @item
  2721. Apply horizontal and vertical deblocking, deringing and automatic
  2722. brightness/contrast:
  2723. @example
  2724. pp=hb/vb/dr/al
  2725. @end example
  2726. @item
  2727. Apply default filters without brightness/contrast correction:
  2728. @example
  2729. pp=de/-al
  2730. @end example
  2731. @item
  2732. Apply default filters and temporal denoiser:
  2733. @example
  2734. pp=default/tmpnoise:1:2:3
  2735. @end example
  2736. @item
  2737. Apply deblocking on luminance only, and switch vertical deblocking on or off
  2738. automatically depending on available CPU time:
  2739. @example
  2740. pp=hb:y/vb:a
  2741. @end example
  2742. @end itemize
  2743. @section removelogo
  2744. Suppress a TV station logo, using an image file to determine which
  2745. pixels comprise the logo. It works by filling in the pixels that
  2746. comprise the logo with neighboring pixels.
  2747. This filter requires one argument which specifies the filter bitmap
  2748. file, which can be any image format supported by libavformat. The
  2749. width and height of the image file must match those of the video
  2750. stream being processed.
  2751. Pixels in the provided bitmap image with a value of zero are not
  2752. considered part of the logo, non-zero pixels are considered part of
  2753. the logo. If you use white (255) for the logo and black (0) for the
  2754. rest, you will be safe. For making the filter bitmap, it is
  2755. recommended to take a screen capture of a black frame with the logo
  2756. visible, and then using a threshold filter followed by the erode
  2757. filter once or twice.
  2758. If needed, little splotches can be fixed manually. Remember that if
  2759. logo pixels are not covered, the filter quality will be much
  2760. reduced. Marking too many pixels as part of the logo does not hurt as
  2761. much, but it will increase the amount of blurring needed to cover over
  2762. the image and will destroy more information than necessary, and extra
  2763. pixels will slow things down on a large logo.
  2764. @section scale
  2765. Scale (resize) the input video, using the libswscale library.
  2766. The scale filter forces the output display aspect ratio to be the same
  2767. of the input, by changing the output sample aspect ratio.
  2768. This filter accepts a list of named options in the form of
  2769. @var{key}=@var{value} pairs separated by ":". If the key for the first
  2770. two options is not specified, the assumed keys for the first two
  2771. values are @code{w} and @code{h}. If the first option has no key and
  2772. can be interpreted like a video size specification, it will be used
  2773. to set the video size.
  2774. A description of the accepted options follows.
  2775. @table @option
  2776. @item width, w
  2777. Set the video width expression, default value is @code{iw}. See below
  2778. for the list of accepted constants.
  2779. @item height, h
  2780. Set the video heiht expression, default value is @code{ih}.
  2781. See below for the list of accepted constants.
  2782. @item interl
  2783. Set the interlacing. It accepts the following values:
  2784. @table @option
  2785. @item 1
  2786. force interlaced aware scaling
  2787. @item 0
  2788. do not apply interlaced scaling
  2789. @item -1
  2790. select interlaced aware scaling depending on whether the source frames
  2791. are flagged as interlaced or not
  2792. @end table
  2793. Default value is @code{0}.
  2794. @item flags
  2795. Set libswscale scaling flags. If not explictly specified the filter
  2796. applies a bilinear scaling algorithm.
  2797. @item size, s
  2798. Set the video size, the value must be a valid abbreviation or in the
  2799. form @var{width}x@var{height}.
  2800. @end table
  2801. The values of the @var{w} and @var{h} options are expressions
  2802. containing the following constants:
  2803. @table @option
  2804. @item in_w, in_h
  2805. the input width and height
  2806. @item iw, ih
  2807. same as @var{in_w} and @var{in_h}
  2808. @item out_w, out_h
  2809. the output (cropped) width and height
  2810. @item ow, oh
  2811. same as @var{out_w} and @var{out_h}
  2812. @item a
  2813. same as @var{iw} / @var{ih}
  2814. @item sar
  2815. input sample aspect ratio
  2816. @item dar
  2817. input display aspect ratio, it is the same as (@var{iw} / @var{ih}) * @var{sar}
  2818. @item hsub, vsub
  2819. horizontal and vertical chroma subsample values. For example for the
  2820. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  2821. @end table
  2822. If the input image format is different from the format requested by
  2823. the next filter, the scale filter will convert the input to the
  2824. requested format.
  2825. If the value for @var{width} or @var{height} is 0, the respective input
  2826. size is used for the output.
  2827. If the value for @var{width} or @var{height} is -1, the scale filter will
  2828. use, for the respective output size, a value that maintains the aspect
  2829. ratio of the input image.
  2830. @subsection Examples
  2831. @itemize
  2832. @item
  2833. Scale the input video to a size of 200x100:
  2834. @example
  2835. scale=200:100
  2836. @end example
  2837. This is equivalent to:
  2838. @example
  2839. scale=w=200:h=100
  2840. @end example
  2841. or:
  2842. @example
  2843. scale=200x100
  2844. @end example
  2845. @item
  2846. Specify a size abbreviation for the output size:
  2847. @example
  2848. scale=qcif
  2849. @end example
  2850. which can also be written as:
  2851. @example
  2852. scale=size=qcif
  2853. @end example
  2854. @item
  2855. Scale the input to 2x:
  2856. @example
  2857. scale=2*iw:2*ih
  2858. @end example
  2859. @item
  2860. The above is the same as:
  2861. @example
  2862. scale=2*in_w:2*in_h
  2863. @end example
  2864. @item
  2865. Scale the input to 2x with forced interlaced scaling:
  2866. @example
  2867. scale=2*iw:2*ih:interl=1
  2868. @end example
  2869. @item
  2870. Scale the input to half size:
  2871. @example
  2872. scale=iw/2:ih/2
  2873. @end example
  2874. @item
  2875. Increase the width, and set the height to the same size:
  2876. @example
  2877. scale=3/2*iw:ow
  2878. @end example
  2879. @item
  2880. Seek for Greek harmony:
  2881. @example
  2882. scale=iw:1/PHI*iw
  2883. scale=ih*PHI:ih
  2884. @end example
  2885. @item
  2886. Increase the height, and set the width to 3/2 of the height:
  2887. @example
  2888. scale=3/2*oh:3/5*ih
  2889. @end example
  2890. @item
  2891. Increase the size, but make the size a multiple of the chroma:
  2892. @example
  2893. scale="trunc(3/2*iw/hsub)*hsub:trunc(3/2*ih/vsub)*vsub"
  2894. @end example
  2895. @item
  2896. Increase the width to a maximum of 500 pixels, keep the same input
  2897. aspect ratio:
  2898. @example
  2899. scale='min(500\, iw*3/2):-1'
  2900. @end example
  2901. @end itemize
  2902. @section setdar, setsar
  2903. The @code{setdar} filter sets the Display Aspect Ratio for the filter
  2904. output video.
  2905. This is done by changing the specified Sample (aka Pixel) Aspect
  2906. Ratio, according to the following equation:
  2907. @example
  2908. @var{DAR} = @var{HORIZONTAL_RESOLUTION} / @var{VERTICAL_RESOLUTION} * @var{SAR}
  2909. @end example
  2910. Keep in mind that the @code{setdar} filter does not modify the pixel
  2911. dimensions of the video frame. Also the display aspect ratio set by
  2912. this filter may be changed by later filters in the filterchain,
  2913. e.g. in case of scaling or if another "setdar" or a "setsar" filter is
  2914. applied.
  2915. The @code{setsar} filter sets the Sample (aka Pixel) Aspect Ratio for
  2916. the filter output video.
  2917. Note that as a consequence of the application of this filter, the
  2918. output display aspect ratio will change according to the equation
  2919. above.
  2920. Keep in mind that the sample aspect ratio set by the @code{setsar}
  2921. filter may be changed by later filters in the filterchain, e.g. if
  2922. another "setsar" or a "setdar" filter is applied.
  2923. The @code{setdar} and @code{setsar} filters accept a string in the
  2924. form @var{num}:@var{den} expressing an aspect ratio, or the following
  2925. named options, expressed as a sequence of @var{key}=@var{value} pairs,
  2926. separated by ":".
  2927. @table @option
  2928. @item max
  2929. Set the maximum integer value to use for expressing numerator and
  2930. denominator when reducing the expressed aspect ratio to a rational.
  2931. Default value is @code{100}.
  2932. @item r, ratio:
  2933. Set the aspect ratio used by the filter.
  2934. The parameter can be a floating point number string, an expression, or
  2935. a string of the form @var{num}:@var{den}, where @var{num} and
  2936. @var{den} are the numerator and denominator of the aspect ratio. If
  2937. the parameter is not specified, it is assumed the value "0".
  2938. In case the form "@var{num}:@var{den}" the @code{:} character should
  2939. be escaped.
  2940. @end table
  2941. If the keys are omitted in the named options list, the specifed values
  2942. are assumed to be @var{ratio} and @var{max} in that order.
  2943. For example to change the display aspect ratio to 16:9, specify:
  2944. @example
  2945. setdar='16:9'
  2946. @end example
  2947. The example above is equivalent to:
  2948. @example
  2949. setdar=1.77777
  2950. @end example
  2951. To change the sample aspect ratio to 10:11, specify:
  2952. @example
  2953. setsar='10:11'
  2954. @end example
  2955. To set a display aspect ratio of 16:9, and specify a maximum integer value of
  2956. 1000 in the aspect ratio reduction, use the command:
  2957. @example
  2958. setdar=ratio='16:9':max=1000
  2959. @end example
  2960. @section setfield
  2961. Force field for the output video frame.
  2962. The @code{setfield} filter marks the interlace type field for the
  2963. output frames. It does not change the input frame, but only sets the
  2964. corresponding property, which affects how the frame is treated by
  2965. following filters (e.g. @code{fieldorder} or @code{yadif}).
  2966. This filter accepts a single option @option{mode}, which can be
  2967. specified either by setting @code{mode=VALUE} or setting the value
  2968. alone. Available values are:
  2969. @table @samp
  2970. @item auto
  2971. Keep the same field property.
  2972. @item bff
  2973. Mark the frame as bottom-field-first.
  2974. @item tff
  2975. Mark the frame as top-field-first.
  2976. @item prog
  2977. Mark the frame as progressive.
  2978. @end table
  2979. @section showinfo
  2980. Show a line containing various information for each input video frame.
  2981. The input video is not modified.
  2982. The shown line contains a sequence of key/value pairs of the form
  2983. @var{key}:@var{value}.
  2984. A description of each shown parameter follows:
  2985. @table @option
  2986. @item n
  2987. sequential number of the input frame, starting from 0
  2988. @item pts
  2989. Presentation TimeStamp of the input frame, expressed as a number of
  2990. time base units. The time base unit depends on the filter input pad.
  2991. @item pts_time
  2992. Presentation TimeStamp of the input frame, expressed as a number of
  2993. seconds
  2994. @item pos
  2995. position of the frame in the input stream, -1 if this information in
  2996. unavailable and/or meaningless (for example in case of synthetic video)
  2997. @item fmt
  2998. pixel format name
  2999. @item sar
  3000. sample aspect ratio of the input frame, expressed in the form
  3001. @var{num}/@var{den}
  3002. @item s
  3003. size of the input frame, expressed in the form
  3004. @var{width}x@var{height}
  3005. @item i
  3006. interlaced mode ("P" for "progressive", "T" for top field first, "B"
  3007. for bottom field first)
  3008. @item iskey
  3009. 1 if the frame is a key frame, 0 otherwise
  3010. @item type
  3011. picture type of the input frame ("I" for an I-frame, "P" for a
  3012. P-frame, "B" for a B-frame, "?" for unknown type).
  3013. Check also the documentation of the @code{AVPictureType} enum and of
  3014. the @code{av_get_picture_type_char} function defined in
  3015. @file{libavutil/avutil.h}.
  3016. @item checksum
  3017. Adler-32 checksum (printed in hexadecimal) of all the planes of the input frame
  3018. @item plane_checksum
  3019. Adler-32 checksum (printed in hexadecimal) of each plane of the input frame,
  3020. expressed in the form "[@var{c0} @var{c1} @var{c2} @var{c3}]"
  3021. @end table
  3022. @section smartblur
  3023. Blur the input video without impacting the outlines.
  3024. The filter accepts the following parameters:
  3025. @var{luma_radius}:@var{luma_strength}:@var{luma_threshold}[:@var{chroma_radius}:@var{chroma_strength}:@var{chroma_threshold}]
  3026. Parameters prefixed by @var{luma} indicate that they work on the
  3027. luminance of the pixels whereas parameters prefixed by @var{chroma}
  3028. refer to the chrominance of the pixels.
  3029. If the chroma parameters are not set, the luma parameters are used for
  3030. either the luminance and the chrominance of the pixels.
  3031. @var{luma_radius} or @var{chroma_radius} must be a float number in the
  3032. range [0.1,5.0] that specifies the variance of the gaussian filter
  3033. used to blur the image (slower if larger).
  3034. @var{luma_strength} or @var{chroma_strength} must be a float number in
  3035. the range [-1.0,1.0] that configures the blurring. A value included in
  3036. [0.0,1.0] will blur the image whereas a value included in [-1.0,0.0]
  3037. will sharpen the image.
  3038. @var{luma_threshold} or @var{chroma_threshold} must be an integer in
  3039. the range [-30,30] that is used as a coefficient to determine whether
  3040. a pixel should be blurred or not. A value of 0 will filter all the
  3041. image, a value included in [0,30] will filter flat areas and a value
  3042. included in [-30,0] will filter edges.
  3043. @anchor{subtitles}
  3044. @section subtitles
  3045. Draw subtitles on top of input video using the libass library.
  3046. To enable compilation of this filter you need to configure FFmpeg with
  3047. @code{--enable-libass}. This filter also requires a build with libavcodec and
  3048. libavformat to convert the passed subtitles file to ASS (Advanced Substation
  3049. Alpha) subtitles format.
  3050. This filter accepts the following named options, expressed as a
  3051. sequence of @var{key}=@var{value} pairs, separated by ":".
  3052. @table @option
  3053. @item filename, f
  3054. Set the filename of the subtitle file to read. It must be specified.
  3055. @item original_size
  3056. Specify the size of the original video, the video for which the ASS file
  3057. was composed. Due to a misdesign in ASS aspect ratio arithmetic, this is
  3058. necessary to correctly scale the fonts if the aspect ratio has been changed.
  3059. @end table
  3060. If the first key is not specified, it is assumed that the first value
  3061. specifies the @option{filename}.
  3062. For example, to render the file @file{sub.srt} on top of the input
  3063. video, use the command:
  3064. @example
  3065. subtitles=sub.srt
  3066. @end example
  3067. which is equivalent to:
  3068. @example
  3069. subtitles=filename=sub.srt
  3070. @end example
  3071. @section split
  3072. Split input video into several identical outputs.
  3073. The filter accepts a single parameter which specifies the number of outputs. If
  3074. unspecified, it defaults to 2.
  3075. For example
  3076. @example
  3077. ffmpeg -i INPUT -filter_complex split=5 OUTPUT
  3078. @end example
  3079. will create 5 copies of the input video.
  3080. For example:
  3081. @example
  3082. [in] split [splitout1][splitout2];
  3083. [splitout1] crop=100:100:0:0 [cropout];
  3084. [splitout2] pad=200:200:100:100 [padout];
  3085. @end example
  3086. will create two separate outputs from the same input, one cropped and
  3087. one padded.
  3088. @section super2xsai
  3089. Scale the input by 2x and smooth using the Super2xSaI (Scale and
  3090. Interpolate) pixel art scaling algorithm.
  3091. Useful for enlarging pixel art images without reducing sharpness.
  3092. @section swapuv
  3093. Swap U & V plane.
  3094. @section thumbnail
  3095. Select the most representative frame in a given sequence of consecutive frames.
  3096. It accepts as argument the frames batch size to analyze (default @var{N}=100);
  3097. in a set of @var{N} frames, the filter will pick one of them, and then handle
  3098. the next batch of @var{N} frames until the end.
  3099. Since the filter keeps track of the whole frames sequence, a bigger @var{N}
  3100. value will result in a higher memory usage, so a high value is not recommended.
  3101. The following example extract one picture each 50 frames:
  3102. @example
  3103. thumbnail=50
  3104. @end example
  3105. Complete example of a thumbnail creation with @command{ffmpeg}:
  3106. @example
  3107. ffmpeg -i in.avi -vf thumbnail,scale=300:200 -frames:v 1 out.png
  3108. @end example
  3109. @section tile
  3110. Tile several successive frames together.
  3111. It accepts a list of options in the form of @var{key}=@var{value} pairs
  3112. separated by ":". A description of the accepted options follows.
  3113. @table @option
  3114. @item layout
  3115. Set the grid size (i.e. the number of lines and columns) in the form
  3116. "@var{w}x@var{h}".
  3117. @item margin
  3118. Set the outer border margin in pixels.
  3119. @item padding
  3120. Set the inner border thickness (i.e. the number of pixels between frames). For
  3121. more advanced padding options (such as having different values for the edges),
  3122. refer to the pad video filter.
  3123. @item nb_frames
  3124. Set the maximum number of frames to render in the given area. It must be less
  3125. than or equal to @var{w}x@var{h}. The default value is @code{0}, meaning all
  3126. the area will be used.
  3127. @end table
  3128. Alternatively, the options can be specified as a flat string:
  3129. @var{layout}[:@var{nb_frames}[:@var{margin}[:@var{padding}]]]
  3130. For example, produce 8x8 PNG tiles of all keyframes (@option{-skip_frame
  3131. nokey}) in a movie:
  3132. @example
  3133. ffmpeg -skip_frame nokey -i file.avi -vf 'scale=128:72,tile=8x8' -an -vsync 0 keyframes%03d.png
  3134. @end example
  3135. The @option{-vsync 0} is necessary to prevent @command{ffmpeg} from
  3136. duplicating each output frame to accomodate the originally detected frame
  3137. rate.
  3138. Another example to display @code{5} pictures in an area of @code{3x2} frames,
  3139. with @code{7} pixels between them, and @code{2} pixels of initial margin, using
  3140. mixed flat and named options:
  3141. @example
  3142. tile=3x2:nb_frames=5:padding=7:margin=2
  3143. @end example
  3144. @section tinterlace
  3145. Perform various types of temporal field interlacing.
  3146. Frames are counted starting from 1, so the first input frame is
  3147. considered odd.
  3148. This filter accepts options in the form of @var{key}=@var{value} pairs
  3149. separated by ":".
  3150. Alternatively, the @var{mode} option can be specified as a value alone,
  3151. optionally followed by a ":" and further ":" separated @var{key}=@var{value}
  3152. pairs.
  3153. A description of the accepted options follows.
  3154. @table @option
  3155. @item mode
  3156. Specify the mode of the interlacing. This option can also be specified
  3157. as a value alone. See below for a list of values for this option.
  3158. Available values are:
  3159. @table @samp
  3160. @item merge, 0
  3161. Move odd frames into the upper field, even into the lower field,
  3162. generating a double height frame at half framerate.
  3163. @item drop_odd, 1
  3164. Only output even frames, odd frames are dropped, generating a frame with
  3165. unchanged height at half framerate.
  3166. @item drop_even, 2
  3167. Only output odd frames, even frames are dropped, generating a frame with
  3168. unchanged height at half framerate.
  3169. @item pad, 3
  3170. Expand each frame to full height, but pad alternate lines with black,
  3171. generating a frame with double height at the same input framerate.
  3172. @item interleave_top, 4
  3173. Interleave the upper field from odd frames with the lower field from
  3174. even frames, generating a frame with unchanged height at half framerate.
  3175. @item interleave_bottom, 5
  3176. Interleave the lower field from odd frames with the upper field from
  3177. even frames, generating a frame with unchanged height at half framerate.
  3178. @item interlacex2, 6
  3179. Double frame rate with unchanged height. Frames are inserted each
  3180. containing the second temporal field from the previous input frame and
  3181. the first temporal field from the next input frame. This mode relies on
  3182. the top_field_first flag. Useful for interlaced video displays with no
  3183. field synchronisation.
  3184. @end table
  3185. Numeric values are deprecated but are accepted for backward
  3186. compatibility reasons.
  3187. Default mode is @code{merge}.
  3188. @item flags
  3189. Specify flags influencing the filter process.
  3190. Available value for @var{flags} is:
  3191. @table @option
  3192. @item low_pass_filter, vlfp
  3193. Enable vertical low-pass filtering in the filter.
  3194. Vertical low-pass filtering is required when creating an interlaced
  3195. destination from a progressive source which contains high-frequency
  3196. vertical detail. Filtering will reduce interlace 'twitter' and Moire
  3197. patterning.
  3198. Vertical low-pass filtering can only be enabled for @option{mode}
  3199. @var{interleave_top} and @var{interleave_bottom}.
  3200. @end table
  3201. @end table
  3202. @section transpose
  3203. Transpose rows with columns in the input video and optionally flip it.
  3204. The filter accepts parameters as a list of @var{key}=@var{value}
  3205. pairs, separated by ':'. If the key of the first options is omitted,
  3206. the arguments are interpreted according to the syntax
  3207. @var{dir}:@var{passthrough}.
  3208. @table @option
  3209. @item dir
  3210. Specify the transposition direction. Can assume the following values:
  3211. @table @samp
  3212. @item 0, 4
  3213. Rotate by 90 degrees counterclockwise and vertically flip (default), that is:
  3214. @example
  3215. L.R L.l
  3216. . . -> . .
  3217. l.r R.r
  3218. @end example
  3219. @item 1, 5
  3220. Rotate by 90 degrees clockwise, that is:
  3221. @example
  3222. L.R l.L
  3223. . . -> . .
  3224. l.r r.R
  3225. @end example
  3226. @item 2, 6
  3227. Rotate by 90 degrees counterclockwise, that is:
  3228. @example
  3229. L.R R.r
  3230. . . -> . .
  3231. l.r L.l
  3232. @end example
  3233. @item 3, 7
  3234. Rotate by 90 degrees clockwise and vertically flip, that is:
  3235. @example
  3236. L.R r.R
  3237. . . -> . .
  3238. l.r l.L
  3239. @end example
  3240. @end table
  3241. For values between 4-7, the transposition is only done if the input
  3242. video geometry is portrait and not landscape. These values are
  3243. deprecated, the @code{passthrough} option should be used instead.
  3244. @item passthrough
  3245. Do not apply the transposition if the input geometry matches the one
  3246. specified by the specified value. It accepts the following values:
  3247. @table @samp
  3248. @item none
  3249. Always apply transposition.
  3250. @item portrait
  3251. Preserve portrait geometry (when @var{height} >= @var{width}).
  3252. @item landscape
  3253. Preserve landscape geometry (when @var{width} >= @var{height}).
  3254. @end table
  3255. Default value is @code{none}.
  3256. @end table
  3257. For example to rotate by 90 degrees clockwise and preserve portrait
  3258. layout:
  3259. @example
  3260. transpose=dir=1:passthrough=portrait
  3261. @end example
  3262. The command above can also be specified as:
  3263. @example
  3264. transpose=1:portrait
  3265. @end example
  3266. @section unsharp
  3267. Sharpen or blur the input video.
  3268. It accepts the following parameters:
  3269. @var{luma_msize_x}:@var{luma_msize_y}:@var{luma_amount}:@var{chroma_msize_x}:@var{chroma_msize_y}:@var{chroma_amount}
  3270. Negative values for the amount will blur the input video, while positive
  3271. values will sharpen. All parameters are optional and default to the
  3272. equivalent of the string '5:5:1.0:5:5:0.0'.
  3273. @table @option
  3274. @item luma_msize_x
  3275. Set the luma matrix horizontal size. It can be an integer between 3
  3276. and 13, default value is 5.
  3277. @item luma_msize_y
  3278. Set the luma matrix vertical size. It can be an integer between 3
  3279. and 13, default value is 5.
  3280. @item luma_amount
  3281. Set the luma effect strength. It can be a float number between -2.0
  3282. and 5.0, default value is 1.0.
  3283. @item chroma_msize_x
  3284. Set the chroma matrix horizontal size. It can be an integer between 3
  3285. and 13, default value is 5.
  3286. @item chroma_msize_y
  3287. Set the chroma matrix vertical size. It can be an integer between 3
  3288. and 13, default value is 5.
  3289. @item chroma_amount
  3290. Set the chroma effect strength. It can be a float number between -2.0
  3291. and 5.0, default value is 0.0.
  3292. @end table
  3293. @example
  3294. # Strong luma sharpen effect parameters
  3295. unsharp=7:7:2.5
  3296. # Strong blur of both luma and chroma parameters
  3297. unsharp=7:7:-2:7:7:-2
  3298. # Use the default values with @command{ffmpeg}
  3299. ffmpeg -i in.avi -vf "unsharp" out.mp4
  3300. @end example
  3301. @section vflip
  3302. Flip the input video vertically.
  3303. @example
  3304. ffmpeg -i in.avi -vf "vflip" out.avi
  3305. @end example
  3306. @section yadif
  3307. Deinterlace the input video ("yadif" means "yet another deinterlacing
  3308. filter").
  3309. The filter accepts parameters as a list of @var{key}=@var{value}
  3310. pairs, separated by ":". If the key of the first options is omitted,
  3311. the arguments are interpreted according to syntax
  3312. @var{mode}:@var{parity}:@var{deint}.
  3313. The description of the accepted parameters follows.
  3314. @table @option
  3315. @item mode
  3316. Specify the interlacing mode to adopt. Accept one of the following
  3317. values:
  3318. @table @option
  3319. @item 0, send_frame
  3320. output 1 frame for each frame
  3321. @item 1, send_field
  3322. output 1 frame for each field
  3323. @item 2, send_frame_nospatial
  3324. like @code{send_frame} but skip spatial interlacing check
  3325. @item 3, send_field_nospatial
  3326. like @code{send_field} but skip spatial interlacing check
  3327. @end table
  3328. Default value is @code{send_frame}.
  3329. @item parity
  3330. Specify the picture field parity assumed for the input interlaced
  3331. video. Accept one of the following values:
  3332. @table @option
  3333. @item 0, tff
  3334. assume top field first
  3335. @item 1, bff
  3336. assume bottom field first
  3337. @item -1, auto
  3338. enable automatic detection
  3339. @end table
  3340. Default value is @code{auto}.
  3341. If interlacing is unknown or decoder does not export this information,
  3342. top field first will be assumed.
  3343. @item deint
  3344. Specify which frames to deinterlace. Accept one of the following
  3345. values:
  3346. @table @option
  3347. @item 0, all
  3348. deinterlace all frames
  3349. @item 1, interlaced
  3350. only deinterlace frames marked as interlaced
  3351. @end table
  3352. Default value is @code{all}.
  3353. @end table
  3354. @c man end VIDEO FILTERS
  3355. @chapter Video Sources
  3356. @c man begin VIDEO SOURCES
  3357. Below is a description of the currently available video sources.
  3358. @section buffer
  3359. Buffer video frames, and make them available to the filter chain.
  3360. This source is mainly intended for a programmatic use, in particular
  3361. through the interface defined in @file{libavfilter/vsrc_buffer.h}.
  3362. It accepts a list of options in the form of @var{key}=@var{value} pairs
  3363. separated by ":". A description of the accepted options follows.
  3364. @table @option
  3365. @item video_size
  3366. Specify the size (width and height) of the buffered video frames.
  3367. @item pix_fmt
  3368. A string representing the pixel format of the buffered video frames.
  3369. It may be a number corresponding to a pixel format, or a pixel format
  3370. name.
  3371. @item time_base
  3372. Specify the timebase assumed by the timestamps of the buffered frames.
  3373. @item time_base
  3374. Specify the frame rate expected for the video stream.
  3375. @item pixel_aspect
  3376. Specify the sample aspect ratio assumed by the video frames.
  3377. @item sws_param
  3378. Specify the optional parameters to be used for the scale filter which
  3379. is automatically inserted when an input change is detected in the
  3380. input size or format.
  3381. @end table
  3382. For example:
  3383. @example
  3384. buffer=size=320x240:pix_fmt=yuv410p:time_base=1/24:pixel_aspect=1/1
  3385. @end example
  3386. will instruct the source to accept video frames with size 320x240 and
  3387. with format "yuv410p", assuming 1/24 as the timestamps timebase and
  3388. square pixels (1:1 sample aspect ratio).
  3389. Since the pixel format with name "yuv410p" corresponds to the number 6
  3390. (check the enum AVPixelFormat definition in @file{libavutil/pixfmt.h}),
  3391. this example corresponds to:
  3392. @example
  3393. buffer=size=320x240:pixfmt=6:time_base=1/24:pixel_aspect=1/1
  3394. @end example
  3395. Alternatively, the options can be specified as a flat string, but this
  3396. syntax is deprecated:
  3397. @var{width}:@var{height}:@var{pix_fmt}:@var{time_base.num}:@var{time_base.den}:@var{pixel_aspect.num}:@var{pixel_aspect.den}[:@var{sws_param}]
  3398. @section cellauto
  3399. Create a pattern generated by an elementary cellular automaton.
  3400. The initial state of the cellular automaton can be defined through the
  3401. @option{filename}, and @option{pattern} options. If such options are
  3402. not specified an initial state is created randomly.
  3403. At each new frame a new row in the video is filled with the result of
  3404. the cellular automaton next generation. The behavior when the whole
  3405. frame is filled is defined by the @option{scroll} option.
  3406. This source accepts a list of options in the form of
  3407. @var{key}=@var{value} pairs separated by ":". A description of the
  3408. accepted options follows.
  3409. @table @option
  3410. @item filename, f
  3411. Read the initial cellular automaton state, i.e. the starting row, from
  3412. the specified file.
  3413. In the file, each non-whitespace character is considered an alive
  3414. cell, a newline will terminate the row, and further characters in the
  3415. file will be ignored.
  3416. @item pattern, p
  3417. Read the initial cellular automaton state, i.e. the starting row, from
  3418. the specified string.
  3419. Each non-whitespace character in the string is considered an alive
  3420. cell, a newline will terminate the row, and further characters in the
  3421. string will be ignored.
  3422. @item rate, r
  3423. Set the video rate, that is the number of frames generated per second.
  3424. Default is 25.
  3425. @item random_fill_ratio, ratio
  3426. Set the random fill ratio for the initial cellular automaton row. It
  3427. is a floating point number value ranging from 0 to 1, defaults to
  3428. 1/PHI.
  3429. This option is ignored when a file or a pattern is specified.
  3430. @item random_seed, seed
  3431. Set the seed for filling randomly the initial row, must be an integer
  3432. included between 0 and UINT32_MAX. If not specified, or if explicitly
  3433. set to -1, the filter will try to use a good random seed on a best
  3434. effort basis.
  3435. @item rule
  3436. Set the cellular automaton rule, it is a number ranging from 0 to 255.
  3437. Default value is 110.
  3438. @item size, s
  3439. Set the size of the output video.
  3440. If @option{filename} or @option{pattern} is specified, the size is set
  3441. by default to the width of the specified initial state row, and the
  3442. height is set to @var{width} * PHI.
  3443. If @option{size} is set, it must contain the width of the specified
  3444. pattern string, and the specified pattern will be centered in the
  3445. larger row.
  3446. If a filename or a pattern string is not specified, the size value
  3447. defaults to "320x518" (used for a randomly generated initial state).
  3448. @item scroll
  3449. If set to 1, scroll the output upward when all the rows in the output
  3450. have been already filled. If set to 0, the new generated row will be
  3451. written over the top row just after the bottom row is filled.
  3452. Defaults to 1.
  3453. @item start_full, full
  3454. If set to 1, completely fill the output with generated rows before
  3455. outputting the first frame.
  3456. This is the default behavior, for disabling set the value to 0.
  3457. @item stitch
  3458. If set to 1, stitch the left and right row edges together.
  3459. This is the default behavior, for disabling set the value to 0.
  3460. @end table
  3461. @subsection Examples
  3462. @itemize
  3463. @item
  3464. Read the initial state from @file{pattern}, and specify an output of
  3465. size 200x400.
  3466. @example
  3467. cellauto=f=pattern:s=200x400
  3468. @end example
  3469. @item
  3470. Generate a random initial row with a width of 200 cells, with a fill
  3471. ratio of 2/3:
  3472. @example
  3473. cellauto=ratio=2/3:s=200x200
  3474. @end example
  3475. @item
  3476. Create a pattern generated by rule 18 starting by a single alive cell
  3477. centered on an initial row with width 100:
  3478. @example
  3479. cellauto=p=@@:s=100x400:full=0:rule=18
  3480. @end example
  3481. @item
  3482. Specify a more elaborated initial pattern:
  3483. @example
  3484. cellauto=p='@@@@ @@ @@@@':s=100x400:full=0:rule=18
  3485. @end example
  3486. @end itemize
  3487. @section mandelbrot
  3488. Generate a Mandelbrot set fractal, and progressively zoom towards the
  3489. point specified with @var{start_x} and @var{start_y}.
  3490. This source accepts a list of options in the form of
  3491. @var{key}=@var{value} pairs separated by ":". A description of the
  3492. accepted options follows.
  3493. @table @option
  3494. @item end_pts
  3495. Set the terminal pts value. Default value is 400.
  3496. @item end_scale
  3497. Set the terminal scale value.
  3498. Must be a floating point value. Default value is 0.3.
  3499. @item inner
  3500. Set the inner coloring mode, that is the algorithm used to draw the
  3501. Mandelbrot fractal internal region.
  3502. It shall assume one of the following values:
  3503. @table @option
  3504. @item black
  3505. Set black mode.
  3506. @item convergence
  3507. Show time until convergence.
  3508. @item mincol
  3509. Set color based on point closest to the origin of the iterations.
  3510. @item period
  3511. Set period mode.
  3512. @end table
  3513. Default value is @var{mincol}.
  3514. @item bailout
  3515. Set the bailout value. Default value is 10.0.
  3516. @item maxiter
  3517. Set the maximum of iterations performed by the rendering
  3518. algorithm. Default value is 7189.
  3519. @item outer
  3520. Set outer coloring mode.
  3521. It shall assume one of following values:
  3522. @table @option
  3523. @item iteration_count
  3524. Set iteration cound mode.
  3525. @item normalized_iteration_count
  3526. set normalized iteration count mode.
  3527. @end table
  3528. Default value is @var{normalized_iteration_count}.
  3529. @item rate, r
  3530. Set frame rate, expressed as number of frames per second. Default
  3531. value is "25".
  3532. @item size, s
  3533. Set frame size. Default value is "640x480".
  3534. @item start_scale
  3535. Set the initial scale value. Default value is 3.0.
  3536. @item start_x
  3537. Set the initial x position. Must be a floating point value between
  3538. -100 and 100. Default value is -0.743643887037158704752191506114774.
  3539. @item start_y
  3540. Set the initial y position. Must be a floating point value between
  3541. -100 and 100. Default value is -0.131825904205311970493132056385139.
  3542. @end table
  3543. @section mptestsrc
  3544. Generate various test patterns, as generated by the MPlayer test filter.
  3545. The size of the generated video is fixed, and is 256x256.
  3546. This source is useful in particular for testing encoding features.
  3547. This source accepts an optional sequence of @var{key}=@var{value} pairs,
  3548. separated by ":". The description of the accepted options follows.
  3549. @table @option
  3550. @item rate, r
  3551. Specify the frame rate of the sourced video, as the number of frames
  3552. generated per second. It has to be a string in the format
  3553. @var{frame_rate_num}/@var{frame_rate_den}, an integer number, a float
  3554. number or a valid video frame rate abbreviation. The default value is
  3555. "25".
  3556. @item duration, d
  3557. Set the video duration of the sourced video. The accepted syntax is:
  3558. @example
  3559. [-]HH:MM:SS[.m...]
  3560. [-]S+[.m...]
  3561. @end example
  3562. See also the function @code{av_parse_time()}.
  3563. If not specified, or the expressed duration is negative, the video is
  3564. supposed to be generated forever.
  3565. @item test, t
  3566. Set the number or the name of the test to perform. Supported tests are:
  3567. @table @option
  3568. @item dc_luma
  3569. @item dc_chroma
  3570. @item freq_luma
  3571. @item freq_chroma
  3572. @item amp_luma
  3573. @item amp_chroma
  3574. @item cbp
  3575. @item mv
  3576. @item ring1
  3577. @item ring2
  3578. @item all
  3579. @end table
  3580. Default value is "all", which will cycle through the list of all tests.
  3581. @end table
  3582. For example the following:
  3583. @example
  3584. testsrc=t=dc_luma
  3585. @end example
  3586. will generate a "dc_luma" test pattern.
  3587. @section frei0r_src
  3588. Provide a frei0r source.
  3589. To enable compilation of this filter you need to install the frei0r
  3590. header and configure FFmpeg with @code{--enable-frei0r}.
  3591. The source supports the syntax:
  3592. @example
  3593. @var{size}:@var{rate}:@var{src_name}[@{=|:@}@var{param1}:@var{param2}:...:@var{paramN}]
  3594. @end example
  3595. @var{size} is the size of the video to generate, may be a string of the
  3596. form @var{width}x@var{height} or a frame size abbreviation.
  3597. @var{rate} is the rate of the video to generate, may be a string of
  3598. the form @var{num}/@var{den} or a frame rate abbreviation.
  3599. @var{src_name} is the name to the frei0r source to load. For more
  3600. information regarding frei0r and how to set the parameters read the
  3601. section @ref{frei0r} in the description of the video filters.
  3602. For example, to generate a frei0r partik0l source with size 200x200
  3603. and frame rate 10 which is overlayed on the overlay filter main input:
  3604. @example
  3605. frei0r_src=200x200:10:partik0l=1234 [overlay]; [in][overlay] overlay
  3606. @end example
  3607. @section life
  3608. Generate a life pattern.
  3609. This source is based on a generalization of John Conway's life game.
  3610. The sourced input represents a life grid, each pixel represents a cell
  3611. which can be in one of two possible states, alive or dead. Every cell
  3612. interacts with its eight neighbours, which are the cells that are
  3613. horizontally, vertically, or diagonally adjacent.
  3614. At each interaction the grid evolves according to the adopted rule,
  3615. which specifies the number of neighbor alive cells which will make a
  3616. cell stay alive or born. The @option{rule} option allows to specify
  3617. the rule to adopt.
  3618. This source accepts a list of options in the form of
  3619. @var{key}=@var{value} pairs separated by ":". A description of the
  3620. accepted options follows.
  3621. @table @option
  3622. @item filename, f
  3623. Set the file from which to read the initial grid state. In the file,
  3624. each non-whitespace character is considered an alive cell, and newline
  3625. is used to delimit the end of each row.
  3626. If this option is not specified, the initial grid is generated
  3627. randomly.
  3628. @item rate, r
  3629. Set the video rate, that is the number of frames generated per second.
  3630. Default is 25.
  3631. @item random_fill_ratio, ratio
  3632. Set the random fill ratio for the initial random grid. It is a
  3633. floating point number value ranging from 0 to 1, defaults to 1/PHI.
  3634. It is ignored when a file is specified.
  3635. @item random_seed, seed
  3636. Set the seed for filling the initial random grid, must be an integer
  3637. included between 0 and UINT32_MAX. If not specified, or if explicitly
  3638. set to -1, the filter will try to use a good random seed on a best
  3639. effort basis.
  3640. @item rule
  3641. Set the life rule.
  3642. A rule can be specified with a code of the kind "S@var{NS}/B@var{NB}",
  3643. where @var{NS} and @var{NB} are sequences of numbers in the range 0-8,
  3644. @var{NS} specifies the number of alive neighbor cells which make a
  3645. live cell stay alive, and @var{NB} the number of alive neighbor cells
  3646. which make a dead cell to become alive (i.e. to "born").
  3647. "s" and "b" can be used in place of "S" and "B", respectively.
  3648. Alternatively a rule can be specified by an 18-bits integer. The 9
  3649. high order bits are used to encode the next cell state if it is alive
  3650. for each number of neighbor alive cells, the low order bits specify
  3651. the rule for "borning" new cells. Higher order bits encode for an
  3652. higher number of neighbor cells.
  3653. For example the number 6153 = @code{(12<<9)+9} specifies a stay alive
  3654. rule of 12 and a born rule of 9, which corresponds to "S23/B03".
  3655. Default value is "S23/B3", which is the original Conway's game of life
  3656. rule, and will keep a cell alive if it has 2 or 3 neighbor alive
  3657. cells, and will born a new cell if there are three alive cells around
  3658. a dead cell.
  3659. @item size, s
  3660. Set the size of the output video.
  3661. If @option{filename} is specified, the size is set by default to the
  3662. same size of the input file. If @option{size} is set, it must contain
  3663. the size specified in the input file, and the initial grid defined in
  3664. that file is centered in the larger resulting area.
  3665. If a filename is not specified, the size value defaults to "320x240"
  3666. (used for a randomly generated initial grid).
  3667. @item stitch
  3668. If set to 1, stitch the left and right grid edges together, and the
  3669. top and bottom edges also. Defaults to 1.
  3670. @item mold
  3671. Set cell mold speed. If set, a dead cell will go from @option{death_color} to
  3672. @option{mold_color} with a step of @option{mold}. @option{mold} can have a
  3673. value from 0 to 255.
  3674. @item life_color
  3675. Set the color of living (or new born) cells.
  3676. @item death_color
  3677. Set the color of dead cells. If @option{mold} is set, this is the first color
  3678. used to represent a dead cell.
  3679. @item mold_color
  3680. Set mold color, for definitely dead and moldy cells.
  3681. @end table
  3682. @subsection Examples
  3683. @itemize
  3684. @item
  3685. Read a grid from @file{pattern}, and center it on a grid of size
  3686. 300x300 pixels:
  3687. @example
  3688. life=f=pattern:s=300x300
  3689. @end example
  3690. @item
  3691. Generate a random grid of size 200x200, with a fill ratio of 2/3:
  3692. @example
  3693. life=ratio=2/3:s=200x200
  3694. @end example
  3695. @item
  3696. Specify a custom rule for evolving a randomly generated grid:
  3697. @example
  3698. life=rule=S14/B34
  3699. @end example
  3700. @item
  3701. Full example with slow death effect (mold) using @command{ffplay}:
  3702. @example
  3703. ffplay -f lavfi life=s=300x200:mold=10:r=60:ratio=0.1:death_color=#C83232:life_color=#00ff00,scale=1200:800:flags=16
  3704. @end example
  3705. @end itemize
  3706. @section color, nullsrc, rgbtestsrc, smptebars, testsrc
  3707. The @code{color} source provides an uniformly colored input.
  3708. The @code{nullsrc} source returns unprocessed video frames. It is
  3709. mainly useful to be employed in analysis / debugging tools, or as the
  3710. source for filters which ignore the input data.
  3711. The @code{rgbtestsrc} source generates an RGB test pattern useful for
  3712. detecting RGB vs BGR issues. You should see a red, green and blue
  3713. stripe from top to bottom.
  3714. The @code{smptebars} source generates a color bars pattern, based on
  3715. the SMPTE Engineering Guideline EG 1-1990.
  3716. The @code{testsrc} source generates a test video pattern, showing a
  3717. color pattern, a scrolling gradient and a timestamp. This is mainly
  3718. intended for testing purposes.
  3719. These sources accept an optional sequence of @var{key}=@var{value} pairs,
  3720. separated by ":". The description of the accepted options follows.
  3721. @table @option
  3722. @item color, c
  3723. Specify the color of the source, only used in the @code{color}
  3724. source. It can be the name of a color (case insensitive match) or a
  3725. 0xRRGGBB[AA] sequence, possibly followed by an alpha specifier. The
  3726. default value is "black".
  3727. @item size, s
  3728. Specify the size of the sourced video, it may be a string of the form
  3729. @var{width}x@var{height}, or the name of a size abbreviation. The
  3730. default value is "320x240".
  3731. @item rate, r
  3732. Specify the frame rate of the sourced video, as the number of frames
  3733. generated per second. It has to be a string in the format
  3734. @var{frame_rate_num}/@var{frame_rate_den}, an integer number, a float
  3735. number or a valid video frame rate abbreviation. The default value is
  3736. "25".
  3737. @item sar
  3738. Set the sample aspect ratio of the sourced video.
  3739. @item duration, d
  3740. Set the video duration of the sourced video. The accepted syntax is:
  3741. @example
  3742. [-]HH[:MM[:SS[.m...]]]
  3743. [-]S+[.m...]
  3744. @end example
  3745. See also the function @code{av_parse_time()}.
  3746. If not specified, or the expressed duration is negative, the video is
  3747. supposed to be generated forever.
  3748. @item decimals, n
  3749. Set the number of decimals to show in the timestamp, only used in the
  3750. @code{testsrc} source.
  3751. The displayed timestamp value will correspond to the original
  3752. timestamp value multiplied by the power of 10 of the specified
  3753. value. Default value is 0.
  3754. @end table
  3755. For example the following:
  3756. @example
  3757. testsrc=duration=5.3:size=qcif:rate=10
  3758. @end example
  3759. will generate a video with a duration of 5.3 seconds, with size
  3760. 176x144 and a frame rate of 10 frames per second.
  3761. The following graph description will generate a red source
  3762. with an opacity of 0.2, with size "qcif" and a frame rate of 10
  3763. frames per second.
  3764. @example
  3765. color=c=red@@0.2:s=qcif:r=10
  3766. @end example
  3767. If the input content is to be ignored, @code{nullsrc} can be used. The
  3768. following command generates noise in the luminance plane by employing
  3769. the @code{geq} filter:
  3770. @example
  3771. nullsrc=s=256x256, geq=random(1)*255:128:128
  3772. @end example
  3773. @c man end VIDEO SOURCES
  3774. @chapter Video Sinks
  3775. @c man begin VIDEO SINKS
  3776. Below is a description of the currently available video sinks.
  3777. @section buffersink
  3778. Buffer video frames, and make them available to the end of the filter
  3779. graph.
  3780. This sink is mainly intended for a programmatic use, in particular
  3781. through the interface defined in @file{libavfilter/buffersink.h}.
  3782. It does not require a string parameter in input, but you need to
  3783. specify a pointer to a list of supported pixel formats terminated by
  3784. -1 in the opaque parameter provided to @code{avfilter_init_filter}
  3785. when initializing this sink.
  3786. @section nullsink
  3787. Null video sink, do absolutely nothing with the input video. It is
  3788. mainly useful as a template and to be employed in analysis / debugging
  3789. tools.
  3790. @c man end VIDEO SINKS
  3791. @chapter Multimedia Filters
  3792. @c man begin MULTIMEDIA FILTERS
  3793. Below is a description of the currently available multimedia filters.
  3794. @section aselect, select
  3795. Select frames to pass in output.
  3796. These filters accept a single option @option{expr} or @option{e}
  3797. specifying the select expression, which can be specified either by
  3798. specyfing @code{expr=VALUE} or specifying the expression
  3799. alone.
  3800. The select expression is evaluated for each input frame. If the
  3801. evaluation result is a non-zero value, the frame is selected and
  3802. passed to the output, otherwise it is discarded.
  3803. The expression can contain the following constants:
  3804. @table @option
  3805. @item n
  3806. the sequential number of the filtered frame, starting from 0
  3807. @item selected_n
  3808. the sequential number of the selected frame, starting from 0
  3809. @item prev_selected_n
  3810. the sequential number of the last selected frame, NAN if undefined
  3811. @item TB
  3812. timebase of the input timestamps
  3813. @item pts
  3814. the PTS (Presentation TimeStamp) of the filtered video frame,
  3815. expressed in @var{TB} units, NAN if undefined
  3816. @item t
  3817. the PTS (Presentation TimeStamp) of the filtered video frame,
  3818. expressed in seconds, NAN if undefined
  3819. @item prev_pts
  3820. the PTS of the previously filtered video frame, NAN if undefined
  3821. @item prev_selected_pts
  3822. the PTS of the last previously filtered video frame, NAN if undefined
  3823. @item prev_selected_t
  3824. the PTS of the last previously selected video frame, NAN if undefined
  3825. @item start_pts
  3826. the PTS of the first video frame in the video, NAN if undefined
  3827. @item start_t
  3828. the time of the first video frame in the video, NAN if undefined
  3829. @item pict_type @emph{(video only)}
  3830. the type of the filtered frame, can assume one of the following
  3831. values:
  3832. @table @option
  3833. @item I
  3834. @item P
  3835. @item B
  3836. @item S
  3837. @item SI
  3838. @item SP
  3839. @item BI
  3840. @end table
  3841. @item interlace_type @emph{(video only)}
  3842. the frame interlace type, can assume one of the following values:
  3843. @table @option
  3844. @item PROGRESSIVE
  3845. the frame is progressive (not interlaced)
  3846. @item TOPFIRST
  3847. the frame is top-field-first
  3848. @item BOTTOMFIRST
  3849. the frame is bottom-field-first
  3850. @end table
  3851. @item consumed_sample_n @emph{(audio only)}
  3852. the number of selected samples before the current frame
  3853. @item samples_n @emph{(audio only)}
  3854. the number of samples in the current frame
  3855. @item sample_rate @emph{(audio only)}
  3856. the input sample rate
  3857. @item key
  3858. 1 if the filtered frame is a key-frame, 0 otherwise
  3859. @item pos
  3860. the position in the file of the filtered frame, -1 if the information
  3861. is not available (e.g. for synthetic video)
  3862. @item scene @emph{(video only)}
  3863. value between 0 and 1 to indicate a new scene; a low value reflects a low
  3864. probability for the current frame to introduce a new scene, while a higher
  3865. value means the current frame is more likely to be one (see the example below)
  3866. @end table
  3867. The default value of the select expression is "1".
  3868. @subsection Examples
  3869. @itemize
  3870. @item
  3871. Select all frames in input:
  3872. @example
  3873. select
  3874. @end example
  3875. The example above is the same as:
  3876. @example
  3877. select=1
  3878. @end example
  3879. @item
  3880. Skip all frames:
  3881. @example
  3882. select=0
  3883. @end example
  3884. @item
  3885. Select only I-frames:
  3886. @example
  3887. select='eq(pict_type\,I)'
  3888. @end example
  3889. @item
  3890. Select one frame every 100:
  3891. @example
  3892. select='not(mod(n\,100))'
  3893. @end example
  3894. @item
  3895. Select only frames contained in the 10-20 time interval:
  3896. @example
  3897. select='gte(t\,10)*lte(t\,20)'
  3898. @end example
  3899. @item
  3900. Select only I frames contained in the 10-20 time interval:
  3901. @example
  3902. select='gte(t\,10)*lte(t\,20)*eq(pict_type\,I)'
  3903. @end example
  3904. @item
  3905. Select frames with a minimum distance of 10 seconds:
  3906. @example
  3907. select='isnan(prev_selected_t)+gte(t-prev_selected_t\,10)'
  3908. @end example
  3909. @item
  3910. Use aselect to select only audio frames with samples number > 100:
  3911. @example
  3912. aselect='gt(samples_n\,100)'
  3913. @end example
  3914. @item
  3915. Create a mosaic of the first scenes:
  3916. @example
  3917. ffmpeg -i video.avi -vf select='gt(scene\,0.4)',scale=160:120,tile -frames:v 1 preview.png
  3918. @end example
  3919. Comparing @var{scene} against a value between 0.3 and 0.5 is generally a sane
  3920. choice.
  3921. @end itemize
  3922. @section asendcmd, sendcmd
  3923. Send commands to filters in the filtergraph.
  3924. These filters read commands to be sent to other filters in the
  3925. filtergraph.
  3926. @code{asendcmd} must be inserted between two audio filters,
  3927. @code{sendcmd} must be inserted between two video filters, but apart
  3928. from that they act the same way.
  3929. The specification of commands can be provided in the filter arguments
  3930. with the @var{commands} option, or in a file specified by the
  3931. @var{filename} option.
  3932. These filters accept the following options:
  3933. @table @option
  3934. @item commands, c
  3935. Set the commands to be read and sent to the other filters.
  3936. @item filename, f
  3937. Set the filename of the commands to be read and sent to the other
  3938. filters.
  3939. @end table
  3940. @subsection Commands syntax
  3941. A commands description consists of a sequence of interval
  3942. specifications, comprising a list of commands to be executed when a
  3943. particular event related to that interval occurs. The occurring event
  3944. is typically the current frame time entering or leaving a given time
  3945. interval.
  3946. An interval is specified by the following syntax:
  3947. @example
  3948. @var{START}[-@var{END}] @var{COMMANDS};
  3949. @end example
  3950. The time interval is specified by the @var{START} and @var{END} times.
  3951. @var{END} is optional and defaults to the maximum time.
  3952. The current frame time is considered within the specified interval if
  3953. it is included in the interval [@var{START}, @var{END}), that is when
  3954. the time is greater or equal to @var{START} and is lesser than
  3955. @var{END}.
  3956. @var{COMMANDS} consists of a sequence of one or more command
  3957. specifications, separated by ",", relating to that interval. The
  3958. syntax of a command specification is given by:
  3959. @example
  3960. [@var{FLAGS}] @var{TARGET} @var{COMMAND} @var{ARG}
  3961. @end example
  3962. @var{FLAGS} is optional and specifies the type of events relating to
  3963. the time interval which enable sending the specified command, and must
  3964. be a non-null sequence of identifier flags separated by "+" or "|" and
  3965. enclosed between "[" and "]".
  3966. The following flags are recognized:
  3967. @table @option
  3968. @item enter
  3969. The command is sent when the current frame timestamp enters the
  3970. specified interval. In other words, the command is sent when the
  3971. previous frame timestamp was not in the given interval, and the
  3972. current is.
  3973. @item leave
  3974. The command is sent when the current frame timestamp leaves the
  3975. specified interval. In other words, the command is sent when the
  3976. previous frame timestamp was in the given interval, and the
  3977. current is not.
  3978. @end table
  3979. If @var{FLAGS} is not specified, a default value of @code{[enter]} is
  3980. assumed.
  3981. @var{TARGET} specifies the target of the command, usually the name of
  3982. the filter class or a specific filter instance name.
  3983. @var{COMMAND} specifies the name of the command for the target filter.
  3984. @var{ARG} is optional and specifies the optional list of argument for
  3985. the given @var{COMMAND}.
  3986. Between one interval specification and another, whitespaces, or
  3987. sequences of characters starting with @code{#} until the end of line,
  3988. are ignored and can be used to annotate comments.
  3989. A simplified BNF description of the commands specification syntax
  3990. follows:
  3991. @example
  3992. @var{COMMAND_FLAG} ::= "enter" | "leave"
  3993. @var{COMMAND_FLAGS} ::= @var{COMMAND_FLAG} [(+|"|")@var{COMMAND_FLAG}]
  3994. @var{COMMAND} ::= ["[" @var{COMMAND_FLAGS} "]"] @var{TARGET} @var{COMMAND} [@var{ARG}]
  3995. @var{COMMANDS} ::= @var{COMMAND} [,@var{COMMANDS}]
  3996. @var{INTERVAL} ::= @var{START}[-@var{END}] @var{COMMANDS}
  3997. @var{INTERVALS} ::= @var{INTERVAL}[;@var{INTERVALS}]
  3998. @end example
  3999. @subsection Examples
  4000. @itemize
  4001. @item
  4002. Specify audio tempo change at second 4:
  4003. @example
  4004. asendcmd=c='4.0 atempo tempo 1.5',atempo
  4005. @end example
  4006. @item
  4007. Specify a list of drawtext and hue commands in a file.
  4008. @example
  4009. # show text in the interval 5-10
  4010. 5.0-10.0 [enter] drawtext reinit 'fontfile=FreeSerif.ttf:text=hello world',
  4011. [leave] drawtext reinit 'fontfile=FreeSerif.ttf:text=';
  4012. # desaturate the image in the interval 15-20
  4013. 15.0-20.0 [enter] hue reinit s=0,
  4014. [enter] drawtext reinit 'fontfile=FreeSerif.ttf:text=nocolor',
  4015. [leave] hue reinit s=1,
  4016. [leave] drawtext reinit 'fontfile=FreeSerif.ttf:text=color';
  4017. # apply an exponential saturation fade-out effect, starting from time 25
  4018. 25 [enter] hue s=exp(t-25)
  4019. @end example
  4020. A filtergraph allowing to read and process the above command list
  4021. stored in a file @file{test.cmd}, can be specified with:
  4022. @example
  4023. sendcmd=f=test.cmd,drawtext=fontfile=FreeSerif.ttf:text='',hue
  4024. @end example
  4025. @end itemize
  4026. @anchor{setpts}
  4027. @section asetpts, setpts
  4028. Change the PTS (presentation timestamp) of the input frames.
  4029. @code{asetpts} works on audio frames, @code{setpts} on video frames.
  4030. Accept in input an expression evaluated through the eval API, which
  4031. can contain the following constants:
  4032. @table @option
  4033. @item FRAME_RATE
  4034. frame rate, only defined for constant frame-rate video
  4035. @item PTS
  4036. the presentation timestamp in input
  4037. @item N
  4038. the count of the input frame, starting from 0.
  4039. @item NB_CONSUMED_SAMPLES
  4040. the number of consumed samples, not including the current frame (only
  4041. audio)
  4042. @item NB_SAMPLES
  4043. the number of samples in the current frame (only audio)
  4044. @item SAMPLE_RATE
  4045. audio sample rate
  4046. @item STARTPTS
  4047. the PTS of the first frame
  4048. @item STARTT
  4049. the time in seconds of the first frame
  4050. @item INTERLACED
  4051. tell if the current frame is interlaced
  4052. @item T
  4053. the time in seconds of the current frame
  4054. @item TB
  4055. the time base
  4056. @item POS
  4057. original position in the file of the frame, or undefined if undefined
  4058. for the current frame
  4059. @item PREV_INPTS
  4060. previous input PTS
  4061. @item PREV_INT
  4062. previous input time in seconds
  4063. @item PREV_OUTPTS
  4064. previous output PTS
  4065. @item PREV_OUTT
  4066. previous output time in seconds
  4067. @end table
  4068. @subsection Examples
  4069. @itemize
  4070. @item
  4071. Start counting PTS from zero
  4072. @example
  4073. setpts=PTS-STARTPTS
  4074. @end example
  4075. @item
  4076. Apply fast motion effect:
  4077. @example
  4078. setpts=0.5*PTS
  4079. @end example
  4080. @item
  4081. Apply slow motion effect:
  4082. @example
  4083. setpts=2.0*PTS
  4084. @end example
  4085. @item
  4086. Set fixed rate of 25 frames per second:
  4087. @example
  4088. setpts=N/(25*TB)
  4089. @end example
  4090. @item
  4091. Set fixed rate 25 fps with some jitter:
  4092. @example
  4093. setpts='1/(25*TB) * (N + 0.05 * sin(N*2*PI/25))'
  4094. @end example
  4095. @item
  4096. Apply an offset of 10 seconds to the input PTS:
  4097. @example
  4098. setpts=PTS+10/TB
  4099. @end example
  4100. @end itemize
  4101. @section ebur128
  4102. EBU R128 scanner filter. This filter takes an audio stream as input and outputs
  4103. it unchanged. By default, it logs a message at a frequency of 10Hz with the
  4104. Momentary loudness (identified by @code{M}), Short-term loudness (@code{S}),
  4105. Integrated loudness (@code{I}) and Loudness Range (@code{LRA}).
  4106. The filter also has a video output (see the @var{video} option) with a real
  4107. time graph to observe the loudness evolution. The graphic contains the logged
  4108. message mentioned above, so it is not printed anymore when this option is set,
  4109. unless the verbose logging is set. The main graphing area contains the
  4110. short-term loudness (3 seconds of analysis), and the gauge on the right is for
  4111. the momentary loudness (400 milliseconds).
  4112. More information about the Loudness Recommendation EBU R128 on
  4113. @url{http://tech.ebu.ch/loudness}.
  4114. The filter accepts the following named parameters:
  4115. @table @option
  4116. @item video
  4117. Activate the video output. The audio stream is passed unchanged whether this
  4118. option is set or no. The video stream will be the first output stream if
  4119. activated. Default is @code{0}.
  4120. @item size
  4121. Set the video size. This option is for video only. Default and minimum
  4122. resolution is @code{640x480}.
  4123. @item meter
  4124. Set the EBU scale meter. Default is @code{9}. Common values are @code{9} and
  4125. @code{18}, respectively for EBU scale meter +9 and EBU scale meter +18. Any
  4126. other integer value between this range is allowed.
  4127. @end table
  4128. Example of real-time graph using @command{ffplay}, with a EBU scale meter +18:
  4129. @example
  4130. ffplay -f lavfi -i "amovie=input.mp3,ebur128=video=1:meter=18 [out0][out1]"
  4131. @end example
  4132. Run an analysis with @command{ffmpeg}:
  4133. @example
  4134. ffmpeg -nostats -i input.mp3 -filter_complex ebur128 -f null -
  4135. @end example
  4136. @section settb, asettb
  4137. Set the timebase to use for the output frames timestamps.
  4138. It is mainly useful for testing timebase configuration.
  4139. It accepts in input an arithmetic expression representing a rational.
  4140. The expression can contain the constants "AVTB" (the
  4141. default timebase), "intb" (the input timebase) and "sr" (the sample rate,
  4142. audio only).
  4143. The default value for the input is "intb".
  4144. @subsection Examples
  4145. @itemize
  4146. @item
  4147. Set the timebase to 1/25:
  4148. @example
  4149. settb=1/25
  4150. @end example
  4151. @item
  4152. Set the timebase to 1/10:
  4153. @example
  4154. settb=0.1
  4155. @end example
  4156. @item
  4157. Set the timebase to 1001/1000:
  4158. @example
  4159. settb=1+0.001
  4160. @end example
  4161. @item
  4162. Set the timebase to 2*intb:
  4163. @example
  4164. settb=2*intb
  4165. @end example
  4166. @item
  4167. Set the default timebase value:
  4168. @example
  4169. settb=AVTB
  4170. @end example
  4171. @end itemize
  4172. @section concat
  4173. Concatenate audio and video streams, joining them together one after the
  4174. other.
  4175. The filter works on segments of synchronized video and audio streams. All
  4176. segments must have the same number of streams of each type, and that will
  4177. also be the number of streams at output.
  4178. The filter accepts the following named parameters:
  4179. @table @option
  4180. @item n
  4181. Set the number of segments. Default is 2.
  4182. @item v
  4183. Set the number of output video streams, that is also the number of video
  4184. streams in each segment. Default is 1.
  4185. @item a
  4186. Set the number of output audio streams, that is also the number of video
  4187. streams in each segment. Default is 0.
  4188. @item unsafe
  4189. Activate unsafe mode: do not fail if segments have a different format.
  4190. @end table
  4191. The filter has @var{v}+@var{a} outputs: first @var{v} video outputs, then
  4192. @var{a} audio outputs.
  4193. There are @var{n}x(@var{v}+@var{a}) inputs: first the inputs for the first
  4194. segment, in the same order as the outputs, then the inputs for the second
  4195. segment, etc.
  4196. Related streams do not always have exactly the same duration, for various
  4197. reasons including codec frame size or sloppy authoring. For that reason,
  4198. related synchronized streams (e.g. a video and its audio track) should be
  4199. concatenated at once. The concat filter will use the duration of the longest
  4200. stream in each segment (except the last one), and if necessary pad shorter
  4201. audio streams with silence.
  4202. For this filter to work correctly, all segments must start at timestamp 0.
  4203. All corresponding streams must have the same parameters in all segments; the
  4204. filtering system will automatically select a common pixel format for video
  4205. streams, and a common sample format, sample rate and channel layout for
  4206. audio streams, but other settings, such as resolution, must be converted
  4207. explicitly by the user.
  4208. Different frame rates are acceptable but will result in variable frame rate
  4209. at output; be sure to configure the output file to handle it.
  4210. Examples:
  4211. @itemize
  4212. @item
  4213. Concatenate an opening, an episode and an ending, all in bilingual version
  4214. (video in stream 0, audio in streams 1 and 2):
  4215. @example
  4216. ffmpeg -i opening.mkv -i episode.mkv -i ending.mkv -filter_complex \
  4217. '[0:0] [0:1] [0:2] [1:0] [1:1] [1:2] [2:0] [2:1] [2:2]
  4218. concat=n=3:v=1:a=2 [v] [a1] [a2]' \
  4219. -map '[v]' -map '[a1]' -map '[a2]' output.mkv
  4220. @end example
  4221. @item
  4222. Concatenate two parts, handling audio and video separately, using the
  4223. (a)movie sources, and adjusting the resolution:
  4224. @example
  4225. movie=part1.mp4, scale=512:288 [v1] ; amovie=part1.mp4 [a1] ;
  4226. movie=part2.mp4, scale=512:288 [v2] ; amovie=part2.mp4 [a2] ;
  4227. [v1] [v2] concat [outv] ; [a1] [a2] concat=v=0:a=1 [outa]
  4228. @end example
  4229. Note that a desync will happen at the stitch if the audio and video streams
  4230. do not have exactly the same duration in the first file.
  4231. @end itemize
  4232. @section showspectrum
  4233. Convert input audio to a video output, representing the audio frequency
  4234. spectrum.
  4235. The filter accepts the following named parameters:
  4236. @table @option
  4237. @item size, s
  4238. Specify the video size for the output. Default value is @code{640x480}.
  4239. @item slide
  4240. Specify if the spectrum should slide along the window. Default value is
  4241. @code{0}.
  4242. @end table
  4243. The usage is very similar to the showwaves filter; see the examples in that
  4244. section.
  4245. @section showwaves
  4246. Convert input audio to a video output, representing the samples waves.
  4247. The filter accepts the following named parameters:
  4248. @table @option
  4249. @item n
  4250. Set the number of samples which are printed on the same column. A
  4251. larger value will decrease the frame rate. Must be a positive
  4252. integer. This option can be set only if the value for @var{rate}
  4253. is not explicitly specified.
  4254. @item rate, r
  4255. Set the (approximate) output frame rate. This is done by setting the
  4256. option @var{n}. Default value is "25".
  4257. @item size, s
  4258. Specify the video size for the output. Default value is "600x240".
  4259. @end table
  4260. Some examples follow.
  4261. @itemize
  4262. @item
  4263. Output the input file audio and the corresponding video representation
  4264. at the same time:
  4265. @example
  4266. amovie=a.mp3,asplit[out0],showwaves[out1]
  4267. @end example
  4268. @item
  4269. Create a synthetic signal and show it with showwaves, forcing a
  4270. framerate of 30 frames per second:
  4271. @example
  4272. aevalsrc=sin(1*2*PI*t)*sin(880*2*PI*t):cos(2*PI*200*t),asplit[out0],showwaves=r=30[out1]
  4273. @end example
  4274. @end itemize
  4275. @c man end MULTIMEDIA FILTERS
  4276. @chapter Multimedia Sources
  4277. @c man begin MULTIMEDIA SOURCES
  4278. Below is a description of the currently available multimedia sources.
  4279. @section amovie
  4280. This is the same as @ref{movie} source, except it selects an audio
  4281. stream by default.
  4282. @anchor{movie}
  4283. @section movie
  4284. Read audio and/or video stream(s) from a movie container.
  4285. It accepts the syntax: @var{movie_name}[:@var{options}] where
  4286. @var{movie_name} is the name of the resource to read (not necessarily
  4287. a file but also a device or a stream accessed through some protocol),
  4288. and @var{options} is an optional sequence of @var{key}=@var{value}
  4289. pairs, separated by ":".
  4290. The description of the accepted options follows.
  4291. @table @option
  4292. @item format_name, f
  4293. Specifies the format assumed for the movie to read, and can be either
  4294. the name of a container or an input device. If not specified the
  4295. format is guessed from @var{movie_name} or by probing.
  4296. @item seek_point, sp
  4297. Specifies the seek point in seconds, the frames will be output
  4298. starting from this seek point, the parameter is evaluated with
  4299. @code{av_strtod} so the numerical value may be suffixed by an IS
  4300. postfix. Default value is "0".
  4301. @item streams, s
  4302. Specifies the streams to read. Several streams can be specified,
  4303. separated by "+". The source will then have as many outputs, in the
  4304. same order. The syntax is explained in the ``Stream specifiers''
  4305. section in the ffmpeg manual. Two special names, "dv" and "da" specify
  4306. respectively the default (best suited) video and audio stream. Default
  4307. is "dv", or "da" if the filter is called as "amovie".
  4308. @item stream_index, si
  4309. Specifies the index of the video stream to read. If the value is -1,
  4310. the best suited video stream will be automatically selected. Default
  4311. value is "-1". Deprecated. If the filter is called "amovie", it will select
  4312. audio instead of video.
  4313. @item loop
  4314. Specifies how many times to read the stream in sequence.
  4315. If the value is less than 1, the stream will be read again and again.
  4316. Default value is "1".
  4317. Note that when the movie is looped the source timestamps are not
  4318. changed, so it will generate non monotonically increasing timestamps.
  4319. @end table
  4320. This filter allows to overlay a second video on top of main input of
  4321. a filtergraph as shown in this graph:
  4322. @example
  4323. input -----------> deltapts0 --> overlay --> output
  4324. ^
  4325. |
  4326. movie --> scale--> deltapts1 -------+
  4327. @end example
  4328. Some examples follow.
  4329. @itemize
  4330. @item
  4331. Skip 3.2 seconds from the start of the avi file in.avi, and overlay it
  4332. on top of the input labelled as "in":
  4333. @example
  4334. movie=in.avi:seek_point=3.2, scale=180:-1, setpts=PTS-STARTPTS [movie];
  4335. [in] setpts=PTS-STARTPTS, [movie] overlay=16:16 [out]
  4336. @end example
  4337. @item
  4338. Read from a video4linux2 device, and overlay it on top of the input
  4339. labelled as "in":
  4340. @example
  4341. movie=/dev/video0:f=video4linux2, scale=180:-1, setpts=PTS-STARTPTS [movie];
  4342. [in] setpts=PTS-STARTPTS, [movie] overlay=16:16 [out]
  4343. @end example
  4344. @item
  4345. Read the first video stream and the audio stream with id 0x81 from
  4346. dvd.vob; the video is connected to the pad named "video" and the audio is
  4347. connected to the pad named "audio":
  4348. @example
  4349. movie=dvd.vob:s=v:0+#0x81 [video] [audio]
  4350. @end example
  4351. @end itemize
  4352. @c man end MULTIMEDIA SOURCES