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 E8546495AA for ; Sun, 11 Aug 2024 19:05:37 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id C730368D9D5; Sun, 11 Aug 2024 22:05:34 +0300 (EEST) Received: from iq.passwd.hu (iq.passwd.hu [217.27.212.140]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 4102168D8FF for ; Sun, 11 Aug 2024 22:05:28 +0300 (EEST) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 0365DEAC59 for ; Sun, 11 Aug 2024 21:05:28 +0200 (CEST) X-Virus-Scanned: amavisd-new at passwd.hu Received: from iq.passwd.hu ([127.0.0.1]) by localhost (iq.passwd.hu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id lr00tNRKuuJu for ; Sun, 11 Aug 2024 21:05:26 +0200 (CEST) Received: from iq (iq [217.27.212.140]) by iq.passwd.hu (Postfix) with ESMTPS id 3834FEABD1 for ; Sun, 11 Aug 2024 21:05:26 +0200 (CEST) Date: Sun, 11 Aug 2024 21:05:26 +0200 (CEST) From: Marton Balint To: FFmpeg development discussions and patches In-Reply-To: <20240803191900.41511-1-jamrial@gmail.com> Message-ID: References: <20240803191900.41511-1-jamrial@gmail.com> MIME-Version: 1.0 Subject: Re: [FFmpeg-devel] [PATCH] avformat/movenc: use stream indexes when generating track ids 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-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: On Sat, 3 Aug 2024, James Almer wrote: > In some scenarios nb_tracks isn't the same as nb_streams, so a given id may end > up being used for two separate streams. > > e.g. when muxing an IAMF track followed by a video track, if the IAMF track > consists of several streams, the video track would end up having an id of 2, > which may also be used by one of the IAMF streams. > > Signed-off-by: James Almer > --- > libavformat/movenc.c | 6 +++++- > 1 file changed, 5 insertions(+), 1 deletion(-) > > diff --git a/libavformat/movenc.c b/libavformat/movenc.c > index 8e4a037e46..8d91059081 100644 > --- a/libavformat/movenc.c > +++ b/libavformat/movenc.c > @@ -4944,11 +4944,15 @@ static int mov_setup_track_ids(MOVMuxContext *mov, AVFormatContext *s) > mov->tracks[i].track_id = i >= mov->nb_streams ? ++next_generated_track_id : mov->tracks[i].st->id; > } > } else { > + int last_track_id = 0; > for (i = 0; i < mov->nb_tracks; i++) { > if (mov->tracks[i].entry <= 0 && !(mov->flags & FF_MOV_FLAG_FRAGMENT)) > continue; > > - mov->tracks[i].track_id = i + 1; > + last_track_id = > + mov->tracks[i].track_id = (mov->tracks[i].st > + ? FFMAX(mov->tracks[i].st->index, last_track_id) > + : FFMAX((i ? mov->tracks[i - 1].track_id : i), last_track_id)) + 1; Are you sure mov->tracks[i-1].track_id is always initialized? Because there is a condition above which can skip certain tracks. Maybe it would be safer to use last_track_id instead of mov->tracks[i-1].track_id ? Thanks, Marton _______________________________________________ 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".