create a new filter with a specific signature selecting a subset of actual ffmpeg filter args?
See original GitHub issueApologies for what might be an incredibly dumb or obvious question: I’m new here. I was thinking about trying to add a ‘fade’ filter – as much to learn the interface and repo as anything else… then my usecase morphed a little bit into something more like “What if I wanted to implement a filter that exposed a subset of the arguments or mangled them in a specific way?”. A couple of illustrative examples might be:
- implement a
fadeByTime
filter, where the signature was something like:def fadeByTime(stream, direction=in, offset=0, fade_len=0, **kwargs)
– but in my contrived example, the offset and duration would be interpreted in seconds rather than in frames… In the code I would then map the inputs of this function to the actual ffmpegfade
filter with the arguments {t=direction, st=offset, d=fade_len
}
In much more general terms, I guess I’m asking how this library knows or decides that some parameters for some filters are position and some appear to be defined by keywords.
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
FFmpeg Filters Documentation
Some filters take in input a list of parameters: they are specified after the filter name and an equal sign, and are separated...
Read more >FFmpeg filters
Some filters take in input a list of parameters: they are specified after the filter name and an equal sign, and are separated...
Read more >FFmpeg: possible to apply filter to only part of a video file ...
How do I flip only a subsection of a video using ffmpeg ? Here, -filter_complex is your friend, as it can create chains...
Read more >3 Common Tasks
Check Existing Layers: Before creating a new layer, you should be sure ... that building for a particular machine affects only the signature...
Read more >How to download portion of video with youtube-dl command?
I don't believe youtube-dl alone will do what you want. However you can combine it with a command line utility like ffmpeg. First...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
In short:
ffmpeg.input
/.filter
/.output
/ etc), it can be compiled into the corresponding ffmpeg command-line arguments usingffmpeg.compile
(whichffmpeg.run
uses internally).-filter_complex
command-line argument (e.g. the things that show up as e.g.[s0]
,[s1]
, etc.A key thing to note is that everything in this design is functional/immutable: constructing a graph consists of creating nodes that refer to other nodes, and then compiling the graph into ffmpeg command-line arguments is a pure function that takes a graph (downstream leafnode references) and produces a set of strings.
Useful background info might be to look at simple compiler/AST examples on the web to understand some of the compilation concepts.
Does this explanation help?
(At some point this info/explanation should probably be copied into some actual docs somewhere, so feedback on the above explanation is helpful)
If you want to implement your own function to apply the fade filter to an input you can do it like this:
But maybe I misunderstand and you really want to add your own filter operators, in which case I would suggest your just look at other implemented filters in the filter module, for example: https://github.com/kkroening/ffmpeg-python/blob/master/ffmpeg/_filters.py#L216