From patchwork Mon Sep 25 11:31:19 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tobias Rapp X-Patchwork-Id: 5259 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.2.36.26 with SMTP id f26csp2511942jaa; Mon, 25 Sep 2017 04:31:41 -0700 (PDT) X-Google-Smtp-Source: AOwi7QCw9pXn78L+vxM3o3ZVvUVnLx46sjkZgblRod6rlN3yOnlb4BecEitmg9nUlZoc9xSDcIil X-Received: by 10.28.211.66 with SMTP id k63mr17834wmg.33.1506339101387; Mon, 25 Sep 2017 04:31:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1506339101; cv=none; d=google.com; s=arc-20160816; b=Jf6B1QtnDvuzpVwbgi2akM6IwYUttebTUBGrOkH8OJWnynEouzlZIgskXMy4EXMODA PzQOz6U1KIaF3xD6vJmAiqEX91GbMROoaqfx8xT28MRpjHJCfdOE4eUt8aTiQ0rU+hKD rxzqJs9mZnDFEo3c2rFmQApYvOwnNAWrTgk8xz9dyVNiw3Q5+KAPwkKMRnz0NRre8eFS qSIxCp+doH4ZjIwNF8xfG5kEaTmKAjQWxTgBPeGGM+y6XfjNHv+lb9VpJAGPFojK8pow A5MZTNUGiXv7AHB25mRd5ZHGDugckRhFgmweU3gB+bOk2M55+KVOLty0FETkzsA+8CB/ j4rQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:delivered-to:arc-authentication-results; bh=VqQhwGvjvVD5PVFegFtEjJwKfcaHEc4AN6c43FdDwbc=; b=Pdub4j5AmGBsfzYVltpjWUTUDzhEa7DUBigxo4u1W2CJH/LC33gIgCgQmt8Ivqx76P BTB2NVFVI4X7RrovdaYryYVw2hIwLdB3CJWMV+WAcwwJl3q2i16awaSajgAIVcTAfp3D ODEqmHEx7P27lLFp45bJLkzk+BJxDO64N7+Eo9hXNANN29yxZ6CLsKHTm/+RKmTeACZL N19sCiPLijV74OPF1kmSTggkCH+oynLhc5T+ed205o2WNi43sk0b0sQR5yBO+vLfA9vj nIGEFqJTnYXKXmFEj43g+3R9yDPMFgmLwbP8Mt6v1yoV9Qm9uml4ixiwWKujtAPcGm1E d+bA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id e127si4528606wme.238.2017.09.25.04.31.40; Mon, 25 Sep 2017 04:31:41 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 08F55688366; Mon, 25 Sep 2017 14:31:28 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mx01.mail.netstorage.at (mx01.mail.netstorage.at [89.207.144.13]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 44B4168062C for ; Mon, 25 Sep 2017 14:31:22 +0300 (EEST) Received: from p1002.netstorage.at (p1002.netstorage.at [89.207.146.186]) by mx01.mail.netstorage.at (Postfix) with ESMTPS id 28015A074C for ; Mon, 25 Sep 2017 13:31:20 +0200 (CEST) Received: from mailix (noaport.de [46.237.252.213]) by p1002.netstorage.at (Postfix) with ESMTPA id C280181616 for ; Mon, 25 Sep 2017 13:31:19 +0200 (CEST) Received: from frogstar-a.kuhnle.local (frogstar-a.kuhnle.local [192.168.0.26]) by mailix with ESMTPA ; Mon, 25 Sep 2017 13:31:19 +0200 From: Tobias Rapp To: ffmpeg-devel@ffmpeg.org Date: Mon, 25 Sep 2017 13:31:19 +0200 Message-Id: <1506339079-14869-2-git-send-email-t.rapp@noa-archive.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1506339079-14869-1-git-send-email-t.rapp@noa-archive.com> References: <1506005752-14650-1-git-send-email-t.rapp@noa-archive.com> <1506339079-14869-1-git-send-email-t.rapp@noa-archive.com> X-PPP-Message-ID: <20170925113120.19416.73482@p1002.netstorage.at> X-PPP-Vhost: noa-archive.com X-NetStorage-MailScanner-Information: Please contact the ISP for more information X-NetStorage-MailScanner-ID: 28015A074C.A2AB7 X-NetStorage-MailScanner: Found to be clean X-NetStorage-MailScanner-SpamCheck: not spam (whitelisted), SpamAssassin (nicht zwischen gespeichert, Wertung=-0.5, benoetigt 6, autolearn=not spam, BAYES_00 -0.50) X-NetStorage-MailScanner-From: t.rapp@noa-archive.com X-Spam-Status: No Subject: [FFmpeg-devel] [PATCH v2 2/2] avfilter/vf_fps: add eof_action filter option 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" Allows to specify the action to be performed when reading the last frame from the internal FIFO buffer. By default the last frame is written to filter output depending on the timestamp rounding method. When using "pass" action the last frame is passed through if input duration has not been reached yet. Examples using an input file with 25Hz, 1.4sec duration: - "fps=fps=1:round=near" generates an output file of 1sec - "fps=fps=1:round=near:eof_action=pass" generates an output file of 2sec Signed-off-by: Tobias Rapp --- doc/filters.texi | 12 ++++++++++++ libavfilter/version.h | 2 +- libavfilter/vf_fps.c | 14 +++++++++++++- 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/doc/filters.texi b/doc/filters.texi index a46865f..1b48793 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -8695,6 +8695,18 @@ round to nearest @end table The default is @code{near}. +@item eof_action +Action performed when reading the last frame. + +Possible values are: +@table @option +@item round +Use same timestamp rounding method as used for other frames. +@item pass +Pass through last frame if input duration has not been reached yet. +@end table +The default is @code{round}. + @end table Alternatively, the options can be specified as a flat string: diff --git a/libavfilter/version.h b/libavfilter/version.h index fb382d4..8191c59 100644 --- a/libavfilter/version.h +++ b/libavfilter/version.h @@ -31,7 +31,7 @@ #define LIBAVFILTER_VERSION_MAJOR 6 #define LIBAVFILTER_VERSION_MINOR 106 -#define LIBAVFILTER_VERSION_MICRO 100 +#define LIBAVFILTER_VERSION_MICRO 101 #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \ LIBAVFILTER_VERSION_MINOR, \ diff --git a/libavfilter/vf_fps.c b/libavfilter/vf_fps.c index a5e51c3..dbafd2c 100644 --- a/libavfilter/vf_fps.c +++ b/libavfilter/vf_fps.c @@ -40,6 +40,12 @@ #include "internal.h" #include "video.h" +enum EOFAction { + EOF_ACTION_ROUND, + EOF_ACTION_PASS, + EOF_ACTION_NB +}; + typedef struct FPSContext { const AVClass *class; @@ -52,6 +58,7 @@ typedef struct FPSContext { AVRational framerate; ///< target framerate int rounding; ///< AVRounding method for timestamps + int eof_action; ///< action performed for last frame in FIFO /* statistics */ int frames_in; ///< number of frames on input @@ -72,6 +79,9 @@ static const AVOption fps_options[] = { { "down", "round towards -infty", 0, AV_OPT_TYPE_CONST, { .i64 = AV_ROUND_DOWN }, 0, 0, V|F, "round" }, { "up", "round towards +infty", 0, AV_OPT_TYPE_CONST, { .i64 = AV_ROUND_UP }, 0, 0, V|F, "round" }, { "near", "round to nearest", 0, AV_OPT_TYPE_CONST, { .i64 = AV_ROUND_NEAR_INF }, 0, 0, V|F, "round" }, + { "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" }, { NULL } }; @@ -151,9 +161,11 @@ static int request_frame(AVFilterLink *outlink) /* This is the last frame, we may have to duplicate it to match * the last frame duration */ int j; + int eof_rounding = (s->eof_action == EOF_ACTION_PASS) ? AV_ROUND_UP : s->rounding; int delta = av_rescale_q_rnd(ctx->inputs[0]->current_pts - s->first_pts, ctx->inputs[0]->time_base, - outlink->time_base, s->rounding) - s->frames_out ; + outlink->time_base, eof_rounding) - s->frames_out; + av_log(ctx, AV_LOG_DEBUG, "EOF frames_out:%d delta:%d\n", s->frames_out, delta); /* if the delta is equal to 1, it means we just need to output * the last frame. Greater than 1 means we will need duplicate * delta-1 frames */