From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 9A7C14ABD4 for ; Tue, 14 May 2024 19:59:07 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id A069768D73C; Tue, 14 May 2024 22:59:04 +0300 (EEST) Received: from mail-pj1-f51.google.com (mail-pj1-f51.google.com [209.85.216.51]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 6DD6A68D4FD for ; Tue, 14 May 2024 22:58:58 +0300 (EEST) Received: by mail-pj1-f51.google.com with SMTP id 98e67ed59e1d1-2b346712919so4314984a91.2 for ; Tue, 14 May 2024 12:58:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1715716736; x=1716321536; darn=ffmpeg.org; h=subject:date:from:to:message-id:from:to:cc:subject:date:message-id :reply-to; bh=puV7KgiqYI44JhN8iQyMKGnnaRi+V44UhRIDnQRqEXU=; b=CQh64KnqTot9FU6lSzdi+CTVDdylCCJNXfGUR+Bu6eNlyiW11EECZ9UH688oXHOjha oIvR0DO8saKb7QeAwNxl2P+/gO6XEtguOhyamh24jjRf36Y2S92l7J1Wlho4SObI+372 nbgonmHuwcSMOzD+qX7Q9b5TssAMn8tIPNkqalQT0CCKkOTiq5GpG48yHcqUE+cdoDWh ekIqt2mxASyus8X6Ce4IwNVJ27VBnbS8sdY08HAwJ7yvF5GpM8cVaCpKNDVo5M1buNmL eHBnpxOwU87DHWO6wTTq3Br3Iig96nJvHXo2XUh4nWpKCQEX7GZ+Iit6m6c7ReEoMXke Wqcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715716736; x=1716321536; h=subject:date:from:to:message-id:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=puV7KgiqYI44JhN8iQyMKGnnaRi+V44UhRIDnQRqEXU=; b=Q2gwRiJhd7cSgX/LXZW8eQxkXGOl7p93cF05Anri0OOWayYsyGfmflbeQd510LPQ+u gcjRAGaQi1SqL2rkgpl/A54s3yAqr7FWTJ5g7lgQxlaj7sGSrnfSMbaaTtU/Kbwu1RZx PSrJeCk6HmC0ye8ym7HKoIb5c8d3UbvCR09smAZDFq2r92u+ws9cogo4mF4ztZW/5uHG Lq8T8YVTB3z1EysyidCpRr7JvIdR1k6YEs0sIf0/1Vcs7rWz7tOJN1IZYGrO30lCj+Zz eSFf59bixa95by3mlekU+oGb7IGxmgJab9G/PWWseeyIR2FXZV+Vg35HNtaVdxbEYgQL CBzg== X-Gm-Message-State: AOJu0YznE9fDCqOJLX7FH90Rje0gl6dp+BrU/PusO6XIrEZ335rTnOhE nZXzjmdmFdGoYDJg3n+jxteJlslNQpiSMolaqZZkSEKW3cLDlkrViVSKug== X-Google-Smtp-Source: AGHT+IHg4atSCUyEqUJK+N/sGkGHL6g1reyQOcEtbMoQB766nmpxuiK/030jQ5bdAz6aMB8QqolKbQ== X-Received: by 2002:a17:90b:3902:b0:2a0:3dc3:8a8b with SMTP id 98e67ed59e1d1-2b6cd0e9730mr9402088a91.47.1715716736163; Tue, 14 May 2024 12:58:56 -0700 (PDT) Received: from localhost ([103.208.20.250]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2b671165fbcsm11286517a91.17.2024.05.14.12.58.54 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 14 May 2024 12:58:55 -0700 (PDT) Message-Id: To: From: Date: Sat, 23 Sep 2023 16:26:20 +0530 Subject: [FFmpeg-devel] [PATCH] avformat/mov: avoid seeking back to 0 on HEVC open GOP files 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 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: ab77b878f1 attempted to fix the issue of broken packets being sent to the decoder by implementing logic that kept attempting to PTS-step backwards until it reached a valid point, however applying this heuristic meant that in files that had no valid points (such as HEVC videos shot on iPhones), we'd seek back to sample 0 on every seek attempt. This meant that files that were previously seekable, albeit with some skipped frames, were not seekable at all now. Relax this heuristic a bit by giving up on seeking to a valid point if we've tried a different sample and we still don't have a valid point to seek to. This may some frames to be skipped on seeking but it's better than not being able to seek at all in such files. Fixes: ab77b878f1 ("avformat/mov: fix seeking with HEVC open GOP files") Fixes: #10585 --- libavformat/mov.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/libavformat/mov.c b/libavformat/mov.c index b3fa748f27e8..6174a04c3169 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -10133,7 +10133,7 @@ static int mov_seek_stream(AVFormatContext *s, AVStream *st, int64_t timestamp, { MOVStreamContext *sc = st->priv_data; FFStream *const sti = ffstream(st); - int sample, time_sample, ret; + int sample, time_sample, ret, next_ts, requested_sample; unsigned int i; // Here we consider timestamp to be PTS, hence try to offset it so that we @@ -10154,7 +10154,17 @@ static int mov_seek_stream(AVFormatContext *s, AVStream *st, int64_t timestamp, if (!sample || can_seek_to_key_sample(st, sample, timestamp)) break; - timestamp -= FFMAX(sc->min_sample_duration, 1); + + next_ts = timestamp - FFMAX(sc->min_sample_duration, 1); + requested_sample = av_index_search_timestamp(st, next_ts, flags); + + // If we've reached a different sample trying to find a good pts to + // seek to, give up searching because we'll end up seeking back to + // sample 0 on every seek. + if (!can_seek_to_key_sample(st, requested_sample, next_ts) && sample != requested_sample) + break; + + timestamp = next_ts; } mov_current_sample_set(sc, sample); base-commit: b0093ab8a3d34bf2fefd6665464cc343a9ef0d53 -- 2.45.0 _______________________________________________ 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".