From patchwork Tue Feb 15 15:56:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Almer X-Patchwork-Id: 34307 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6838:90eb:0:0:0:0 with SMTP id a11csp415262nkf; Tue, 15 Feb 2022 07:57:20 -0800 (PST) X-Google-Smtp-Source: ABdhPJyshP2m110GXxoYko41a8U+HhQ+/qv8RvKKAyTMF9yXT+Qj/HCj0xWFtkGKBDom3zYwmyOr X-Received: by 2002:a17:906:74c2:: with SMTP id z2mr3415906ejl.685.1644940639772; Tue, 15 Feb 2022 07:57:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644940639; cv=none; d=google.com; s=arc-20160816; b=I9D0/vyNbruC5QA0D8s50a+/oemjXGRnO6vY05S2oZIFb1e2gzBod50h3trOU30i5V /BeUcJHckOhg0Ypco9yg0dOcgr2+teppy3CbSPv6IP0G2AHEfJsiPL//yA3sCGFcwGk6 epsQCvItbjURaHjo4X18uzVw2g54in1bBKrJ2OkvzlXv8yW4+ZQEgY42w6eq5Im2jIQL tPXKI0m+jy7BzIHKPAy/9W3CbvrAlRohX+STLLgbQ8aFa+FzXGEqEKhrqQ6diDrtciLS g63pru1yhG+2tGnD0lTvedgSx2YlsYDv7hX/FriFT4rZ02MTXJck+YrML1Do3MyH92NY CdBQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:dkim-signature:delivered-to; bh=h18sMsulQ8mmbizgzEj3g6hNLPMHaIrPZWaJrqZJbnc=; b=jY7ww1YLbJpPdFe8YlrKE/V7p6A0+gJXpHzQlBw7wyu9n78rM7HJ14sTAwuEr/IGlt oK3WU2wEM66uMnT9XI0AiXkhQtd6vtYMSI1uJ4mnRvNwRGX5uIghinvT3yRH9kobYRk4 oxW1/K/lVLDTeRQf7Vx1sd/vK0xgPc0t1Yx8AhVqo5Na/duCPFJHfo/cmfEsNGMexsOs rHMAqTqDSBXyB+LfpbriyVbZ14sQ8g0wuxXU2B6npNp7cXcx96P20yzt0hKlYyoOaSar e5dUzt8dMfWRXeKdaLOt/LWuQimrx0Lg0JqulE8fiSY2cPCjfWJuiX2ol+yzvnn6CjcK Y9NQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=PTj6W8EL; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id fm14si1983001ejc.795.2022.02.15.07.56.56; Tue, 15 Feb 2022 07:57:19 -0800 (PST) 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=@gmail.com header.s=20210112 header.b=PTj6W8EL; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 02AAC68A596; Tue, 15 Feb 2022 17:56:53 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ot1-f45.google.com (mail-ot1-f45.google.com [209.85.210.45]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 6CCB168A596 for ; Tue, 15 Feb 2022 17:56:46 +0200 (EET) Received: by mail-ot1-f45.google.com with SMTP id w27-20020a9d5a9b000000b005a17d68ae89so14055563oth.12 for ; Tue, 15 Feb 2022 07:56:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=YT/ZWaWwGurmmqu/41s2bx5GX6qUAC2aVPZyovhSIhg=; b=PTj6W8ELZjtUtKcFZMW3wF7B/nR6moBn2xG6VbZeupmQhBbWyBZw2/zVZXbRPSCCK/ GcqZa+twGZoSeaaiFXmK6aCziIup1bHjrlyt3hyB2CRSZxR9WhLPpoXCr3+JSOFycn7l JrSlqEOZR0Rg9QaSuhVX9gj+Qmac0tu+H3/5gy8X6cNQ5nx9mobWNNfu2oQn4PPRrrpf bpl6c/xVQncw0jam17xh90J4kjDG4KdjiLd2hQNQ2by4jZXHcY4Z3TrqKyOWwJP3uyDd 98EBOXhPYgdQYhFIYKG644ySrDdZacaD3kIsR6PpUTFTft43nCUaBTxLtdIndGcMGSkA CNZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=YT/ZWaWwGurmmqu/41s2bx5GX6qUAC2aVPZyovhSIhg=; b=NpKZDa2iXwRCCW6EmOa3qipMsYt61aRYbC8RGgK/0007F6pZ790qACmj4tCWfuRESl iLQWhr/USNrIePDbcTgQP99xJbJjIvVo0QzZjYW8BQ8/J5IrkdC+mtkf8EJkWiU74vle Yi+bNywNw75w2cyJAd1PVutuvnS9VThyE7+O6Khcu5uv1Ed8OC9Y2xxG9Z3+llthZWUr 4GbtsfPefaUEnYbaHIx0L1cKaxP3MYWcbHnXRp/dJdR6Qn02Q6K6Bpf0tm+VU1xeeBfD s1FyC8WW/P18n1O5+WC+vHhxEYWd49Nup+RYGHlXYB6iMlkqr3cbYZn1r/FPleTMSGn1 dkWA== X-Gm-Message-State: AOAM533Q++ZEtpBuSrAMOKihNZM4WaEhroC57xLvtl+TRcIYXtlgFhxv pGCrY3CVpySC+3o1UJyzgwE379RK/LrDOg== X-Received: by 2002:a05:6830:1df0:: with SMTP id b16mr1531698otj.364.1644940604404; Tue, 15 Feb 2022 07:56:44 -0800 (PST) Received: from localhost.localdomain ([186.136.131.95]) by smtp.gmail.com with ESMTPSA id bh7sm10968233oib.6.2022.02.15.07.56.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Feb 2022 07:56:43 -0800 (PST) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Tue, 15 Feb 2022 12:56:14 -0300 Message-Id: <20220215155615.5234-1-jamrial@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220214224156.39862-1-jamrial@gmail.com> References: <20220214224156.39862-1-jamrial@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/4] ffmpeg: ensure a keyframe was not seen before skipping packets X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: xTo0aCoP4a2N A keyframe could be buffered in the bsf and not be output until more packets had been fed to it. Signed-off-by: James Almer --- This replaces/supersedes [PATCH 2/6] avcodec/bsf: add a capabilities field to AVBitStreamFilter [PATCH 4/6] ffmpeg: don't skip packets before a keyframe was seen if a bsf with delay is used fftools/ffmpeg.c | 4 +++- fftools/ffmpeg.h | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 6aa0986f02..2a56b2f0e7 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -889,6 +889,8 @@ static void output_packet(OutputFile *of, AVPacket *pkt, /* apply the output bitstream filters */ if (ost->bsf_ctx) { + if (pkt && (pkt->flags & AV_PKT_FLAG_KEY)) + ost->seen_kf = 1; ret = av_bsf_send_packet(ost->bsf_ctx, eof ? NULL : pkt); if (ret < 0) goto finish; @@ -2026,7 +2028,7 @@ static void do_streamcopy(InputStream *ist, OutputStream *ost, const AVPacket *p } if ((!ost->frame_number && !(pkt->flags & AV_PKT_FLAG_KEY)) && - !ost->copy_initial_nonkeyframes) + !ost->copy_initial_nonkeyframes && !ost->seen_kf) return; if (!ost->frame_number && !ost->copy_prior_start) { diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index 1b8bbace3f..cc8f767e5d 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -535,6 +535,7 @@ typedef struct OutputStream { int inputs_done; const char *attachment_filename; + int seen_kf; int copy_initial_nonkeyframes; int copy_prior_start; char *disposition;