[Libav-user] Dynamic_input filters and avfilter_pad_get_type

Paul B Mahol onemda at gmail.com
Wed May 14 14:34:21 EEST 2025


On Wed, May 14, 2025 at 11:25 AM Andrew Randrianasulu <
randrianasulu at gmail.com> wrote:

>
>
> ср, 14 мая 2025 г., 14:10 Paul B Mahol <onemda at gmail.com>:
>
>>
>>
>> On Wed, May 14, 2025 at 11:02 AM Andrew Randrianasulu <
>> randrianasulu at gmail.com> wrote:
>>
>>> On Wed, May 14, 2025 at 10:59 AM Paul B Mahol <onemda at gmail.com> wrote:
>>> >
>>> >
>>> >
>>> > On Wed, May 14, 2025 at 4:27 AM Andrew Randrianasulu <
>>> randrianasulu at gmail.com> wrote:
>>> >>
>>> >> On Sat, May 10, 2025 at 11:14 AM Andrew Randrianasulu
>>> >> <randrianasulu at gmail.com> wrote:
>>> >> >
>>> >> > On Sat, May 10, 2025 at 9:05 AM Paul B Mahol <onemda at gmail.com>
>>> wrote:
>>> >> > >
>>> >> > >
>>> >> > >
>>> >> > > On Fri, May 9, 2025 at 11:38 PM Andrew Randrianasulu <
>>> randrianasulu at gmail.com> wrote:
>>> >> > >>
>>> >> > >> I was looking at why our application (cinelerra-gg) crashed at
>>> trying to use libplacebo
>>> >> > >>
>>> >> > >> I found that libplacebo defines itself
>>> >> > >>
>>> >> > >> https://ffmpeg.org/doxygen/7.0/vf__libplacebo_8c.html
>>> >> > >>
>>> >> > >> as
>>> >> > >>
>>> >> > >>  .flags = AVFILTER_FLAG_HWDEVICE | AVFILTER_FLAG_DYNAMIC_INPUTS,
>>> >> > >>
>>> >> > >> so only output pad is defined, as far as I can see:
>>> >> > >>
>>> >> > >> static const AVFilterPad libplacebo_outputs[] = {
>>> >> > >>   {
>>> >> > >>   .name = "default",
>>> >> > >>   .type = AVMEDIA_TYPE_VIDEO,
>>> >> > >>   .config_props = &libplacebo_config_output,
>>> >> > >>   },
>>> >> > >>  };
>>> >> > >>
>>> >> > >>
>>> >> > >>
>>> >> > >> then when our code calls
>>> >> > >>
>>> >> > >> avfilter_pad_get_type()
>>> >> > >
>>> >> > >
>>> >> > > You need to call it only after filtergraph have been configured,
>>> not before because in such cases number of output pads may be 0 before
>>> configuration.
>>> >> > > In  any case you need to check current number of input pads and
>>> output pads for each filter before trying to access them.
>>> >> > >
>>> >> >
>>> >> > Thanks. Attached patch  makes this crash go away, just 32-bit cingg
>>> >> > can't cope with 4k frames filtering en-masse :)
>>> >>
>>> >> Sadly wtch ffmpeg.git patch does not work anymore.
>>> >>
>>> >> I tried to use
>>> >>
>>> >> int       nb_pads = avfilter_filter_pad_count(filter,0);
>>> >
>>> >
>>> > input pads != output pads
>>>
>>>
>>> well, sure, but I thought after you create filtergraph filters inside
>>> it will know, um, their ins and outs ?
>>>
>>
>> Yes, it should.
>>
>> Dunno about your project code quality and coding practices so can not
>> help more.
>> Make sure that you test with valgrind and/or address sanitizers turned on
>> when developing your software.
>>
>
> I think here is more logical error - may be we send null if filter name
> unknown for current  libav* build ....
>
> and avfilter_filter_pad_count dislikes this very much and crash? So
> backtrace points at it, but it basically innocent, while may be additional
> check for this bad input will not hurt?
>

avfilter_filter_pad_count takes only const filter, which means not context
that get later created.

After filter context have been created you just loop over
filter_ctx->inputs[] and filter_ctx->outputs[] arrays.

>
>
>
>>
>>>
>>> >
>>> >>
>>> >>
>>> >> but this one apparently crashes when I try zscale :(
>>> >>
>>> >> while may be zscale was just not compiled in?
>>> >>
>>> >> I'll retry with some more env. options.
>>> >>
>>> >> On the plus side ffmpeg.git + radv + h264 video = it mostly works.
>>> >> Some vids still crash us ...
>>> >>
>>> >>
>>> >> >
>>> >> > Andrea, can you test attached patch +  this opts file put alongside
>>> >> > test 4k HDR video  decodable by hardware?
>>> >> >
>>> >> >
>>> >> >
>>> >> > >
>>> >> > >>
>>> >> > >>
>>> >> > >> it promptly crashes.
>>> >> > >>
>>> >> > >>  BC_Signals::dump_stack
>>> >> > >> cin() [0x8b2c9e2]
>>> >> > >> linux-gate.so.1(__kernel_rt_sigreturn+0) [0xf7fb8590]
>>> >> > >> cin(avfilter_pad_get_type+0x14) [0x99266a4]
>>> >> > >> cin(_ZN13FFVideoStream13create_filterEPKc+0xbc) [0x865669c]
>>> >> > >> cin(_ZN6FFMPEG12open_decoderEv+0x80f) [0x865732f]
>>> >> > >> cin(_ZN10FileFFMPEG9check_sigEP5Asset+0x81) [0x8670071]
>>> >> > >> cin(_ZN4File5probeEv+0x376) [0x867cd86]
>>> >> > >> cin(_ZN4File9open_fileEP11PreferencesP5Assetii+0x378) [0x867d628]
>>> >> > >> cin(_ZN7MWindow14load_filenamesEP9ArrayListIPcEiii+0x250)
>>> [0x87301f0]
>>> >> > >> cin(_ZN17CommandLineThread3runEv+0x53) [0x86e2cd3]
>>> >> > >> cin(_ZN6Thread10entrypointEPv+0x41) [0x8b70c11]
>>> >> > >> /lib/libpthread.so.0(+0x7328) [0xf7df9328]
>>> >> > >> /lib/libc.so.6(clone+0x66) [0xf0373f06]
>>> >> > >>
>>> >> > >>
>>> >> > >>
>>> >> > >> We still hope to get libplacebo's tonemapping  + vulkan hevc
>>> decoding going, so any pointers how to talk to those dynamic_input filters
>>> will be useful. Even swscale is dynamic_input in ffmpeg 7.1+, so I (we)
>>> really hope to keep it working, too.
>>> >> > >>
>>> >> > >> Code:
>>> >> > >>
>>> >> > >>
>>> https://git.cinelerra-gg.org/git/?p=goodguy/cinelerra.git;a=blob;f=cinelerra-5.1/cinelerra/ffmpeg.C;h=1d0979df59f932628246678a920aca002d8dd88b;hb=HEAD#l3893
>>> >> > >>
>>> >> > >>
>>> >> > >>
>>> >> > >> _______________________________________________
>>> >> > >> 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".
>>
> _______________________________________________
> 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/20250514/9d724159/attachment.htm>


More information about the Libav-user mailing list