[Libav-user] Libavfilter - Dynamic filtergraph reconfiguration

ilkercan Kaya canilkerkaya at gmail.com
Fri Feb 5 23:26:04 EET 2021


>
> There are two APIs to set options,

Is the other one through a dictionary? I tried to find it through examples
but that's all I got.

Could you tell me the other API so I can try to set the enable flag through
there.

On Fri, Feb 5, 2021 at 3:25 PM Paul B Mahol <onemda at gmail.com> wrote:

>
>
> On Fri, Feb 5, 2021 at 2:49 AM ilkercan Kaya <canilkerkaya at gmail.com>
> wrote:
>
>> enable option is also command for every filter that supports timeline.
>>> Yes it looks like not documented explicitly.
>>
>> Does this mean that I can set "enable" as an option? if so I tried to do
>> the following before initializing the filter:
>>
>> if ((res = av_opt_set_int(ctx, "enable", 1, AV_OPT_SEARCH_CHILDREN)) == 0) {
>>     isOn = true;
>> } else {
>>     isFxBroken = true;
>>     LOGE("AvFX::activateFilter failed! %s %s", name,
>>          av_err2str(res));
>> }
>>
>> But the call always landed on else with " AvFX::activateFilter failed!
>> agate Invalid argument"
>> Than I tried the following:
>>
>> if ((res = av_opt_set(ctx, "enable", "1", AV_OPT_SEARCH_CHILDREN)) == 0) {
>>     isOn = true;
>> } else {
>>     isFxBroken = true;
>>     LOGE("AvFX::activateFilter failed! %s %s", name,
>>          av_err2str(res));
>> }
>>
>> This time it did not land on else but this just makes it crash the app
>> when data is passed through the filtergraph with "null pointer deference on
>> libavfilter.so"
>>
>> How may I set this enable option through the code?
>>
>
> There is nothing wrong with your code. It is just bug in libavfilter, I
> posted patch to fix it on devel mailing list.
>
> There are two APIs to set options, one of them is not much tested and thus
> it got broken.
>
>
>>
>> On Tue, Feb 2, 2021 at 12:52 AM Paul B Mahol <onemda at gmail.com> wrote:
>>
>>>
>>>
>>> On Mon, Feb 1, 2021 at 10:33 PM ilkercan Kaya <canilkerkaya at gmail.com>
>>> wrote:
>>>
>>>> A simpler solution, if you only need to implement enabling and disabling
>>>>> some of the filters, you can expect the "timeline" support does the
>>>>> trick:
>>>>
>>>>
>>>> I looked at timeline support, correct me if I am wrong but it is done
>>>> through the *enable_str  *property of *AVFilterContext*. It is
>>>> activated with *avfilter_init_str *call. This seems like setting the *enable_str
>>>> * evaluation can only be done once without reiniting the whole graph.
>>>> If this is the case, is there a way to  pass a custom variable to the
>>>> expression so that I can switch it on or off? The case in the example at
>>>> the documentation, smartblur is hardcoded to be activated between 10
>>>> seconds to 3 minutes, in my case I can not foresee when the filter will be
>>>> turned on/off.
>>>>
>>>
>>> enable option is also command for every filter that supports timeline.
>>> Yes it looks like not documented explicitly.
>>>
>>> Just tried it and works.
>>>
>>> mpv crowd_run_1080p50.y4m -vf "lavfi=[sendcmd=2.0 colorcorrect enable
>>> 0,colorcorrect=saturation=0]"
>>>
>>>
>>>>
>>>> On Mon, Feb 1, 2021 at 11:10 PM Paul B Mahol <onemda at gmail.com> wrote:
>>>>
>>>>> lowpass, highpass and agate on master git version have both timeline
>>>>> and command support.
>>>>>
>>>>> On Mon, Feb 1, 2021 at 7:39 PM ilkercan Kaya <canilkerkaya at gmail.com>
>>>>> wrote:
>>>>>
>>>>>> Hi Everyone,
>>>>>>
>>>>>> I am making a mobile music app where the user can add multiple
>>>>>> different FXS at runtime to current playing music through a two dimensional
>>>>>> pad with an effects header. I am using FFmpeg, libavfilter in C++ to add
>>>>>> multiple FX to the audio.
>>>>>>
>>>>>> My problem is, the user can disable any of the FX's I am using at any
>>>>>> time as they wish, the effects I use are agate, lowpass, highpass. The
>>>>>> graph is:
>>>>>>
>>>>>> abuffer -> lowpass -> highpass -> agate -> aformat -> abuffersink.
>>>>>>
>>>>>> From time to time, I want to disable some of the following  lowpass,
>>>>>> highpass, agate. So I thought I could just reconfigure the graph and
>>>>>> basically get rid of links to fulfil my wish. I am not sure this is the
>>>>>> right way to do it tho. I tried to dig online but all I could find was a
>>>>>> thread from 2012 with no conclusion. Libavfilter documentation doesn't say
>>>>>> anything about reconfigure or reset existing filtergraph (of that I could
>>>>>> find).
>>>>>>
>>>>>> What would be the best way to do this?
>>>>>>
>>>>>> Thank you!
>>>>>> _______________________________________________
>>>>>> Libav-user mailing list
>>>>>> Libav-user at ffmpeg.org
>>>>>> https://ffmpeg.org/mailman/listinfo/libav-user
>>>>>>
>>>>>> To unsubscribe, visit link above, or email
>>>>>> libav-user-request at ffmpeg.org with subject "unsubscribe".
>>>>>
>>>>> _______________________________________________
>>>>> Libav-user mailing list
>>>>> Libav-user at ffmpeg.org
>>>>> https://ffmpeg.org/mailman/listinfo/libav-user
>>>>>
>>>>> To unsubscribe, visit link above, or email
>>>>> libav-user-request at ffmpeg.org with subject "unsubscribe".
>>>>
>>>> _______________________________________________
>>>> Libav-user mailing list
>>>> Libav-user at ffmpeg.org
>>>> https://ffmpeg.org/mailman/listinfo/libav-user
>>>>
>>>> To unsubscribe, visit link above, or email
>>>> libav-user-request at ffmpeg.org with subject "unsubscribe".
>>>
>>> _______________________________________________
>>> Libav-user mailing list
>>> Libav-user at ffmpeg.org
>>> https://ffmpeg.org/mailman/listinfo/libav-user
>>>
>>> To unsubscribe, visit link above, or email
>>> libav-user-request at ffmpeg.org with subject "unsubscribe".
>>
>> _______________________________________________
>> Libav-user mailing list
>> Libav-user at ffmpeg.org
>> https://ffmpeg.org/mailman/listinfo/libav-user
>>
>> To unsubscribe, visit link above, or email
>> libav-user-request at ffmpeg.org with subject "unsubscribe".
>
> _______________________________________________
> Libav-user mailing list
> Libav-user at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/libav-user
>
> To unsubscribe, visit link above, or email
> libav-user-request at ffmpeg.org with subject "unsubscribe".
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://ffmpeg.org/pipermail/libav-user/attachments/20210206/1bc21b09/attachment.html>


More information about the Libav-user mailing list