From patchwork Thu Apr 26 05:03:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Dixit, Vishwanath" X-Patchwork-Id: 8652 Delivered-To: ffmpegpatchwork@gmail.com Received: by 2002:a02:155:0:0:0:0:0 with SMTP id c82-v6csp1506121jad; Wed, 25 Apr 2018 22:04:20 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+aHJCA5yrkPFWq1pc9kiZSSqMtK2Jn+IyECtVbk36bQ8HlTdWvNqBipb5Aq9Z92YJQkiyT X-Received: by 10.28.1.1 with SMTP id 1mr16901228wmb.28.1524719060571; Wed, 25 Apr 2018 22:04:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524719060; cv=none; d=google.com; s=arc-20160816; b=DqYalTaLCfB9WhxzCnDfzc+wogGBUKjRHvi281UV0r3mWpcyTBpT6T4pGK/MZuZy7z rlqoa6F/K5vnzk0qK/fn9WNVTtUlokaZrqydZWLbCex7g99bowfR8ZlK4iy/rqRrYT6I G6tvUUn0DLiwHrNV7mzHnDA3rU899s14d/9Vdh/3YSV02M1rTT8PmNQ7ZYtRmdk9MFIV CXCUKD1UuKzOpBpccouFT1IKClyA5Thrwxha6RTkx5l3Dv7cL/BWjXa8vO7Zg8U3ofmP Jgeoo/VM1CZo7QgjihrFlH8YRu3vLrmrwZHaUHiw2e18PMjXFxSrJzQ2yzQcr+WrnhRS 5F6Q== 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:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:feedback-id:message-id:date:to:from :dkim-signature:delivered-to:arc-authentication-results; bh=/WO6tF4hmDE3fGWswydLfRnJ7/kwxZTZC/fqf3YSYKU=; b=ZjCI3lzq4Rm7xXFAUB2scroKN5jjBw+bvNHgDVYsBxa3XbrhorkmwS7a110holMvXE jHZFwJsDaAcK+T8VUTf/5r7SukSHvlnjBtwqdr/0gmYZO1T/O99kO2e4+PSH+MMMfzWL wLAidHqam+fLxgej0cEzNCZ87/agFLUnTQ86aCmZguAjcTL1b9jhyUVN3NDhcFejE1F0 fkPwfRQy55gf563MFz5Vxjg4A7VwxNwWxJQ4eGe84wy4vnWeIkuJ4VIzTq2MrFmLi0AA e9EfirK77EqPjxIr6bKcmVb9xFrObB4sik2CyIspYBpM2M8I9zf5Ybe6GE2AzB/t+NaV tSww== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@smtpservice.net header.s=m78bu0.a1-4.dyn header.b=lOtr9f6a; 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; dmarc=fail (p=QUARANTINE sp=NONE dis=NONE) header.from=akamai.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id p138si4122351wmb.144.2018.04.25.22.04.19; Wed, 25 Apr 2018 22:04:20 -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; dkim=neutral (body hash did not verify) header.i=@smtpservice.net header.s=m78bu0.a1-4.dyn header.b=lOtr9f6a; 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; dmarc=fail (p=QUARANTINE sp=NONE dis=NONE) header.from=akamai.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 5E4A4689B7C; Thu, 26 Apr 2018 08:03:47 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from a1i318.smtp2go.com (a1i318.smtp2go.com [43.228.185.62]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id F30BD68048B for ; Thu, 26 Apr 2018 08:03:40 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=smtpservice.net; s=m78bu0.a1-4.dyn; x=1524719956; h=Feedback-ID: X-Smtpcorp-Track:Message-Id:Date:Subject:To:From:Reply-To:Sender: List-Unsubscribe; bh=/Vfa144BgoTsyWN6YBcjg18pcrVnzrsyRNKwpBFptM0=; b=lOtr9f6a KMDPwZl2l/XaVZJPOs1lF0zw8+u58RbRhfbQQRy8F+nQSbqvkl4A+uPKSyB4i46/IXUuofeqD3mHl Ck/AayPWfHYWk8kWzseYjk5aDwO6SnPU21088PFib+CjGVKMGXNHVhqPjBh9i1rHiy+kbrt7wZhsq gJVnJD6uVy+HrGtDV4qi5yUZd7IC/nSA4wzUZa5LYN3nr5zlIL15imny466VmkzCE5fSFJZOSA9Wm A9rWql27wvJi0gPY/pQs8Wmzpry3zbTwnu70NbfUjsrZLDeA8Tk8Ufm7C1vz5UEY2BPzIxVxQETL7 dm1aLzZQHkBd13b+SCecn5Uh0w==; From: vdixit@akamai.com To: ffmpeg-devel@ffmpeg.org Date: Thu, 26 Apr 2018 10:33:59 +0530 Message-Id: <1524719040-30542-1-git-send-email-vdixit@akamai.com> X-Mailer: git-send-email 1.9.1 X-Smtpcorp-Track: 1fUZ4f4baCd7D9.4R3E6bgx6 Feedback-ID: 337386m:337386asVRLGB:337386sknCFCOScX:SMTPCORP X-Report-Abuse: Please forward a copy of this message, including all headers, to Subject: [FFmpeg-devel] [PATCH 1/2] ffmpeg: handling copyts use case in forced key frames functionality 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 Cc: Vishwanath Dixit MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" From: Vishwanath Dixit Forced key frames creation functionality was assuming the first PTS value to be zero, but, when 'copyts' is enalbed, the first PTS can be any big number. This was eventually forcing all the frames as key frames. To overcome this issue, the actual first PTS value has to be considered. --- fftools/ffmpeg.c | 5 ++++- fftools/ffmpeg_opt.c | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 4dbe721..d9bb78a 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -1227,7 +1227,7 @@ static void do_video_out(OutputFile *of, in_picture->pict_type = 0; pts_time = in_picture->pts != AV_NOPTS_VALUE ? - in_picture->pts * av_q2d(enc->time_base) : NAN; + (in_picture->pts - ost->first_pts) * av_q2d(enc->time_base) : NAN; if (ost->forced_kf_index < ost->forced_kf_count && in_picture->pts >= ost->forced_kf_pts[ost->forced_kf_index]) { ost->forced_kf_index++; @@ -1477,6 +1477,9 @@ static int reap_filters(int flush) filtered_frame->pts = av_rescale_q(filtered_frame->pts, filter_tb, enc->time_base) - av_rescale_q(start_time, AV_TIME_BASE_Q, enc->time_base); + + if (ost->first_pts == AV_NOPTS_VALUE) + ost->first_pts = filtered_frame->pts; } //if (ost->source_index >= 0) // *filtered_frame= *input_streams[ost->source_index]->decoded_frame; //for me_threshold diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c index 8ae68ae..24efbd7 100644 --- a/fftools/ffmpeg_opt.c +++ b/fftools/ffmpeg_opt.c @@ -1510,6 +1510,7 @@ static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, e input_streams[source_index]->st->discard = input_streams[source_index]->user_set_discard; } ost->last_mux_dts = AV_NOPTS_VALUE; + ost->first_pts = AV_NOPTS_VALUE; ost->muxing_queue = av_fifo_alloc(8 * sizeof(AVPacket)); if (!ost->muxing_queue)