From patchwork Tue Oct 29 13:47:43 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: 16012 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 055F6449759 for ; Tue, 29 Oct 2019 15:48:01 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id CC3D868B09D; Tue, 29 Oct 2019 15:48:00 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f47.google.com (mail-wr1-f47.google.com [209.85.221.47]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 8D2C468B068 for ; Tue, 29 Oct 2019 15:47:54 +0200 (EET) Received: by mail-wr1-f47.google.com with SMTP id o28so13724818wro.7 for ; Tue, 29 Oct 2019 06:47:54 -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=A5q8SxV6oaqeM79QIyOeeNk2SwNgpWRJT9K2XIWRww0=; b=WvL4sLzJ3iUOnhvyohTnwsH9PaiixN68DYTznf3mJEVLSw1gWyBQ9swx8SgWe7lnTw ptJWeEBmZUTT5SDoO2uoSRj0rUZzzKXs7ZkHJ4clGLmJAz9/sdF8amWgMEfsC0akH3EZ n4NgaXcsR/qOcFAj8OmUjyPieqeBi3P6+GlHwbRg+Vod0xC3JgRDkbYkNP3t6RHmO32Z 9BZ0uFOhHIBuHJnCsrHk/j//OVkWwi4x9p4YKTJIHkAkcbivGyPH1gvQf2jtgPUARPiE 3VmYc/0GNyxD9ramsaDDJfdDNliy9EkdhuzjBYMt9bEzx/LUae/sSFzFbaMNxcikMIbk PO7Q== 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=A5q8SxV6oaqeM79QIyOeeNk2SwNgpWRJT9K2XIWRww0=; b=cDkEFNRSsgXm/AS9QJf5/ucJHsef0YwHe3epfL5PFH0YfxJtbea1EmCF60XmihFrys /UfR+S1KAdV/+iXGCnT5yKAOXbYVUHF36/zWKzOYgOcpkz3ss/4swM/T96B62EIUotdz UHBAeLbM72sKIpgbBFA7JNOdFqEn8EE40YkWHUGYbR/RBeTcTAn7EgjBX41MatxxJrTh 4nBzMNQhclry8QbPTgil75IuzJMUALZ/CYMJL5U2PQc3P0Fbp8AoElsuTSK0iR+Zq3sv KJ7ZfjR7HfSvGS3Rj4dLpOUbmQq0yMEdcbtuCt6lTZilBWFTdy1HGebYVauC6PJU9299 LQAQ== X-Gm-Message-State: APjAAAXU0FsSNDDm6UL7Jft3UGTQ+/ev9gj0iLc+dEsk17MyVbLxR4tC Xt4TGPkKE63BpgdqtBh3uhDw/WhYMnE= X-Google-Smtp-Source: APXvYqx0YF828ceELZOalWO3SMLFBoNHlhJyrepY7RRmT4uSpPHVxJD4uXrOkiUP1erRtgqAcmOXNQ== X-Received: by 2002:adf:f7c6:: with SMTP id a6mr19706032wrq.272.1572356873772; Tue, 29 Oct 2019 06:47:53 -0700 (PDT) Received: from localhost.localdomain ([212.15.160.218]) by smtp.gmail.com with ESMTPSA id 12sm3302639wmk.13.2019.10.29.06.47.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Oct 2019 06:47:53 -0700 (PDT) From: Paul B Mahol To: ffmpeg-devel@ffmpeg.org Date: Tue, 29 Oct 2019 14:47:43 +0100 Message-Id: <20191029134744.470-1-onemda@gmail.com> X-Mailer: git-send-email 2.17.1 Subject: [FFmpeg-devel] [PATCH 1/2] 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..3561332f0e 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 is available", OFFSET(input), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, V|F }, { NULL } }; @@ -99,7 +101,8 @@ 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); + if (!s->input) + av_log(ctx, AV_LOG_VERBOSE, "fps=%d/%d\n", s->framerate.num, s->framerate.den); return 0; } @@ -153,8 +156,13 @@ 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; + } /* Calculate the input and output pts offsets for start_time */ if (s->start_time != DBL_MAX && s->start_time != AV_NOPTS_VALUE) {