From patchwork Tue Oct 29 17:00:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul B Mahol X-Patchwork-Id: 16016 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 54C78449295 for ; Tue, 29 Oct 2019 19:01:14 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 2E71168B0E8; Tue, 29 Oct 2019 19:01:14 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm1-f50.google.com (mail-wm1-f50.google.com [209.85.128.50]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 2E06C68B067 for ; Tue, 29 Oct 2019 19:01:08 +0200 (EET) Received: by mail-wm1-f50.google.com with SMTP id q70so3424310wme.1 for ; Tue, 29 Oct 2019 10:01:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id; bh=xj5OUCl6DRVHEI2UO+Ggfd7/OqYmha18zpAQl1Fo4Hg=; b=qAm/rYbS8vZG1wb0NX+cLB0CzOj1AynQg1m6bWglLSeJUm2Gxzi0cN474ZDCSPiVbA CTzl2drZvWE+WsY5qWyV4xZtkDXDE2ONljA7aaDNKq+PGz5c/kWzPKgHsl6tHYs/MN50 NiCg5c0YEKn83fi1E1295JcVZihL2/ex33sjlKTUNtPCytnnAi78dwVTvUmR/3DnvFrx aBA4q5TWJUJh+MrWhuLzVxW2gvJoNW6iPJHA2rSek648H54tvd9tntEb6mh+1swToko9 oUMLUbn5rgT0XKddfqNYhqSmdT1wFwL/aqp0nu6bZX3ysRpdK8eVxdtxSzPAJsPEJzhC EBDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id; bh=xj5OUCl6DRVHEI2UO+Ggfd7/OqYmha18zpAQl1Fo4Hg=; b=nxnzn3dN2A4YSF52CLGP9WBQLfYCf47TD1jsa+oNT9TTNmvryB3e9WKraWSLCWoDZt CI+A18wK6q0RXIDgkNP/XZTtm6LmCt9nhxlCU2rISA+Es27xe52V2d7fM8Ds9nYY9Q3m MgqbyaJRujHiUBCkfVezpWrG9YAXnS3yg0d/CPlmmWhVCC+XXMTuGbLauvYJ1w8P+3gs lYWJgffVg29U5cBvlufFmbmPlfQY6yFx77h3zCkMxXdOW+RcQ48mZtU1Ps9UTsy4okgk pVCgurc16DjzIuwumY0x9WkYCQTL227G1qtYncewdpChA/t4K7iNX5sVI42kQ6VWhZ4g Myfw== X-Gm-Message-State: APjAAAUj9wpVRJ4dM+e4WjPKtAyYEZYgP6zRMWAWkXg1nEsz3Zj5dXho tdmeA4HZY7F+a9MlMhjsxSE7Q5HtaL4= X-Google-Smtp-Source: APXvYqybMQXv14+VOv4lMJLuUk+utfsOioa7NgexqPq0ZcV2EfirHNd9KNOgiGYCmRsDYWWXxfyL/g== X-Received: by 2002:a7b:cf06:: with SMTP id l6mr5397793wmg.44.1572368465866; Tue, 29 Oct 2019 10:01:05 -0700 (PDT) Received: from localhost.localdomain ([212.15.160.218]) by smtp.gmail.com with ESMTPSA id u21sm3070140wmj.22.2019.10.29.10.01.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Oct 2019 10:01:04 -0700 (PDT) From: Paul B Mahol To: ffmpeg-devel@ffmpeg.org Date: Tue, 29 Oct 2019 18:00:55 +0100 Message-Id: <20191029170057.6116-1-onemda@gmail.com> X-Mailer: git-send-email 2.17.1 Subject: [FFmpeg-devel] [PATCH 1/3] avfilter/vf_fps: add way to get CFR output without knowing input frame rate X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Signed-off-by: Paul B Mahol --- doc/filters.texi | 3 +++ libavfilter/vf_fps.c | 10 +++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/doc/filters.texi b/doc/filters.texi index 11f715319a..1e815bf940 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -10737,6 +10737,9 @@ Pass through last frame if input duration has not been reached yet. @end table The default is @code{round}. +@item input +Pick output frame rate from input if it is available. The default is disabled. +Useful to change input to constant frame rate without needing to know input frame rate. @end table Alternatively, the options can be specified as a flat string: diff --git a/libavfilter/vf_fps.c b/libavfilter/vf_fps.c index cf1e36726a..7c9762864b 100644 --- a/libavfilter/vf_fps.c +++ b/libavfilter/vf_fps.c @@ -70,6 +70,7 @@ typedef struct FPSContext { int frames_out; ///< number of frames on output int dup; ///< number of frames duplicated int drop; ///< number of framed dropped + int input; ///< should filter use input framerate if one is set } FPSContext; #define OFFSET(x) offsetof(FPSContext, x) @@ -87,6 +88,7 @@ static const AVOption fps_options[] = { { "eof_action", "action performed for last frame", OFFSET(eof_action), AV_OPT_TYPE_INT, { .i64 = EOF_ACTION_ROUND }, 0, EOF_ACTION_NB-1, V|F, "eof_action" }, { "round", "round similar to other frames", 0, AV_OPT_TYPE_CONST, { .i64 = EOF_ACTION_ROUND }, 0, 0, V|F, "eof_action" }, { "pass", "pass through last frame", 0, AV_OPT_TYPE_CONST, { .i64 = EOF_ACTION_PASS }, 0, 0, V|F, "eof_action" }, + { "input", "use input framerate if available", OFFSET(input), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, V|F }, { NULL } }; @@ -99,7 +101,6 @@ static av_cold int init(AVFilterContext *ctx) s->status_pts = AV_NOPTS_VALUE; s->next_pts = AV_NOPTS_VALUE; - av_log(ctx, AV_LOG_VERBOSE, "fps=%d/%d\n", s->framerate.num, s->framerate.den); return 0; } @@ -153,8 +154,15 @@ static int config_props(AVFilterLink* outlink) AVFilterLink *inlink = ctx->inputs[0]; FPSContext *s = ctx->priv; + if (s->input && inlink->frame_rate.num > 0 && inlink->frame_rate.den > 0) { + outlink->time_base = av_inv_q(inlink->frame_rate); + outlink->frame_rate = inlink->frame_rate; + } else { outlink->time_base = av_inv_q(s->framerate); outlink->frame_rate = s->framerate; + } + + av_log(ctx, AV_LOG_VERBOSE, "fps=%d/%d\n", outlink->frame_rate.num, outlink->frame_rate.den); /* Calculate the input and output pts offsets for start_time */ if (s->start_time != DBL_MAX && s->start_time != AV_NOPTS_VALUE) {