FFmpeg filter graph
New to topics? Read the documentation here!
Filter graphs are a thing of great beauty. What an amazingly obscure domain-specific language, but which can produce striking results with very little!!!
A quick example from stackoverflow.com/questions/59551013/how-to-generate-stereo-sine-wave-using-ffmpeg-with-different-frequencies-for-eac/77730492#77730492 illustrates some of the fundamentals:
ffplay -autoexit -nodisp -f lavfi -i '
sine=frequency=500[a];
sine=frequency=1000[b];
[a][b]amerge, atrim=end=2
'
+--------+
[sine=frequency=500]--->[a]-->| |
| amerge |-->[atrim]-->[output]
[sine=frequency=1000]-->[b]-->| |
+--------+
So we see the following syntax patterns:
sine
,amerge
andatrim
are filterssine=frequency=500
: the first=
says "araguments follow"frequency=500
sets thefrequency
argument of thesine
filter- for multiple arguments the syntax is to separate arguments with colons e.g.
sine=frequency=500:duration=2
;
: separates statements[a]
,[b]
: sets the name of an edge,
: creates unnamed edge between filters that have one input and one output
A list of all filters can be obtained ith:and parameters for a single filter can be obtained with:Related question: stackoverflow.com/questions/69251087/in-ffmpeg-command-line-how-to-show-all-filter-settings-and-their-parameters-bef
ffmpeg -filters
ffmpeg --help filter=sine
TODO dump graph to ASCII art? trac.ffmpeg.org/wiki/FilteringGuide#Visualizingfilters mentions a
-dumpgraph
option, but haven't managed to use it yet.Bibliography:
- ffmpeg.org/ffmpeg-filters.html official documentation
- trac.ffmpeg.org/wiki/FilteringGuide some handy tips from the FFMpeg Wiki