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

Richard Ling richard.b.ling at gmail.com
Sat Sep 30 02:11:24 EEST 2017


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...

More information about the Libav-user mailing list