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 ESMTPS id 85E6C48400 for ; Tue, 28 Jan 2025 01:20:41 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id E97F468BAEA; Tue, 28 Jan 2025 03:20:37 +0200 (EET) Received: from mail-pl1-f170.google.com (mail-pl1-f170.google.com [209.85.214.170]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id BCA5B68B6D2 for ; Tue, 28 Jan 2025 03:20:30 +0200 (EET) Received: by mail-pl1-f170.google.com with SMTP id d9443c01a7336-21634338cfdso13822225ad.2 for ; Mon, 27 Jan 2025 17:20:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1738027228; x=1738632028; darn=ffmpeg.org; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=lSEjUSu4ZbvERQSb0Q8STm25dPANIj9GIT+KgW3uTNU=; b=So5zgLcTmFQE4hk/vab/YYnjv4hIyQ1+z+yaN53vVIsjMmS5bvHiCxds/QP+paxlxY wPgaaiD22rbBRJuq8K97JtShn8WSkpWK03BE6iwT7LYxrfu0GYDoyW+eAE18sjT6qcn1 yxjfoTMXdgOOqOdoxcK03wh6fYnI0IxggeTFWFTwUMjPFkuvW95b113avi/FOjmqn1cG fj59vkfCv0a+sFvUvDJzKyJXTGmertRfkcebB+dmr/zTundcJpve7eLV+jhzbkt3RUtq DXojpOlFmnj2isNHq6sZl4uWa3137WEfjbGuZVV74BVzerWAPvCeypAmFo4WD54zypG0 VANw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738027228; x=1738632028; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=lSEjUSu4ZbvERQSb0Q8STm25dPANIj9GIT+KgW3uTNU=; b=K0xXfD7IpD9a3ljQwH5Af/SaPeo573PD9/Q8+j3Rv1i1MiypwCRjHPNM1bN9yG7jZ2 96etCCuINLkMsRuVl5ATSszF/h3w+MvP3kNwIDWtsFrBRYznVxP1JBZltL5b8xrr+7Mc f795DQcnJFla5HO4yAV14U2aTq+AcoWRaUTpuNaK6/5Us4H8yGrc/PRoTAONZZ9yXIzq E+FknwWvpG02xRleZ2ED7hW6+bxCECTtQjMu4fJipSiRMeF9QSFxysBY/SzECwMyII3U Dvy8OiRueo+3pHPNJczJGf7CC7P49pyxxSRw8tjBLEV5H+oBfPW5auPoI1gTDRdI5pmu izfQ== X-Gm-Message-State: AOJu0Yy2xXUA10uvsPofzPLAfrtg/L2Qdvm3aynbsQO2DXlWsQsSMsd9 dSxInjwjMncBinDIHOLHOwnVMELuacevIU1spHy+FvNCRx4PTGjBo6ovWw== X-Gm-Gg: ASbGnct60CTRnJKh+2cfqgUvoabjP1tkLX4NOlty98DE8Dq4Ip1F0N6c6U0qwVfvlt9 ka73Ww5JjdXT4OcgMUs3x4/Y1+lHQO4Zocf/qc1lE/b2Krk4JHu2E4SOFWw/8n2Q9CEX2sJCz5B DqnRB8jFYeaQYaVN9fMO+P9AMFK7TlRJrvtqr02jEqnlvUj0kQZajTZ9Lw2wO9tNNvkhjgEp1V3 fFuaT/Cuw+aJvD3MwrVrtqGuQUKxhUsbEmS4hUluIHFYZh9LVtP+LgNdfyExr2lsRDSLexWyU4x SlmY8rMEOMTamZ4= X-Google-Smtp-Source: AGHT+IGC/A/8oSrIk2Dj6rW3FvLLm5fsiwin5whigfQqVgO6gN5nU3HgF6V8e7HxZDkWiT40rxdBqQ== X-Received: by 2002:a05:6a00:3018:b0:725:df1a:275 with SMTP id d2e1a72fcca58-72dafbd97b0mr61477951b3a.23.1738027228421; Mon, 27 Jan 2025 17:20:28 -0800 (PST) Received: from Mac.localdomain ([50.35.88.47]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72f8a76119fsm8147898b3a.104.2025.01.27.17.20.27 for (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 27 Jan 2025 17:20:28 -0800 (PST) From: Srikanth Kiran Kotagiri X-Google-Original-From: Srikanth Kiran Kotagiri To: ffmpeg-devel@ffmpeg.org Date: Mon, 27 Jan 2025 17:20:27 -0800 Message-Id: <20250128012027.15172-1-srikantk@gmail.com> X-Mailer: git-send-email 2.39.5 (Apple Git-154) MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] libavformat/mov.c: fix seek issues for fragmented mp4 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 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: For Fragmented MP4 files where the audio and video streams are written to seperate fragments, the -ss option will cause the file pointer to be set to the first available fragment. This is due to an interaction in search_frag_timestamp() function and get_frag_time() functions. With this change, we first verify that the fragment does not actually contain the requested fragment before just sending AV_NOPTS_VALUE. --- libavformat/mov.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/libavformat/mov.c b/libavformat/mov.c index c016ce8e41..f3e4f4deff 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -87,6 +87,7 @@ typedef struct MOVParseTableEntry { static int mov_read_default(MOVContext *c, AVIOContext *pb, MOVAtom atom); static int mov_read_mfra(MOVContext *c, AVIOContext *f); static void mov_free_stream_context(AVFormatContext *s, AVStream *st); +static int mov_switch_root(AVFormatContext *s, int64_t target, int index); static int mov_metadata_track_or_disc_number(MOVContext *c, AVIOContext *pb, unsigned len, const char *key) @@ -1680,6 +1681,27 @@ static int64_t get_frag_time(AVFormatContext *s, AVStream *dst_st, return frag_stream_info->sidx_pts; } + + // Check if the requested stream is present in the fragment + int stream_present = 0; + for (i = 0; i < frag_index->item[index].nb_stream_info; i++) { + if (dst_st->id != frag_index->item[index].stream_info[i].id) + continue; + if ( get_stream_info_time(&frag_index->item[index].stream_info[i]) != AV_NOPTS_VALUE) { + exists = 1; + break; + } + if ( mov_switch_root(s,-1,index) < 0) + return AV_NOPTS_VALUE; + if ( get_stream_info_time(&frag_index->item[index].stream_info[i]) != AV_NOPTS_VALUE) { + exists = 1; + break; + } + } + if (!stream_present) + return AV_NOPTS_VALUE; + + for (i = 0; i < frag_index->item[index].nb_stream_info; i++) { AVStream *frag_stream = NULL; frag_stream_info = &frag_index->item[index].stream_info[i]; -- 2.39.5 (Apple Git-154) _______________________________________________ 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".