From patchwork Thu Apr 6 08:44:51 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas George X-Patchwork-Id: 3314 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.44.195 with SMTP id s186csp555545vss; Thu, 6 Apr 2017 01:45:32 -0700 (PDT) X-Received: by 10.28.166.208 with SMTP id p199mr22879053wme.25.1491468332675; Thu, 06 Apr 2017 01:45:32 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id u7si1555112wrb.292.2017.04.06.01.45.32; Thu, 06 Apr 2017 01:45:32 -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 D2746688369; Thu, 6 Apr 2017 11:45:02 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from nef2.ens.fr (nef2.ens.fr [129.199.96.40]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 9F8A1688355 for ; Thu, 6 Apr 2017 11:44:54 +0300 (EEST) Received: from phare.normalesup.org (archicubes.ens.fr [129.199.129.80]) by nef2.ens.fr (8.13.6/1.01.28121999) with ESMTP id v368ivFu047378 for ; Thu, 6 Apr 2017 10:44:57 +0200 (CEST) Received: by phare.normalesup.org (Postfix, from userid 1001) id 01A60E8C4D; Thu, 6 Apr 2017 10:44:56 +0200 (CEST) From: Nicolas George To: ffmpeg-devel@ffmpeg.org Date: Thu, 6 Apr 2017 10:44:51 +0200 Message-Id: <20170406084451.27892-4-george@nsup.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170406084451.27892-1-george@nsup.org> References: <20170406084451.27892-1-george@nsup.org> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.4.3 (nef2.ens.fr [129.199.96.32]); Thu, 06 Apr 2017 10:44:57 +0200 (CEST) Subject: [FFmpeg-devel] [PATCH 4/4] ffmpeg: send EOF pts to filters. 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: Nicolas George --- ffmpeg.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) With this change, filters have a timestamp when EOF is reached, available in link->current_pts. For example, vf_fps could make use of it to fix the duration of the last frame; the logic in vf_fps seems unnecessarily complicated, I have not yet implemented this, but a quick fix could be possible. diff --git a/ffmpeg.c b/ffmpeg.c index 41f1f076ca..45d477dcf4 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -2212,14 +2212,14 @@ static int ifilter_send_frame(InputFilter *ifilter, AVFrame *frame) return 0; } -static int ifilter_send_eof(InputFilter *ifilter) +static int ifilter_send_eof(InputFilter *ifilter, int64_t pts) { int i, j, ret; ifilter->eof = 1; if (ifilter->filter) { - ret = av_buffersrc_add_frame_flags(ifilter->filter, NULL, AV_BUFFERSRC_FLAG_PUSH); + ret = av_buffersrc_close(ifilter->filter, pts, AV_BUFFERSRC_FLAG_PUSH); if (ret < 0) return ret; } else { @@ -2570,8 +2570,12 @@ out: static int send_filter_eof(InputStream *ist) { int i, ret; + /* TODO keep pts also in stream time base to avoid converting back */ + int64_t pts = av_rescale_q_rnd(ist->pts, AV_TIME_BASE_Q, ist->st->time_base, + AV_ROUND_NEAR_INF | AV_ROUND_PASS_MINMAX); + for (i = 0; i < ist->nb_filters; i++) { - ret = ifilter_send_eof(ist->filters[i]); + ret = ifilter_send_eof(ist->filters[i], pts); if (ret < 0) return ret; }