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 8E1BF49533 for ; Tue, 14 May 2024 20:07:15 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 10A6E68D744; Tue, 14 May 2024 23:07:13 +0300 (EEST) Received: from mail-pf1-f172.google.com (mail-pf1-f172.google.com [209.85.210.172]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 71C6C68D700 for ; Tue, 14 May 2024 23:07:06 +0300 (EEST) Received: by mail-pf1-f172.google.com with SMTP id d2e1a72fcca58-6f4603237e0so4237407b3a.0 for ; Tue, 14 May 2024 13:07:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1715717223; x=1716322023; darn=ffmpeg.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=nTiF5b9pDhUdrvJLDXIZVORXQ+i52pdpIb410VwbwYg=; b=cOS088Iz4uv5C2bTvk/387PqZe7xzPBzhhR17lvCIfZn6OO1NMV3c/Um1ABEQlq0Lb VlOALnxOF2DjDvQKMwXAm23XkJpxjoBD+9BfaHhgHxARudeLma7hzeQh28WAtb7Sgux0 4hiQfsuUNSFf2B77BydCRMgZNfN3KWIplk57AO0DhvE0CczjfxKCP5BkYDpuy7ZETeco xn0KXfZpoY+IKYsLuSAT30b8TcFuKju/1FGk83vBGn6Yx9K38aYJaL/Ao06/mA2FBTDN BsxYqmp7GNXnJ1Ju7z7Rpy0l7OWndB6GMSIX9vFJEdJ/eCmERGcktSSTHhkDQaIN4wkx V2LQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715717223; x=1716322023; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=nTiF5b9pDhUdrvJLDXIZVORXQ+i52pdpIb410VwbwYg=; b=BBneT1TRMycC/qUNkzzOIrKdIPWbKA5SXVLCc4XJQrn3SS79JBoqQyKSldXkY+2Tm2 NJ3sJyNvI9RanX41/8+RJflUH/LwTDFSPV4NU4A6Sz11HbLNNQX2Zhx2KnORG4ZDfLqs rG5MbxEjuSAufdO0mx4pj5TrMrLRiVxPM4F8Js7PMk5SLP8exIAnqOMQYenRJUfGIrB9 zOhEg7XCFrCqWWCl0Dael7uTBKXroPOlebGoG4zePbC28RHmDOuNubBsK9nj3iSaJXhF 6xFrPDwyKHX5X1UEo6ant+/rdyitZ0bb1SqWrou1KuQxZ1YtqI9uCzw3m1rdSRQw9CVQ SB1A== X-Gm-Message-State: AOJu0YyHJOv4xHtdqZyuNsFcemjmwkoN1jbGpQKsWTM9KvifiITjAOno YjRtNosKGor1mglmcOeB4GoiSNTe0NNhBhhQ5sUF3p2h+87QLqZMC3AoLw== X-Google-Smtp-Source: AGHT+IFPYM9V4jU4zXOykU5PY4BaYx1Yjb03AuajG2jO/vGcG2HSl/DlwrJHZkKCFMrly+b6dg8FHA== X-Received: by 2002:a05:6a21:9985:b0:1af:8106:e046 with SMTP id adf61e73a8af0-1afde191e41mr18873809637.20.1715717223593; Tue, 14 May 2024 13:07:03 -0700 (PDT) Received: from localhost.localdomain ([103.208.20.250]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-6f4d2af2c41sm9878530b3a.172.2024.05.14.13.07.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 May 2024 13:07:03 -0700 (PDT) From: llyyr.public@gmail.com To: ffmpeg-devel@ffmpeg.org Date: Wed, 15 May 2024 01:36:43 +0530 Message-ID: <20240514200643.721-1-llyyr.public@gmail.com> X-Mailer: git-send-email 2.45.0 MIME-Version: 1.0 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 Cc: llyyr 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: From: llyyr 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); -- 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".