[Libav-user] Is it possible to dynamically reconfigure a filter graph?

Stefano Sabatini stefasab at gmail.com
Tue Oct 23 22:38:37 CEST 2012


On date Tuesday 2012-10-23 13:03:27 -0600, Michael Bradshaw encoded:
> I'm using avfilter to rescale video (and convert it to the right pixel
> format) and convert audio (to the right sample format, sample rate,
> and channel_layout) (I'm also buffering audio using asetnsamples to
> fill frames with a consistent number of samples). While reading the
> source video and source audio, it's possible they change in the
> stream.

> If the source audio stream changes (i.e. sample rate, sample
> format, channel_layout), or if the source video stream changes (width,
> height, or pixel format), do I have to completely destroy and rebuild
> the filter graph? Or is there a way to "update" the source filters to
> the new formats and update (without destroying) the filter graph?

Some filters do, others won't, so in general the best way is to
"normalize" the input media before injecting it in the filtergraph, a
consistent and robust way to deal with that will require some
(re)design at the framework level.
 
> My primary concern is that asetnsamples may have some samples
> buffered, and destroying and recreating the filter graph would lose
> these buffered samples.
> 

> Also, if it's possible to update the filters without destroying the
> graph and recreating it, would it be possible to change the number of
> samples set for asetnsamples? I'm not seeing anything that makes it
> look like this is possible, but it's worth double checking.

This should be easily feasible by implementing a process_command()
callback in asetnsamples, also have a look at the asendcmd filter,
patches (or alternatively a feature request) are welcome.


More information about the Libav-user mailing list