[Libav-user] Changing video filter parameter at runtime

Gabriele Greco gabriele.greco at wyscout.com
Wed Feb 8 15:22:11 EET 2017


Hello everybody,

I've setup a filter chain in my program to deinterlace and scale the video
frame before rendering, it works very well, and the code is faster that the
custom deinterlace/scale that I used before, the problem I have is that I
need to change the filter when the window is resized, here is the filter,
as dumped by avfilter_graph_dump:

+----------+
|    in    |default--[720x576 64:45 yuv420p]--Parsed_yadif_0:default
| (buffer) |
+----------+

                                                   +--------------+
Parsed_scale_1:default--[800x450 1:1 argb]--default|     out      |
                                                   | (buffersink) |
                                                   +--------------+

                                            +----------------+
in:default--[720x576 64:45 yuv420p]--default| Parsed_yadif_0
|default--[720x576 64:45 yuv420p]--Parsed_scale_1:default
                                            |    (yadif)     |
                                            +----------------+

                                                        +----------------+
Parsed_yadif_0:default--[720x576 64:45 yuv420p]--default| Parsed_scale_1
|default--[800x450 1:1 argb]--out:default
                                                        |    (scale)     |
                                                        +----------------+


When a resize event occurs I'm trying to change it in this way:

    if (AVFilterContext *ctx = avfilter_graph_get_filter(filter_graph_,
"Parsed_scale_1")) {
        std::ostringstream os;
        os << "w=" << img_.Width() << ":h=" << img_.Height() << ":eval";
        // passes w=XXX:h=YYY:eval to the filter
        if (avfilter_init_str(ctx, os.str().c_str()) < 0) {
            ELOG << "Unable to reinit filter!";
        }
         }
    else
        ELOG << "Unable to find filter!";

... no error is reported but the filter is not changed after the call...

Note that I added to the filter the "eval" option since I read in the
filter documentation that otherwise the size is evaluated only for the
first frame...

I've tried to read through the avfilter documentation but I cannot find a
specific function to do that, I hope that the only way to do that is not to
delete all the filtergraph and rebuild it, I can do it if needed but I've a
few concerns about the AVFilterInOut inputs/outputs, if they need to be
freed or not, avfilter_graph_parse_ptr says it should not be freed by user,
avfilter_graph_parse says it should...

Thanks in advance!

-- 
*Bye,*
*Gabriele Greco*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20170208/a42a222f/attachment.html>


More information about the Libav-user mailing list