[Libav-user] How can AVFilter tell if input is CFR/VFR, and determine frame rate?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[Libav-user] How can AVFilter tell if input is CFR/VFR, and determine frame rate?

Richard Ling
Hello,

How can an AVFilter determine whether its input is VFR or CFR?
If the input is CFR, how can it get the frame rate in FPS?
I would like to do this in advance of processing any frames, that is,
in init() or config_input().
Please see the implementation below:

static int is_vfr(AVFilterLink *inlink)
{
    return ???; // what goes here?
}

static float get_cfr_fps(AVFilterLink *inlink)
{
    return 1.0f / av_q2d(inlink->time_base);  // is this correct??
}

static int config_input(AVFilterLink *inlink)
{
    float fps;

    if (is_vfr(inlink)) {
        av_log(ctx, AV_LOG_ERROR, "This filter does not support VFR video.\n");
        return AVERROR(EINVAL);
    }
    fps = get_cfr_fps(inlink);
    ...
}


Thanks in advance...
R
_______________________________________________
Libav-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/libav-user
Reply | Threaded
Open this post in threaded view
|

Re: How can AVFilter tell if input is CFR/VFR, and determine frame rate?

Carl Eugen Hoyos-2
2017-09-30 1:11 GMT+02:00 Richard Ling <[hidden email]>:
> Hello,
>
> How can an AVFilter determine whether its input is VFR or CFR?

I may misunderstand your question but I don't think this
is possible in general:
Even if all frames so far have constant duration, the next
frame may not.

Carl Eugen
_______________________________________________
Libav-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/libav-user