Commit 6dba2558c0 for ffmpeg
commit 6dba2558c0d439162d8e88f7182268594c9e2c93
Author: Martin Mirchev <mmirchev@comp.nus.edu.sg>
Date: Wed Oct 21 19:01:04 2026 +0800
avformat/mov: check the stream group type when updating IAMF streams
The lookup of the stream group for each IAMF audio element compared only
the group id and kept the last match. Mix presentation groups are created
after the audio element groups and use the mix_presentation_id as their
id, so if a mix_presentation_id equals an audio_element_id the mix
presentation group was picked instead. Its entries are the streams of
every audio element, so the same output stream got its index entries
filled twice and the av_assert0(!out_sti->index_entries) aborted.
Such files are written by FFmpeg's own mp4 muxer, e.g. with two audio
elements with ids 1 and 2 and a mix presentation with id 1.
Also check the group type. Keep using the last match: audio element ids
are only unique within one IAMF track, and the groups of the current
track were just appended, so the last match is the audio element of the
current track even if an earlier track uses the same id.
Signed-off-by: Martin Mirchev <mmirchev@comp.nus.edu.sg>
diff --git a/libavformat/mov.c b/libavformat/mov.c
index 910df844dc..790087c92a 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -5520,7 +5520,8 @@ static int mov_update_iamf_streams(MOVContext *c, const AVStream *st)
const AVStreamGroup *stg = NULL;
for (int j = 0; j < c->fc->nb_stream_groups; j++)
- if (c->fc->stream_groups[j]->id == iamf->audio_elements[i]->audio_element_id)
+ if (c->fc->stream_groups[j]->type == AV_STREAM_GROUP_PARAMS_IAMF_AUDIO_ELEMENT &&
+ c->fc->stream_groups[j]->id == iamf->audio_elements[i]->audio_element_id)
stg = c->fc->stream_groups[j];
av_assert0(stg);