From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <ffmpeg-devel-bounces@ffmpeg.org>
Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100])
	by master.gitmailbox.com (Postfix) with ESMTPS id 12E6A495D6
	for <ffmpegdev@gitmailbox.com>; Mon, 24 Mar 2025 12:55:13 +0000 (UTC)
Received: from [127.0.1.1] (localhost [127.0.0.1])
	by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 7327D687A73;
	Mon, 24 Mar 2025 14:55:09 +0200 (EET)
Received: from mx0.riseup.net (mx0.riseup.net [198.252.153.6])
 by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 8493D680927
 for <ffmpeg-devel@ffmpeg.org>; Mon, 24 Mar 2025 14:55:02 +0200 (EET)
Received: from fews01-sea.riseup.net (fews01-sea-pn.riseup.net [10.0.1.109])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256)
 (No client certificate requested)
 by mx0.riseup.net (Postfix) with ESMTPS id 4ZLtLX3764z9swH;
 Mon, 24 Mar 2025 12:55:00 +0000 (UTC)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=riseup.net; s=squak;
 t=1742820900; bh=t9vP+iiyn55wjT5vNtES8k2JIjE2ISmX/ZczTiQyfzc=;
 h=Date:From:Subject:To:Cc:References:In-Reply-To:From;
 b=IeT5zkkDzlmsnVnl+7eaQNNh03m8Hx7+tcjA26YntTo+dB+Lq5JLD3PHS/gNGpDl6
 f1cBALoQdLNIk439VAx5XTJ0FydliGvNvRUQX+Vm6NlOLqdpNlxFFu6pzSxvxFUj3M
 mCKC6vo3CxtkdBryTehQYgAMyXoDCAx4fgYeRi6o=
X-Riseup-User-ID: 1AA372CA693BB53DB06C786BB26A247428FE575ADC429E7A9864F4AD1E881084
Received: from [127.0.0.1] (localhost [127.0.0.1])
 by fews01-sea.riseup.net (Postfix) with ESMTPSA id 4ZLtLW55rHzJnJX;
 Mon, 24 Mar 2025 12:54:59 +0000 (UTC)
Message-ID: <86cd1cc5-dfc1-481a-9e86-79e80965abfd@riseup.net>
Date: Mon, 24 Mar 2025 09:54:57 -0300
MIME-Version: 1.0
From: Arthur Grillo Queiroz Cabral <arthurgrillo@riseup.net>
To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
References: <20250312-video-only-kf-recover-v1-1-1e0e340da663@riseup.net>
Content-Language: en-US
In-Reply-To: <20250312-video-only-kf-recover-v1-1-1e0e340da663@riseup.net>
Subject: Re: [FFmpeg-devel] [PATCH] avformat/fifo: Check for keyframe video
 type before stop dropping
X-BeenThere: ffmpeg-devel@ffmpeg.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: FFmpeg development discussions and patches <ffmpeg-devel.ffmpeg.org>
List-Unsubscribe: <https://ffmpeg.org/mailman/options/ffmpeg-devel>,
 <mailto:ffmpeg-devel-request@ffmpeg.org?subject=unsubscribe>
List-Archive: <https://ffmpeg.org/pipermail/ffmpeg-devel>
List-Post: <mailto:ffmpeg-devel@ffmpeg.org>
List-Help: <mailto:ffmpeg-devel-request@ffmpeg.org?subject=help>
List-Subscribe: <https://ffmpeg.org/mailman/listinfo/ffmpeg-devel>,
 <mailto:ffmpeg-devel-request@ffmpeg.org?subject=subscribe>
Reply-To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
Cc: lingjiujianke@gmail.com
Content-Transfer-Encoding: 7bit
Content-Type: text/plain; charset="us-ascii"; Format="flowed"
Errors-To: ffmpeg-devel-bounces@ffmpeg.org
Sender: "ffmpeg-devel" <ffmpeg-devel-bounces@ffmpeg.org>
Archived-At: <https://master.gitmailbox.com/ffmpegdev/86cd1cc5-dfc1-481a-9e86-79e80965abfd@riseup.net/>
List-Archive: <https://master.gitmailbox.com/ffmpegdev/>
List-Post: <mailto:ffmpegdev@gitmailbox.com>

On Wed Mar 12, 2025 at 3:45 PM -03, Arthur Grillo wrote:
> The current behavior when using restart_with_keyframe is that it will
> recover if it also encounters any audio packet, as they are flagged as a
> keyframe.
>
> The expectation is that packets are dropped until the next _video_
> keyframe.
>
> Fix that by checking the packet stream codec type, only letting it
> recover when it is a video one.
>
> Fixes ticket: #11467
>
> Signed-off-by: Arthur Grillo <arthurgrillo@riseup.net>

Gentle ping :-)

> ---
> Cc: lingjiujianke@gmail.com
> ---
>  libavformat/fifo.c | 11 +++++++++--
>  1 file changed, 9 insertions(+), 2 deletions(-)
>
> diff --git a/libavformat/fifo.c b/libavformat/fifo.c
> index 23e4149ad606b201aade77e28057afe8e5fe2b71..1ebfa1f38f3affec2d81b5a2bb9d69190a5aa63f 100644
> --- a/libavformat/fifo.c
> +++ b/libavformat/fifo.c
> @@ -185,14 +185,21 @@ static int fifo_thread_write_packet(FifoThreadContext *ctx, AVPacket *pkt)
>      AVRational src_tb, dst_tb;
>      int ret, s_idx;
>      int64_t orig_pts, orig_dts, orig_duration;
> +    enum AVMediaType stream_codec_type = avf->streams[pkt->stream_index]->codecpar->codec_type;
>  
>      if (fifo->timeshift && pkt->dts != AV_NOPTS_VALUE)
>          atomic_fetch_sub_explicit(&fifo->queue_duration, next_duration(avf, pkt, &ctx->last_received_dts), memory_order_relaxed);
>  
>      if (ctx->drop_until_keyframe) {
>          if (pkt->flags & AV_PKT_FLAG_KEY) {
> -            ctx->drop_until_keyframe = 0;
> -            av_log(avf, AV_LOG_VERBOSE, "Keyframe received, recovering...\n");
> +            if (stream_codec_type == AVMEDIA_TYPE_VIDEO) {
> +                ctx->drop_until_keyframe = 0;
> +                av_log(avf, AV_LOG_VERBOSE, "Video keyframe received, recovering...\n");
> +            } else {
> +                av_log(avf, AV_LOG_VERBOSE, "Dropping non-video keyframe\n");
> +                av_packet_unref(pkt);
> +                return 0;
> +            }
>          } else {
>              av_log(avf, AV_LOG_VERBOSE, "Dropping non-keyframe packet\n");
>              av_packet_unref(pkt);
>
> ---
> base-commit: 3165fe5ecf4917d9f7d7f27d4fa3af31bc604515
> change-id: 20250312-video-only-kf-recover-18816009f240
>
> Best regards,

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".