mirror of
https://github.com/arcodange-org/mediabunny.git
synced 2026-09-27 19:03:46 +02:00
feature(isobmff): read disabled tracks (#214)
* feature(isobmff): read disabled tracks * Put enabled ISOBMFF tracks first --------- Co-authored-by: Vanilagy <[email protected]>
This commit is contained in:
@@ -92,6 +92,7 @@ type InternalTrack = {
|
||||
id: number;
|
||||
demuxer: IsobmffDemuxer;
|
||||
inputTrack: InputTrack | null;
|
||||
isDefault: boolean;
|
||||
timescale: number;
|
||||
durationInMovieTimescale: number;
|
||||
durationInMediaTimescale: number;
|
||||
@@ -315,6 +316,9 @@ export class IsobmffDemuxer extends Demuxer {
|
||||
this.moovSlice = moovSlice;
|
||||
this.readContiguousBoxes(this.moovSlice);
|
||||
|
||||
// Put default tracks first
|
||||
this.tracks.sort((a, b) => Number(b.isDefault) - Number(a.isDefault));
|
||||
|
||||
for (const track of this.tracks) {
|
||||
// Modify the edit list offset based on the previous segment durations. They are in different
|
||||
// timescales, so we first convert to seconds and then into the track timescale.
|
||||
@@ -651,6 +655,7 @@ export class IsobmffDemuxer extends Demuxer {
|
||||
id: -1,
|
||||
demuxer: this,
|
||||
inputTrack: null,
|
||||
isDefault: false,
|
||||
info: null,
|
||||
timescale: -1,
|
||||
durationInMovieTimescale: -1,
|
||||
@@ -695,10 +700,10 @@ export class IsobmffDemuxer extends Demuxer {
|
||||
const version = readU8(slice);
|
||||
const flags = readU24Be(slice);
|
||||
|
||||
const trackEnabled = (flags & 0x1) !== 0;
|
||||
if (!trackEnabled) {
|
||||
break;
|
||||
}
|
||||
// Spec says disabled tracks are to be treated like they don't exist, but in practice, they are treated
|
||||
// more like non-default tracks.
|
||||
const trackEnabled = !!(flags & 0x1);
|
||||
track.isDefault = trackEnabled;
|
||||
|
||||
// Skip over creation & modification time to reach the track ID
|
||||
if (version === 0) {
|
||||
|
||||
Reference in New Issue
Block a user