From patchwork Thu Sep 21 14:55:52 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tobias Rapp X-Patchwork-Id: 5226 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.2.36.26 with SMTP id f26csp2040594jaa; Thu, 21 Sep 2017 07:56:24 -0700 (PDT) X-Google-Smtp-Source: AOwi7QBdd2WJeMYJGV+xw9PU+nfa9ofGMk/0NySp2B3APVmyC6gCnLQ6OpB71TAbej5ugO/GUylf X-Received: by 10.28.98.5 with SMTP id w5mr1005491wmb.51.1506005784269; Thu, 21 Sep 2017 07:56:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1506005784; cv=none; d=google.com; s=arc-20160816; b=Y2Lqqp0si4hVHRmINXERAPRW3Oxa09TtkzZ2UWseeVLy58vFQFuUcoAk8xhuwLJim+ d/4cInaHY54igGgy3KAsYhQ+9Bd7e71pRFqWTLtFlroZ2Vw0NHx5RtlXTAoZDkMI1ykE qnNR6C2oIli8raj83ifWzuTYUgSDnhiZzJrdbSZry/XhGJ06wd70tYXolftCcU+LGRRV 85ek1kaD1iE1HDzHo8FRUAmpi3czMQLh3M4h2sRINSj45sKPHtFkfxArbBf7I4rsTyFg AIXgFK9fRIJCXkgVRf1MLjP/ni5hK+hMaoAF+Z3vFc6aek+TlTvE7PDmwAlHTsVzost4 eMEg== 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=9gxR6eN4OSUgmC+Zrkw1+c1JA+oavGOZx3H76oR+yBg=; b=RTUlGEkWoKvmOnHKQ/OPIKHDZ6Bx5IQurmkNh9AZy7MsgQdLFUJwZ9b4HqGtHD12zF hcS4nU2Fb4C/f9CGQL5a2spp/ZzvE8/GVPXCYFSmSwT0A4Hi4IvFpWWaFmfxv0yVbWLf BeV6NKa9dG+bsOOPzKR83hhrdlrnxk7YivlFg1ffC1SvoSzUuKQwqbgbOeDh6bhF9UKr jMRmOrin8zag5uJHuq48af++lWRdtpRSc8QiO7G2bmZ/Kjp8FlHVNQkKV4kRYsq0P/iK lR2zM6Ffy3cVt2LIiK9eSttSeUM4f4oZsfx8tvT0e6I5MB2p9hSwAPbm7yxTp93JWhrU /uBQ== 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 v10si1257393wrf.453.2017.09.21.07.56.23; Thu, 21 Sep 2017 07:56:24 -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 470686891DF; Thu, 21 Sep 2017 17:56:05 +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 71E356882BA for ; Thu, 21 Sep 2017 17:55:58 +0300 (EEST) Received: from p1002.netstorage.at (p1002.netstorage.at [89.207.146.186]) by mx01.mail.netstorage.at (Postfix) with ESMTPS id E6258A2981 for ; Thu, 21 Sep 2017 16:55:52 +0200 (CEST) Received: from mailix (noaport.de [46.237.252.213]) by p1002.netstorage.at (Postfix) with ESMTPA id 995A08268B for ; Thu, 21 Sep 2017 16:55:52 +0200 (CEST) Received: from frogstar-a.kuhnle.local (frogstar-a.kuhnle.local [192.168.0.26]) by mailix with ESMTPA ; Thu, 21 Sep 2017 16:55:52 +0200 From: Tobias Rapp To: ffmpeg-devel@ffmpeg.org Date: Thu, 21 Sep 2017 16:55:52 +0200 Message-Id: <1506005752-14650-2-git-send-email-t.rapp@noa-archive.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1506005752-14650-1-git-send-email-t.rapp@noa-archive.com> References: <1506005752-14650-1-git-send-email-t.rapp@noa-archive.com> X-PPP-Message-ID: <20170921145552.25332.32270@p1002.netstorage.at> X-PPP-Vhost: noa-archive.com X-NetStorage-MailScanner-Information: Please contact the ISP for more information X-NetStorage-MailScanner-ID: E6258A2981.A3C3C 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 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 96b3dfd..0dc6ba5 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -8695,6 +8695,18 @@ For example, this could be set to 0 to pad the beginning with duplicates of the first frame if a video stream starts after the audio stream or to trim any frames with a negative PTS. +@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 5d6aa5f..0366a66 100644 --- a/libavfilter/version.h +++ b/libavfilter/version.h @@ -31,7 +31,7 @@ #define LIBAVFILTER_VERSION_MAJOR 6 #define LIBAVFILTER_VERSION_MINOR 105 -#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 0db2b48..3fcb584 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[] = { { "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" }, { "start_time", "Assume the first PTS should be this value.", OFFSET(start_time), AV_OPT_TYPE_DOUBLE, { .dbl = DBL_MAX}, -DBL_MAX, DBL_MAX, V|F }, + { "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 */