History

avformat/movenc: use stream indexes when generating track ids

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.

James Almer committed 2 years ago

Commit 49a6e441 parent 210740b1 file · +5 −1Browse files

Unified · Split

libavformat/movenc.c+5−1
@@ -4944,11 +4944,15 @@ static int mov_setup_track_ids(MOVMuxContext *mov, AVFormatContext *s) · 4943 unmodified lines
49444944 mov->tracks[i].track_id = i >= mov->nb_streams ? ++next_generated_track_id : mov->tracks[i].st->id;
49454945 }
49464946 } else {
4947+ int last_track_id = 0;
49474948 for (i = 0; i < mov->nb_tracks; i++) {
49484949 if (mov->tracks[i].entry <= 0 && !(mov->flags & FF_MOV_FLAG_FRAGMENT))
49494950 continue;
49504951
4951− mov->tracks[i].track_id = i + 1;
4952+ last_track_id =
4953+ mov->tracks[i].track_id = (mov->tracks[i].st
4954+ ? FFMAX(mov->tracks[i].st->index, last_track_id)
4955+ : FFMAX((i ? mov->tracks[i - 1].track_id : i), last_track_id)) + 1;
49524956 }
49534957 }
49544958

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t