@remotion/media-parser 4.0.533 → 4.0.535
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/containers/m3u/select-stream.d.ts +6 -0
- package/dist/containers/m3u/select-stream.js +6 -0
- package/dist/controller/media-parser-controller.d.ts +3 -0
- package/dist/controller/media-parser-controller.js +3 -0
- package/dist/download-and-parse-media.d.ts +3 -0
- package/dist/download-and-parse-media.js +3 -0
- package/dist/errors.d.ts +3 -0
- package/dist/errors.js +3 -0
- package/dist/esm/index.mjs +384 -384
- package/dist/esm/node.mjs +3 -3
- package/dist/esm/worker-server-entry.mjs +359 -359
- package/dist/esm/worker-web-entry.mjs +357 -357
- package/dist/esm/worker.mjs +5 -5
- package/dist/readers/from-node.d.ts +12 -0
- package/dist/readers/from-node.js +12 -0
- package/dist/readers/universal.d.ts +3 -0
- package/dist/readers/universal.js +3 -0
- package/dist/readers/web.d.ts +3 -0
- package/dist/readers/web.js +3 -0
- package/dist/server-worker.d.ts +3 -0
- package/dist/server-worker.js +3 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/worker.d.ts +3 -0
- package/dist/worker.js +3 -0
- package/dist/writers/node.d.ts +3 -0
- package/dist/writers/node.js +3 -0
- package/package.json +5 -5
|
@@ -2977,8 +2977,8 @@ var parseAv1PrivateData = (data, colrAtom) => {
|
|
|
2977
2977
|
str += ".";
|
|
2978
2978
|
const high_bitdepth = iterator.getBits(1);
|
|
2979
2979
|
const twelve_bit = iterator.getBits(1);
|
|
2980
|
-
const
|
|
2981
|
-
str +=
|
|
2980
|
+
const bitDepth = high_bitdepth && seqProfile === 2 ? twelve_bit ? 12 : 10 : high_bitdepth ? 10 : 8;
|
|
2981
|
+
str += bitDepth.toString().padStart(2, "0");
|
|
2982
2982
|
str += ".";
|
|
2983
2983
|
const mono_chrome = iterator.getBits(1);
|
|
2984
2984
|
str += mono_chrome ? "1" : "0";
|
|
@@ -3095,12 +3095,12 @@ var normalizeVideoRotation = (rotation) => {
|
|
|
3095
3095
|
var WEBCODECS_TIMESCALE = 1e6;
|
|
3096
3096
|
|
|
3097
3097
|
// src/containers/iso-base-media/color-to-webcodecs-colors.ts
|
|
3098
|
-
var mediaParserAdvancedColorToWebCodecsColor = (
|
|
3098
|
+
var mediaParserAdvancedColorToWebCodecsColor = (color) => {
|
|
3099
3099
|
return {
|
|
3100
|
-
transfer:
|
|
3101
|
-
matrix:
|
|
3102
|
-
primaries:
|
|
3103
|
-
fullRange:
|
|
3100
|
+
transfer: color.transfer,
|
|
3101
|
+
matrix: color.matrix,
|
|
3102
|
+
primaries: color.primaries,
|
|
3103
|
+
fullRange: color.fullRange
|
|
3104
3104
|
};
|
|
3105
3105
|
};
|
|
3106
3106
|
|
|
@@ -3183,10 +3183,10 @@ var createAacCodecPrivate = ({
|
|
|
3183
3183
|
audioObjectType,
|
|
3184
3184
|
sampleRate,
|
|
3185
3185
|
channelConfiguration,
|
|
3186
|
-
codecPrivate
|
|
3186
|
+
codecPrivate
|
|
3187
3187
|
}) => {
|
|
3188
|
-
if (
|
|
3189
|
-
return
|
|
3188
|
+
if (codecPrivate !== null && codecPrivate.length > 2) {
|
|
3189
|
+
return codecPrivate;
|
|
3190
3190
|
}
|
|
3191
3191
|
const bits = `${audioObjectType.toString(2).padStart(5, "0")}${getConfigForSampleRate(sampleRate).toString(2).padStart(4, "0")}${channelConfiguration.toString(2).padStart(4, "0")}000`;
|
|
3192
3192
|
if (bits.length !== 16) {
|
|
@@ -3258,7 +3258,7 @@ var mapAudioObjectTypeToCodecString = (audioObjectType) => {
|
|
|
3258
3258
|
// src/containers/iso-base-media/get-actual-number-of-channels.ts
|
|
3259
3259
|
var getActualDecoderParameters = ({
|
|
3260
3260
|
audioCodec,
|
|
3261
|
-
codecPrivate
|
|
3261
|
+
codecPrivate,
|
|
3262
3262
|
numberOfChannels,
|
|
3263
3263
|
sampleRate
|
|
3264
3264
|
}) => {
|
|
@@ -3266,19 +3266,19 @@ var getActualDecoderParameters = ({
|
|
|
3266
3266
|
return {
|
|
3267
3267
|
numberOfChannels,
|
|
3268
3268
|
sampleRate,
|
|
3269
|
-
codecPrivate
|
|
3269
|
+
codecPrivate
|
|
3270
3270
|
};
|
|
3271
3271
|
}
|
|
3272
|
-
if (
|
|
3273
|
-
return { numberOfChannels, sampleRate, codecPrivate
|
|
3272
|
+
if (codecPrivate === null) {
|
|
3273
|
+
return { numberOfChannels, sampleRate, codecPrivate };
|
|
3274
3274
|
}
|
|
3275
|
-
if (
|
|
3275
|
+
if (codecPrivate.type !== "aac-config") {
|
|
3276
3276
|
throw new Error("Expected AAC codec private data");
|
|
3277
3277
|
}
|
|
3278
|
-
const parsed = parseAacCodecPrivate(
|
|
3278
|
+
const parsed = parseAacCodecPrivate(codecPrivate.data);
|
|
3279
3279
|
const actual = createAacCodecPrivate({
|
|
3280
3280
|
...parsed,
|
|
3281
|
-
codecPrivate:
|
|
3281
|
+
codecPrivate: codecPrivate.data
|
|
3282
3282
|
});
|
|
3283
3283
|
return {
|
|
3284
3284
|
numberOfChannels: parsed.channelConfiguration,
|
|
@@ -3394,11 +3394,11 @@ var makeBaseMediaTrack = (trakBox, startTimeInSeconds) => {
|
|
|
3394
3394
|
throw new Error("Could not find sample rate");
|
|
3395
3395
|
}
|
|
3396
3396
|
const { codecString, description } = getAudioCodecStringFromTrak(trakBox);
|
|
3397
|
-
const
|
|
3397
|
+
const codecPrivate = getCodecPrivateFromTrak(trakBox) ?? description ?? null;
|
|
3398
3398
|
const codecEnum = getAudioCodecFromTrack(trakBox);
|
|
3399
3399
|
const actual = getActualDecoderParameters({
|
|
3400
3400
|
audioCodec: codecEnum,
|
|
3401
|
-
codecPrivate:
|
|
3401
|
+
codecPrivate: codecPrivate ?? null,
|
|
3402
3402
|
numberOfChannels,
|
|
3403
3403
|
sampleRate
|
|
3404
3404
|
});
|
|
@@ -3637,7 +3637,7 @@ var makeAviVideoTrack = ({
|
|
|
3637
3637
|
};
|
|
3638
3638
|
};
|
|
3639
3639
|
var getTracksFromAvi = (structure, state) => {
|
|
3640
|
-
const
|
|
3640
|
+
const tracks = [];
|
|
3641
3641
|
const boxes = getStrlBoxes(structure);
|
|
3642
3642
|
let i = 0;
|
|
3643
3643
|
for (const box of boxes) {
|
|
@@ -3647,22 +3647,22 @@ var getTracksFromAvi = (structure, state) => {
|
|
|
3647
3647
|
}
|
|
3648
3648
|
const { strf } = strh;
|
|
3649
3649
|
if (strf.type === "strf-box-video") {
|
|
3650
|
-
|
|
3650
|
+
tracks.push(addAvcProfileToTrack(makeAviVideoTrack({ strh, strf, index: i }), state.riff.getAvcProfile()));
|
|
3651
3651
|
} else if (strh.fccType === "auds") {
|
|
3652
|
-
|
|
3652
|
+
tracks.push(makeAviAudioTrack({ strf, index: i }));
|
|
3653
3653
|
} else {
|
|
3654
3654
|
throw new Error(`Unsupported track type ${strh.fccType}`);
|
|
3655
3655
|
}
|
|
3656
3656
|
i++;
|
|
3657
3657
|
}
|
|
3658
|
-
return
|
|
3658
|
+
return tracks;
|
|
3659
3659
|
};
|
|
3660
3660
|
var hasAllTracksFromAvi = (state) => {
|
|
3661
3661
|
try {
|
|
3662
3662
|
const structure = state.structure.getRiffStructure();
|
|
3663
3663
|
const numberOfTracks = getNumberOfTracks(structure);
|
|
3664
|
-
const
|
|
3665
|
-
return
|
|
3664
|
+
const tracks = getTracksFromAvi(structure, state);
|
|
3665
|
+
return tracks.length === numberOfTracks && !tracks.find((t) => t.type === "video" && t.codec === TO_BE_OVERRIDDEN_LATER);
|
|
3666
3666
|
} catch {
|
|
3667
3667
|
return false;
|
|
3668
3668
|
}
|
|
@@ -3793,106 +3793,106 @@ var getCodecSegment = (track) => {
|
|
|
3793
3793
|
return codec;
|
|
3794
3794
|
};
|
|
3795
3795
|
var getColourSegment = (track) => {
|
|
3796
|
-
const
|
|
3797
|
-
if (!
|
|
3796
|
+
const videoSegment = getVideoSegment(track);
|
|
3797
|
+
if (!videoSegment) {
|
|
3798
3798
|
return null;
|
|
3799
3799
|
}
|
|
3800
|
-
const colour =
|
|
3800
|
+
const colour = videoSegment.value.find((b) => b.type === "Colour");
|
|
3801
3801
|
if (!colour || colour.type !== "Colour") {
|
|
3802
3802
|
return null;
|
|
3803
3803
|
}
|
|
3804
3804
|
return colour;
|
|
3805
3805
|
};
|
|
3806
|
-
var getTransferCharacteristicsSegment = (
|
|
3807
|
-
if (!
|
|
3806
|
+
var getTransferCharacteristicsSegment = (color) => {
|
|
3807
|
+
if (!color || color.type !== "Colour") {
|
|
3808
3808
|
return null;
|
|
3809
3809
|
}
|
|
3810
|
-
const box =
|
|
3810
|
+
const box = color.value.find((b) => b.type === "TransferCharacteristics");
|
|
3811
3811
|
if (!box || box.type !== "TransferCharacteristics") {
|
|
3812
3812
|
return null;
|
|
3813
3813
|
}
|
|
3814
3814
|
return box;
|
|
3815
3815
|
};
|
|
3816
|
-
var getMatrixCoefficientsSegment = (
|
|
3817
|
-
if (!
|
|
3816
|
+
var getMatrixCoefficientsSegment = (color) => {
|
|
3817
|
+
if (!color || color.type !== "Colour") {
|
|
3818
3818
|
return null;
|
|
3819
3819
|
}
|
|
3820
|
-
const box =
|
|
3820
|
+
const box = color.value.find((b) => b.type === "MatrixCoefficients");
|
|
3821
3821
|
if (!box || box.type !== "MatrixCoefficients") {
|
|
3822
3822
|
return null;
|
|
3823
3823
|
}
|
|
3824
3824
|
return box;
|
|
3825
3825
|
};
|
|
3826
|
-
var getPrimariesSegment = (
|
|
3827
|
-
if (!
|
|
3826
|
+
var getPrimariesSegment = (color) => {
|
|
3827
|
+
if (!color || color.type !== "Colour") {
|
|
3828
3828
|
return null;
|
|
3829
3829
|
}
|
|
3830
|
-
const box =
|
|
3830
|
+
const box = color.value.find((b) => b.type === "Primaries");
|
|
3831
3831
|
if (!box || box.type !== "Primaries") {
|
|
3832
3832
|
return null;
|
|
3833
3833
|
}
|
|
3834
3834
|
return box;
|
|
3835
3835
|
};
|
|
3836
|
-
var getRangeSegment = (
|
|
3837
|
-
if (!
|
|
3836
|
+
var getRangeSegment = (color) => {
|
|
3837
|
+
if (!color || color.type !== "Colour") {
|
|
3838
3838
|
return null;
|
|
3839
3839
|
}
|
|
3840
|
-
const box =
|
|
3840
|
+
const box = color.value.find((b) => b.type === "Range");
|
|
3841
3841
|
if (!box || box.type !== "Range") {
|
|
3842
3842
|
return null;
|
|
3843
3843
|
}
|
|
3844
3844
|
return box;
|
|
3845
3845
|
};
|
|
3846
3846
|
var getDisplayHeightSegment = (track) => {
|
|
3847
|
-
const
|
|
3848
|
-
if (!
|
|
3847
|
+
const videoSegment = getVideoSegment(track);
|
|
3848
|
+
if (!videoSegment) {
|
|
3849
3849
|
return null;
|
|
3850
3850
|
}
|
|
3851
|
-
const
|
|
3852
|
-
if (!
|
|
3851
|
+
const displayHeight = videoSegment.value.find((b) => b.type === "DisplayHeight");
|
|
3852
|
+
if (!displayHeight || displayHeight.type !== "DisplayHeight") {
|
|
3853
3853
|
return null;
|
|
3854
3854
|
}
|
|
3855
|
-
return
|
|
3855
|
+
return displayHeight;
|
|
3856
3856
|
};
|
|
3857
3857
|
var getTrackTypeSegment = (track) => {
|
|
3858
|
-
const
|
|
3859
|
-
if (!
|
|
3858
|
+
const trackType = track.value.find((b) => b.type === "TrackType");
|
|
3859
|
+
if (!trackType || trackType.type !== "TrackType") {
|
|
3860
3860
|
return null;
|
|
3861
3861
|
}
|
|
3862
|
-
return
|
|
3862
|
+
return trackType;
|
|
3863
3863
|
};
|
|
3864
3864
|
var getWidthSegment = (track) => {
|
|
3865
|
-
const
|
|
3866
|
-
if (!
|
|
3865
|
+
const videoSegment = getVideoSegment(track);
|
|
3866
|
+
if (!videoSegment) {
|
|
3867
3867
|
return null;
|
|
3868
3868
|
}
|
|
3869
|
-
const width =
|
|
3869
|
+
const width = videoSegment.value.find((b) => b.type === "PixelWidth");
|
|
3870
3870
|
if (!width || width.type !== "PixelWidth") {
|
|
3871
3871
|
return null;
|
|
3872
3872
|
}
|
|
3873
3873
|
return width;
|
|
3874
3874
|
};
|
|
3875
3875
|
var getHeightSegment = (track) => {
|
|
3876
|
-
const
|
|
3877
|
-
if (!
|
|
3876
|
+
const videoSegment = getVideoSegment(track);
|
|
3877
|
+
if (!videoSegment) {
|
|
3878
3878
|
return null;
|
|
3879
3879
|
}
|
|
3880
|
-
const height =
|
|
3880
|
+
const height = videoSegment.value.find((b) => b.type === "PixelHeight");
|
|
3881
3881
|
if (!height || height.type !== "PixelHeight") {
|
|
3882
3882
|
return null;
|
|
3883
3883
|
}
|
|
3884
3884
|
return height;
|
|
3885
3885
|
};
|
|
3886
3886
|
var getDisplayWidthSegment = (track) => {
|
|
3887
|
-
const
|
|
3888
|
-
if (!
|
|
3887
|
+
const videoSegment = getVideoSegment(track);
|
|
3888
|
+
if (!videoSegment) {
|
|
3889
3889
|
return null;
|
|
3890
3890
|
}
|
|
3891
|
-
const
|
|
3892
|
-
if (!
|
|
3891
|
+
const displayWidth = videoSegment.value.find((b) => b.type === "DisplayWidth");
|
|
3892
|
+
if (!displayWidth || displayWidth.type !== "DisplayWidth") {
|
|
3893
3893
|
return null;
|
|
3894
3894
|
}
|
|
3895
|
-
return
|
|
3895
|
+
return displayWidth;
|
|
3896
3896
|
};
|
|
3897
3897
|
var getTracksSegment = (segment) => {
|
|
3898
3898
|
const tracksSegment = segment.value.find((b) => b.type === "Tracks");
|
|
@@ -3907,60 +3907,60 @@ var getTrackWithUid = (segment, trackUid) => {
|
|
|
3907
3907
|
return null;
|
|
3908
3908
|
}
|
|
3909
3909
|
const trackEntries = tracksSegment.value.filter((t) => t.type === "TrackEntry");
|
|
3910
|
-
const
|
|
3910
|
+
const trackEntry = trackEntries.find((entry) => {
|
|
3911
3911
|
return entry?.value.find((t) => t.type === "TrackUID" && t.value === trackUid);
|
|
3912
3912
|
});
|
|
3913
|
-
if (!
|
|
3913
|
+
if (!trackEntry) {
|
|
3914
3914
|
return null;
|
|
3915
3915
|
}
|
|
3916
|
-
return
|
|
3916
|
+
return trackEntry.value.find((t) => t.type === "TrackNumber")?.value.value ?? null;
|
|
3917
3917
|
};
|
|
3918
3918
|
var getVideoSegment = (track) => {
|
|
3919
|
-
const
|
|
3920
|
-
if (!
|
|
3919
|
+
const videoSegment = track.value.find((b) => b.type === "Video");
|
|
3920
|
+
if (!videoSegment || videoSegment.type !== "Video") {
|
|
3921
3921
|
return null;
|
|
3922
3922
|
}
|
|
3923
|
-
return
|
|
3923
|
+
return videoSegment ?? null;
|
|
3924
3924
|
};
|
|
3925
3925
|
var getAudioSegment = (track) => {
|
|
3926
|
-
const
|
|
3927
|
-
if (!
|
|
3926
|
+
const audioSegment = track.value.find((b) => b.type === "Audio");
|
|
3927
|
+
if (!audioSegment || audioSegment.type !== "Audio") {
|
|
3928
3928
|
return null;
|
|
3929
3929
|
}
|
|
3930
|
-
return
|
|
3930
|
+
return audioSegment ?? null;
|
|
3931
3931
|
};
|
|
3932
3932
|
var getSampleRate2 = (track) => {
|
|
3933
|
-
const
|
|
3934
|
-
if (!
|
|
3933
|
+
const audioSegment = getAudioSegment(track);
|
|
3934
|
+
if (!audioSegment) {
|
|
3935
3935
|
return null;
|
|
3936
3936
|
}
|
|
3937
|
-
const
|
|
3938
|
-
if (!
|
|
3937
|
+
const samplingFrequency = audioSegment.value.find((b) => b.type === "SamplingFrequency");
|
|
3938
|
+
if (!samplingFrequency || samplingFrequency.type !== "SamplingFrequency") {
|
|
3939
3939
|
return null;
|
|
3940
3940
|
}
|
|
3941
|
-
return
|
|
3941
|
+
return samplingFrequency.value.value;
|
|
3942
3942
|
};
|
|
3943
3943
|
var getNumberOfChannels = (track) => {
|
|
3944
|
-
const
|
|
3945
|
-
if (!
|
|
3944
|
+
const audioSegment = getAudioSegment(track);
|
|
3945
|
+
if (!audioSegment) {
|
|
3946
3946
|
throw new Error("Could not find audio segment");
|
|
3947
3947
|
}
|
|
3948
|
-
const
|
|
3949
|
-
if (!
|
|
3948
|
+
const channels = audioSegment.value.find((b) => b.type === "Channels");
|
|
3949
|
+
if (!channels || channels.type !== "Channels") {
|
|
3950
3950
|
return 1;
|
|
3951
3951
|
}
|
|
3952
|
-
return
|
|
3952
|
+
return channels.value.value;
|
|
3953
3953
|
};
|
|
3954
3954
|
var getBitDepth = (track) => {
|
|
3955
|
-
const
|
|
3956
|
-
if (!
|
|
3955
|
+
const audioSegment = getAudioSegment(track);
|
|
3956
|
+
if (!audioSegment) {
|
|
3957
3957
|
return null;
|
|
3958
3958
|
}
|
|
3959
|
-
const
|
|
3960
|
-
if (!
|
|
3959
|
+
const bitDepth = audioSegment.value.find((b) => b.type === "BitDepth");
|
|
3960
|
+
if (!bitDepth || bitDepth.type !== "BitDepth") {
|
|
3961
3961
|
return null;
|
|
3962
3962
|
}
|
|
3963
|
-
return
|
|
3963
|
+
return bitDepth.value.value;
|
|
3964
3964
|
};
|
|
3965
3965
|
var getPrivateData = (track) => {
|
|
3966
3966
|
const privateData = track.value.find((b) => b.type === "CodecPrivate");
|
|
@@ -3972,15 +3972,15 @@ var getPrivateData = (track) => {
|
|
|
3972
3972
|
|
|
3973
3973
|
// src/containers/webm/color.ts
|
|
3974
3974
|
var parseColorSegment = (colourSegment) => {
|
|
3975
|
-
const
|
|
3976
|
-
const
|
|
3977
|
-
const
|
|
3978
|
-
const
|
|
3975
|
+
const transferCharacteristics = getTransferCharacteristicsSegment(colourSegment);
|
|
3976
|
+
const matrixCoefficients = getMatrixCoefficientsSegment(colourSegment);
|
|
3977
|
+
const primaries = getPrimariesSegment(colourSegment);
|
|
3978
|
+
const range = getRangeSegment(colourSegment);
|
|
3979
3979
|
return {
|
|
3980
|
-
transfer:
|
|
3981
|
-
matrix:
|
|
3982
|
-
primaries:
|
|
3983
|
-
fullRange:
|
|
3980
|
+
transfer: transferCharacteristics ? getTransferCharacteristicsFromIndex(transferCharacteristics.value.value) : null,
|
|
3981
|
+
matrix: matrixCoefficients ? getMatrixCoefficientsFromIndex(matrixCoefficients.value.value) : null,
|
|
3982
|
+
primaries: primaries ? getPrimariesFromIndex(primaries.value.value) : null,
|
|
3983
|
+
fullRange: transferCharacteristics?.value.value && matrixCoefficients?.value.value ? null : range ? Boolean(range?.value.value) : null
|
|
3984
3984
|
};
|
|
3985
3985
|
};
|
|
3986
3986
|
|
|
@@ -4050,8 +4050,8 @@ var getAudioDescription = (track) => {
|
|
|
4050
4050
|
};
|
|
4051
4051
|
|
|
4052
4052
|
// src/containers/webm/segments/track-entry.ts
|
|
4053
|
-
var trackTypeToString = (
|
|
4054
|
-
switch (
|
|
4053
|
+
var trackTypeToString = (trackType) => {
|
|
4054
|
+
switch (trackType) {
|
|
4055
4055
|
case 1:
|
|
4056
4056
|
return "video";
|
|
4057
4057
|
case 2:
|
|
@@ -4067,7 +4067,7 @@ var trackTypeToString = (trackType2) => {
|
|
|
4067
4067
|
case 7:
|
|
4068
4068
|
return "metadata";
|
|
4069
4069
|
default:
|
|
4070
|
-
throw new Error(`Unknown track type: ${
|
|
4070
|
+
throw new Error(`Unknown track type: ${trackType}`);
|
|
4071
4071
|
}
|
|
4072
4072
|
};
|
|
4073
4073
|
|
|
@@ -4159,17 +4159,17 @@ var getMatroskaAudioCodecEnum = ({
|
|
|
4159
4159
|
return "vorbis";
|
|
4160
4160
|
}
|
|
4161
4161
|
if (codec.value === "A_PCM/INT/LIT") {
|
|
4162
|
-
const
|
|
4163
|
-
if (
|
|
4162
|
+
const bitDepth = getBitDepth(track);
|
|
4163
|
+
if (bitDepth === null) {
|
|
4164
4164
|
throw new Error("Expected bit depth");
|
|
4165
4165
|
}
|
|
4166
|
-
if (
|
|
4166
|
+
if (bitDepth === 8) {
|
|
4167
4167
|
return "pcm-u8";
|
|
4168
4168
|
}
|
|
4169
|
-
if (
|
|
4169
|
+
if (bitDepth === 16) {
|
|
4170
4170
|
return "pcm-s16";
|
|
4171
4171
|
}
|
|
4172
|
-
if (
|
|
4172
|
+
if (bitDepth === 24) {
|
|
4173
4173
|
return "pcm-s24";
|
|
4174
4174
|
}
|
|
4175
4175
|
throw new Error("Unknown audio format");
|
|
@@ -4194,14 +4194,14 @@ var getMatroskaAudioCodecString = (track) => {
|
|
|
4194
4194
|
return "vorbis";
|
|
4195
4195
|
}
|
|
4196
4196
|
if (codec.value === "A_PCM/INT/LIT") {
|
|
4197
|
-
const
|
|
4198
|
-
if (
|
|
4197
|
+
const bitDepth = getBitDepth(track);
|
|
4198
|
+
if (bitDepth === null) {
|
|
4199
4199
|
throw new Error("Expected bit depth");
|
|
4200
4200
|
}
|
|
4201
|
-
if (
|
|
4201
|
+
if (bitDepth === 8) {
|
|
4202
4202
|
return "pcm-u8";
|
|
4203
4203
|
}
|
|
4204
|
-
return "pcm-s" +
|
|
4204
|
+
return "pcm-s" + bitDepth;
|
|
4205
4205
|
}
|
|
4206
4206
|
if (codec.value === "A_AAC") {
|
|
4207
4207
|
const priv = getPrivateData(track);
|
|
@@ -4225,12 +4225,12 @@ var getTrack = ({
|
|
|
4225
4225
|
timescale,
|
|
4226
4226
|
track
|
|
4227
4227
|
}) => {
|
|
4228
|
-
const
|
|
4229
|
-
if (!
|
|
4228
|
+
const trackType = getTrackTypeSegment(track);
|
|
4229
|
+
if (!trackType) {
|
|
4230
4230
|
throw new Error("Expected track type segment");
|
|
4231
4231
|
}
|
|
4232
4232
|
const trackId = getTrackId(track);
|
|
4233
|
-
if (trackTypeToString(
|
|
4233
|
+
if (trackTypeToString(trackType.value.value) === "video") {
|
|
4234
4234
|
const width = getWidthSegment(track);
|
|
4235
4235
|
if (width === null) {
|
|
4236
4236
|
throw new Error("Expected width segment");
|
|
@@ -4239,13 +4239,13 @@ var getTrack = ({
|
|
|
4239
4239
|
if (height === null) {
|
|
4240
4240
|
throw new Error("Expected height segment");
|
|
4241
4241
|
}
|
|
4242
|
-
const
|
|
4243
|
-
const
|
|
4242
|
+
const displayHeight = getDisplayHeightSegment(track);
|
|
4243
|
+
const displayWidth = getDisplayWidthSegment(track);
|
|
4244
4244
|
const codec = getCodecSegment(track);
|
|
4245
4245
|
if (!codec) {
|
|
4246
4246
|
return null;
|
|
4247
4247
|
}
|
|
4248
|
-
const
|
|
4248
|
+
const codecPrivate = getPrivateData(track);
|
|
4249
4249
|
const codecString = getMatroskaVideoCodecString({
|
|
4250
4250
|
track,
|
|
4251
4251
|
codecSegment: codec
|
|
@@ -4257,18 +4257,18 @@ var getTrack = ({
|
|
|
4257
4257
|
const codecEnum = getMatroskaVideoCodecEnum({
|
|
4258
4258
|
codecSegment: codec
|
|
4259
4259
|
});
|
|
4260
|
-
const codecData =
|
|
4260
|
+
const codecData = codecPrivate === null ? null : codecEnum === "h264" ? { type: "avc-sps-pps", data: codecPrivate } : codecEnum === "av1" ? {
|
|
4261
4261
|
type: "av1c-data",
|
|
4262
|
-
data:
|
|
4262
|
+
data: codecPrivate
|
|
4263
4263
|
} : codecEnum === "h265" ? {
|
|
4264
4264
|
type: "hvcc-data",
|
|
4265
|
-
data:
|
|
4265
|
+
data: codecPrivate
|
|
4266
4266
|
} : codecEnum === "vp8" ? {
|
|
4267
4267
|
type: "unknown-data",
|
|
4268
|
-
data:
|
|
4268
|
+
data: codecPrivate
|
|
4269
4269
|
} : codecEnum === "vp9" ? {
|
|
4270
4270
|
type: "unknown-data",
|
|
4271
|
-
data:
|
|
4271
|
+
data: codecPrivate
|
|
4272
4272
|
} : null;
|
|
4273
4273
|
const advancedColor = colour ? parseColorSegment(colour) : {
|
|
4274
4274
|
fullRange: null,
|
|
@@ -4282,8 +4282,8 @@ var getTrack = ({
|
|
|
4282
4282
|
trackId,
|
|
4283
4283
|
codec: codecString,
|
|
4284
4284
|
description: getDescription(track),
|
|
4285
|
-
height:
|
|
4286
|
-
width:
|
|
4285
|
+
height: displayHeight ? displayHeight.value.value : height.value.value,
|
|
4286
|
+
width: displayWidth ? displayWidth.value.value : width.value.value,
|
|
4287
4287
|
sampleAspectRatio: {
|
|
4288
4288
|
numerator: 1,
|
|
4289
4289
|
denominator: 1
|
|
@@ -4291,8 +4291,8 @@ var getTrack = ({
|
|
|
4291
4291
|
originalTimescale: timescale,
|
|
4292
4292
|
codedHeight: height.value.value,
|
|
4293
4293
|
codedWidth: width.value.value,
|
|
4294
|
-
displayAspectHeight:
|
|
4295
|
-
displayAspectWidth:
|
|
4294
|
+
displayAspectHeight: displayHeight ? displayHeight.value.value : height.value.value,
|
|
4295
|
+
displayAspectWidth: displayWidth ? displayWidth.value.value : width.value.value,
|
|
4296
4296
|
rotation: 0,
|
|
4297
4297
|
codecData,
|
|
4298
4298
|
colorSpace: mediaParserAdvancedColorToWebCodecsColor(advancedColor),
|
|
@@ -4304,10 +4304,10 @@ var getTrack = ({
|
|
|
4304
4304
|
trackMediaTimeOffsetInTrackTimescale: 0
|
|
4305
4305
|
};
|
|
4306
4306
|
}
|
|
4307
|
-
if (trackTypeToString(
|
|
4307
|
+
if (trackTypeToString(trackType.value.value) === "audio") {
|
|
4308
4308
|
const sampleRate = getSampleRate2(track);
|
|
4309
4309
|
const numberOfChannels = getNumberOfChannels(track);
|
|
4310
|
-
const
|
|
4310
|
+
const codecPrivate = getPrivateData(track);
|
|
4311
4311
|
if (sampleRate === null) {
|
|
4312
4312
|
throw new Error("Could not find sample rate or number of channels");
|
|
4313
4313
|
}
|
|
@@ -4320,7 +4320,7 @@ var getTrack = ({
|
|
|
4320
4320
|
numberOfChannels,
|
|
4321
4321
|
sampleRate,
|
|
4322
4322
|
description: getAudioDescription(track),
|
|
4323
|
-
codecData:
|
|
4323
|
+
codecData: codecPrivate ? codecString === "opus" ? { type: "ogg-identification", data: codecPrivate } : { type: "unknown-data", data: codecPrivate } : null,
|
|
4324
4324
|
codecEnum: getMatroskaAudioCodecEnum({
|
|
4325
4325
|
track
|
|
4326
4326
|
}),
|
|
@@ -4445,8 +4445,8 @@ var getCategorizedTracksFromMatroska = (state) => {
|
|
|
4445
4445
|
};
|
|
4446
4446
|
var getTracksFromMoovBox = (moovBox) => {
|
|
4447
4447
|
const mediaParserTracks = [];
|
|
4448
|
-
const
|
|
4449
|
-
for (const trakBox of
|
|
4448
|
+
const tracks = getTraks(moovBox);
|
|
4449
|
+
for (const trakBox of tracks) {
|
|
4450
4450
|
const mvhdBox = getMvhdBox(moovBox);
|
|
4451
4451
|
if (!mvhdBox) {
|
|
4452
4452
|
throw new Error("Mvhd box is not found");
|
|
@@ -4481,11 +4481,11 @@ var getTracksFromIsoBaseMedia = ({
|
|
|
4481
4481
|
return getTracksFromMoovBox(moovBox);
|
|
4482
4482
|
};
|
|
4483
4483
|
var defaultGetTracks = (parserState) => {
|
|
4484
|
-
const
|
|
4485
|
-
if (
|
|
4484
|
+
const tracks = parserState.callbacks.tracks.getTracks();
|
|
4485
|
+
if (tracks.length === 0) {
|
|
4486
4486
|
throw new Error("No tracks found");
|
|
4487
4487
|
}
|
|
4488
|
-
return
|
|
4488
|
+
return tracks;
|
|
4489
4489
|
};
|
|
4490
4490
|
var getTracks = (state, mayUsePrecomputed) => {
|
|
4491
4491
|
const structure = state.structure.getStructure();
|
|
@@ -4514,11 +4514,11 @@ var getTracks = (state, mayUsePrecomputed) => {
|
|
|
4514
4514
|
|
|
4515
4515
|
// src/get-audio-codec.ts
|
|
4516
4516
|
var getAudioCodec = (parserState) => {
|
|
4517
|
-
const
|
|
4518
|
-
if (
|
|
4517
|
+
const tracks = getTracks(parserState, true);
|
|
4518
|
+
if (tracks.length === 0) {
|
|
4519
4519
|
throw new Error("No tracks yet");
|
|
4520
4520
|
}
|
|
4521
|
-
const audioTrack =
|
|
4521
|
+
const audioTrack = tracks.find((t) => t.type === "audio");
|
|
4522
4522
|
if (!audioTrack) {
|
|
4523
4523
|
return null;
|
|
4524
4524
|
}
|
|
@@ -4797,11 +4797,11 @@ var getDimensions = (state) => {
|
|
|
4797
4797
|
if (structure && isAudioStructure(structure)) {
|
|
4798
4798
|
return null;
|
|
4799
4799
|
}
|
|
4800
|
-
const
|
|
4801
|
-
if (!
|
|
4800
|
+
const tracks = getTracks(state, true);
|
|
4801
|
+
if (!tracks.length) {
|
|
4802
4802
|
return null;
|
|
4803
4803
|
}
|
|
4804
|
-
const firstVideoTrack =
|
|
4804
|
+
const firstVideoTrack = tracks.find((t) => t.type === "video");
|
|
4805
4805
|
if (!firstVideoTrack) {
|
|
4806
4806
|
return null;
|
|
4807
4807
|
}
|
|
@@ -4870,8 +4870,8 @@ var getSamplesFromTraf = (trafSegment, moofOffset, trexBoxes) => {
|
|
|
4870
4870
|
}
|
|
4871
4871
|
for (const sample of trunBox.samples) {
|
|
4872
4872
|
i++;
|
|
4873
|
-
const
|
|
4874
|
-
if (
|
|
4873
|
+
const duration = sample.sampleDuration || defaultTrackSampleDuration;
|
|
4874
|
+
if (duration === null) {
|
|
4875
4875
|
throw new Error("Expected duration");
|
|
4876
4876
|
}
|
|
4877
4877
|
const size = sample.sampleSize ?? defaultTrackSampleSize;
|
|
@@ -4889,7 +4889,7 @@ var getSamplesFromTraf = (trafSegment, moofOffset, trexBoxes) => {
|
|
|
4889
4889
|
offset: offset + (moofOffset ?? 0) + (dataOffset ?? 0),
|
|
4890
4890
|
decodingTimestamp: dts,
|
|
4891
4891
|
timestamp: dts + (sample.sampleCompositionTimeOffset ?? 0),
|
|
4892
|
-
duration
|
|
4892
|
+
duration,
|
|
4893
4893
|
isKeyframe: keyframe,
|
|
4894
4894
|
size,
|
|
4895
4895
|
chunk: 0,
|
|
@@ -4898,7 +4898,7 @@ var getSamplesFromTraf = (trafSegment, moofOffset, trexBoxes) => {
|
|
|
4898
4898
|
};
|
|
4899
4899
|
samples.push(samplePosition);
|
|
4900
4900
|
offset += size;
|
|
4901
|
-
time +=
|
|
4901
|
+
time += duration;
|
|
4902
4902
|
}
|
|
4903
4903
|
}
|
|
4904
4904
|
return samples;
|
|
@@ -5166,11 +5166,11 @@ var getPlaylist = (structure, src) => {
|
|
|
5166
5166
|
return playlists;
|
|
5167
5167
|
};
|
|
5168
5168
|
var getDurationFromPlaylist = (playlist) => {
|
|
5169
|
-
const
|
|
5170
|
-
if (
|
|
5169
|
+
const duration = playlist.boxes.filter((box) => box.type === "m3u-extinf");
|
|
5170
|
+
if (duration.length === 0) {
|
|
5171
5171
|
throw new Error("Expected duration in m3u playlist");
|
|
5172
5172
|
}
|
|
5173
|
-
return
|
|
5173
|
+
return duration.reduce((acc, d) => acc + d.value, 0);
|
|
5174
5174
|
};
|
|
5175
5175
|
|
|
5176
5176
|
// src/containers/m3u/get-duration-from-m3u.ts
|
|
@@ -5188,19 +5188,19 @@ var getDurationFromM3u = (state) => {
|
|
|
5188
5188
|
var getUnroundedMpegFrameLength = ({
|
|
5189
5189
|
samplesPerFrame,
|
|
5190
5190
|
bitrateKbit,
|
|
5191
|
-
samplingFrequency
|
|
5191
|
+
samplingFrequency,
|
|
5192
5192
|
padding,
|
|
5193
5193
|
layer
|
|
5194
5194
|
}) => {
|
|
5195
5195
|
if (layer === 1) {
|
|
5196
5196
|
throw new Error("MPEG Layer I is not supported");
|
|
5197
5197
|
}
|
|
5198
|
-
return samplesPerFrame / 8 * bitrateKbit /
|
|
5198
|
+
return samplesPerFrame / 8 * bitrateKbit / samplingFrequency * 1000 + (padding ? layer === 1 ? 4 : 1 : 0);
|
|
5199
5199
|
};
|
|
5200
5200
|
var getAverageMpegFrameLength = ({
|
|
5201
5201
|
samplesPerFrame,
|
|
5202
5202
|
bitrateKbit,
|
|
5203
|
-
samplingFrequency
|
|
5203
|
+
samplingFrequency,
|
|
5204
5204
|
layer
|
|
5205
5205
|
}) => {
|
|
5206
5206
|
const withoutPadding = getUnroundedMpegFrameLength({
|
|
@@ -5208,7 +5208,7 @@ var getAverageMpegFrameLength = ({
|
|
|
5208
5208
|
layer,
|
|
5209
5209
|
padding: false,
|
|
5210
5210
|
samplesPerFrame,
|
|
5211
|
-
samplingFrequency
|
|
5211
|
+
samplingFrequency
|
|
5212
5212
|
});
|
|
5213
5213
|
const rounded = Math.floor(withoutPadding);
|
|
5214
5214
|
const rest = withoutPadding % 1;
|
|
@@ -5217,7 +5217,7 @@ var getAverageMpegFrameLength = ({
|
|
|
5217
5217
|
var getMpegFrameLength = ({
|
|
5218
5218
|
samplesPerFrame,
|
|
5219
5219
|
bitrateKbit,
|
|
5220
|
-
samplingFrequency
|
|
5220
|
+
samplingFrequency,
|
|
5221
5221
|
padding,
|
|
5222
5222
|
layer
|
|
5223
5223
|
}) => {
|
|
@@ -5226,7 +5226,7 @@ var getMpegFrameLength = ({
|
|
|
5226
5226
|
layer,
|
|
5227
5227
|
padding,
|
|
5228
5228
|
samplesPerFrame,
|
|
5229
|
-
samplingFrequency
|
|
5229
|
+
samplingFrequency
|
|
5230
5230
|
}));
|
|
5231
5231
|
};
|
|
5232
5232
|
|
|
@@ -5362,15 +5362,15 @@ var getDurationFromMatroska = (segments) => {
|
|
|
5362
5362
|
...mainSegment.value,
|
|
5363
5363
|
...infoSegment && infoSegment.type === "Info" ? infoSegment.value : []
|
|
5364
5364
|
];
|
|
5365
|
-
const
|
|
5366
|
-
if (!
|
|
5365
|
+
const timestampScale = relevantBoxes.find((s) => s.type === "TimestampScale");
|
|
5366
|
+
if (!timestampScale || timestampScale.type !== "TimestampScale") {
|
|
5367
5367
|
return null;
|
|
5368
5368
|
}
|
|
5369
|
-
const
|
|
5370
|
-
if (!
|
|
5369
|
+
const duration = relevantBoxes.find((s) => s.type === "Duration");
|
|
5370
|
+
if (!duration || duration.type !== "Duration") {
|
|
5371
5371
|
return null;
|
|
5372
5372
|
}
|
|
5373
|
-
return
|
|
5373
|
+
return duration.value.value / timestampScale.value.value * 1000;
|
|
5374
5374
|
};
|
|
5375
5375
|
var getDurationFromIsoBaseMedia = (parserState) => {
|
|
5376
5376
|
const structure = parserState.structure.getIsoStructure();
|
|
@@ -5402,8 +5402,8 @@ var getDurationFromIsoBaseMedia = (parserState) => {
|
|
|
5402
5402
|
if (mvhdBox.durationInSeconds > 0) {
|
|
5403
5403
|
return mvhdBox.durationInSeconds;
|
|
5404
5404
|
}
|
|
5405
|
-
const
|
|
5406
|
-
const allSamples =
|
|
5405
|
+
const tracks = getTracks(parserState, true);
|
|
5406
|
+
const allSamples = tracks.map((t) => {
|
|
5407
5407
|
const { originalTimescale: ts } = t;
|
|
5408
5408
|
const trakBox = getTrakBoxByTrackId(moovBox, t.trackId);
|
|
5409
5409
|
if (!trakBox) {
|
|
@@ -5484,8 +5484,8 @@ var isVideoTrackHdr = (track) => {
|
|
|
5484
5484
|
return track.advancedColor.matrix === "bt2020-ncl" && (track.advancedColor.transfer === "hlg" || track.advancedColor.transfer === "pq") && track.advancedColor.primaries === "bt2020";
|
|
5485
5485
|
};
|
|
5486
5486
|
var getIsHdr = (state) => {
|
|
5487
|
-
const
|
|
5488
|
-
return
|
|
5487
|
+
const tracks = getTracks(state, true);
|
|
5488
|
+
return tracks.some((track) => track.type === "video" && isVideoTrackHdr(track));
|
|
5489
5489
|
};
|
|
5490
5490
|
var hasHdr = (state) => {
|
|
5491
5491
|
return getHasTracks(state, true);
|
|
@@ -5493,13 +5493,13 @@ var hasHdr = (state) => {
|
|
|
5493
5493
|
|
|
5494
5494
|
// src/containers/iso-base-media/get-keyframes.ts
|
|
5495
5495
|
var getKeyframesFromIsoBaseMedia = (state) => {
|
|
5496
|
-
const
|
|
5496
|
+
const tracks = getTracksFromIsoBaseMedia({
|
|
5497
5497
|
isoState: state.iso,
|
|
5498
5498
|
m3uPlaylistContext: state.m3uPlaylistContext,
|
|
5499
5499
|
structure: state.structure,
|
|
5500
5500
|
mayUsePrecomputed: true
|
|
5501
5501
|
});
|
|
5502
|
-
const videoTracks =
|
|
5502
|
+
const videoTracks = tracks.filter((t) => t.type === "video");
|
|
5503
5503
|
const structure = state.structure.getIsoStructure();
|
|
5504
5504
|
const moofBoxes = getMoofBoxes(structure.boxes);
|
|
5505
5505
|
const tfraBoxes = getTfraBoxes(structure.boxes);
|
|
@@ -5717,8 +5717,8 @@ var getMetadataFromMatroska = (structure) => {
|
|
|
5717
5717
|
if (segment.type !== "Segment") {
|
|
5718
5718
|
continue;
|
|
5719
5719
|
}
|
|
5720
|
-
const
|
|
5721
|
-
for (const tag of
|
|
5720
|
+
const tags = segment.value.filter((s) => s.type === "Tags");
|
|
5721
|
+
for (const tag of tags) {
|
|
5722
5722
|
for (const child of tag.value) {
|
|
5723
5723
|
if (child.type !== "Tag") {
|
|
5724
5724
|
continue;
|
|
@@ -5776,8 +5776,8 @@ var getMetadata = (state) => {
|
|
|
5776
5776
|
return [];
|
|
5777
5777
|
}
|
|
5778
5778
|
if (structure.type === "mp3") {
|
|
5779
|
-
const
|
|
5780
|
-
return
|
|
5779
|
+
const tags = getMetadataFromMp3(structure);
|
|
5780
|
+
return tags ?? [];
|
|
5781
5781
|
}
|
|
5782
5782
|
if (structure.type === "wav") {
|
|
5783
5783
|
return getMetadataFromWav(structure) ?? [];
|
|
@@ -6143,13 +6143,13 @@ var getSeekingByteFromFragmentedMp4 = async ({
|
|
|
6143
6143
|
logLevel,
|
|
6144
6144
|
currentPosition,
|
|
6145
6145
|
isoState,
|
|
6146
|
-
tracks
|
|
6146
|
+
tracks,
|
|
6147
6147
|
isLastChunkInPlaylist,
|
|
6148
6148
|
structure,
|
|
6149
6149
|
mp4HeaderSegment
|
|
6150
6150
|
}) => {
|
|
6151
|
-
const firstVideoTrack =
|
|
6152
|
-
const firstTrack = firstVideoTrack ??
|
|
6151
|
+
const firstVideoTrack = tracks.find((t) => t.type === "video");
|
|
6152
|
+
const firstTrack = firstVideoTrack ?? tracks.find((t) => t.type === "audio");
|
|
6153
6153
|
if (!firstTrack) {
|
|
6154
6154
|
throw new Error("no video and no audio tracks");
|
|
6155
6155
|
}
|
|
@@ -6251,7 +6251,7 @@ var getSeekingByteFromIsoBaseMedia = ({
|
|
|
6251
6251
|
m3uPlaylistContext,
|
|
6252
6252
|
structure
|
|
6253
6253
|
}) => {
|
|
6254
|
-
const
|
|
6254
|
+
const tracks = getTracksFromIsoBaseMedia({
|
|
6255
6255
|
isoState,
|
|
6256
6256
|
m3uPlaylistContext,
|
|
6257
6257
|
structure,
|
|
@@ -6276,13 +6276,13 @@ var getSeekingByteFromIsoBaseMedia = ({
|
|
|
6276
6276
|
logLevel,
|
|
6277
6277
|
currentPosition,
|
|
6278
6278
|
isoState,
|
|
6279
|
-
tracks
|
|
6279
|
+
tracks,
|
|
6280
6280
|
isLastChunkInPlaylist: m3uPlaylistContext?.isLastChunkInPlaylist ?? false,
|
|
6281
6281
|
structure,
|
|
6282
6282
|
mp4HeaderSegment: m3uPlaylistContext?.mp4HeaderSegment ?? null
|
|
6283
6283
|
});
|
|
6284
6284
|
}
|
|
6285
|
-
const trackWithSamplePositions = findTrackToSeek(
|
|
6285
|
+
const trackWithSamplePositions = findTrackToSeek(tracks, structure);
|
|
6286
6286
|
if (!trackWithSamplePositions) {
|
|
6287
6287
|
return Promise.resolve({
|
|
6288
6288
|
type: "valid-but-must-wait"
|
|
@@ -6523,7 +6523,7 @@ var getSeekPointFromXing = ({
|
|
|
6523
6523
|
layer: mp3Info.layer,
|
|
6524
6524
|
mpegVersion: mp3Info.mpegVersion
|
|
6525
6525
|
});
|
|
6526
|
-
const
|
|
6526
|
+
const duration = getDurationFromMp3Xing({
|
|
6527
6527
|
xingData,
|
|
6528
6528
|
samplesPerFrame
|
|
6529
6529
|
});
|
|
@@ -6535,7 +6535,7 @@ var getSeekPointFromXing = ({
|
|
|
6535
6535
|
}
|
|
6536
6536
|
return getSeekPointInBytes({
|
|
6537
6537
|
fileSize: xingData.fileSize,
|
|
6538
|
-
percentBetween0And100: timeToTarget /
|
|
6538
|
+
percentBetween0And100: timeToTarget / duration * 100,
|
|
6539
6539
|
tableOfContents: xingData.tableOfContents
|
|
6540
6540
|
});
|
|
6541
6541
|
};
|
|
@@ -6698,16 +6698,16 @@ var registerVideoTrack = async ({
|
|
|
6698
6698
|
logLevel,
|
|
6699
6699
|
onVideoTrack,
|
|
6700
6700
|
registerVideoSampleCallback,
|
|
6701
|
-
tracks
|
|
6701
|
+
tracks
|
|
6702
6702
|
}) => {
|
|
6703
|
-
if (
|
|
6703
|
+
if (tracks.getTracks().find((t) => t.trackId === track.trackId)) {
|
|
6704
6704
|
Log.trace(logLevel, `Track ${track.trackId} already registered, skipping`);
|
|
6705
6705
|
return null;
|
|
6706
6706
|
}
|
|
6707
6707
|
if (track.type !== "video") {
|
|
6708
6708
|
throw new Error("Expected video track");
|
|
6709
6709
|
}
|
|
6710
|
-
|
|
6710
|
+
tracks.addTrack(track);
|
|
6711
6711
|
if (!onVideoTrack) {
|
|
6712
6712
|
return null;
|
|
6713
6713
|
}
|
|
@@ -6721,19 +6721,19 @@ var registerVideoTrack = async ({
|
|
|
6721
6721
|
var registerAudioTrack = async ({
|
|
6722
6722
|
track,
|
|
6723
6723
|
container,
|
|
6724
|
-
tracks
|
|
6724
|
+
tracks,
|
|
6725
6725
|
logLevel,
|
|
6726
6726
|
onAudioTrack,
|
|
6727
6727
|
registerAudioSampleCallback
|
|
6728
6728
|
}) => {
|
|
6729
|
-
if (
|
|
6729
|
+
if (tracks.getTracks().find((t) => t.trackId === track.trackId)) {
|
|
6730
6730
|
Log.trace(logLevel, `Track ${track.trackId} already registered, skipping`);
|
|
6731
6731
|
return null;
|
|
6732
6732
|
}
|
|
6733
6733
|
if (track.type !== "audio") {
|
|
6734
6734
|
throw new Error("Expected audio track");
|
|
6735
6735
|
}
|
|
6736
|
-
|
|
6736
|
+
tracks.addTrack(track);
|
|
6737
6737
|
if (!onAudioTrack) {
|
|
6738
6738
|
return null;
|
|
6739
6739
|
}
|
|
@@ -6783,12 +6783,12 @@ var getSampleAspectRatioFromSps = (sps) => {
|
|
|
6783
6783
|
};
|
|
6784
6784
|
};
|
|
6785
6785
|
var getVideoColorFromSps = (sps) => {
|
|
6786
|
-
const
|
|
6787
|
-
const
|
|
6786
|
+
const matrixCoefficients = sps.vui_parameters?.matrix_coefficients;
|
|
6787
|
+
const transferCharacteristics = sps.vui_parameters?.transfer_characteristics;
|
|
6788
6788
|
const colorPrimaries = sps.vui_parameters?.colour_primaries;
|
|
6789
6789
|
return {
|
|
6790
|
-
matrix:
|
|
6791
|
-
transfer:
|
|
6790
|
+
matrix: matrixCoefficients ? getMatrixCoefficientsFromIndex(matrixCoefficients) : null,
|
|
6791
|
+
transfer: transferCharacteristics ? getTransferCharacteristicsFromIndex(transferCharacteristics) : null,
|
|
6792
6792
|
primaries: colorPrimaries ? getPrimariesFromIndex(colorPrimaries) : null,
|
|
6793
6793
|
fullRange: sps.vui_parameters?.video_full_range_flag ?? null
|
|
6794
6794
|
};
|
|
@@ -7144,7 +7144,7 @@ var handleAvcPacket = async ({
|
|
|
7144
7144
|
trackId: programId,
|
|
7145
7145
|
newOffset: startOffset
|
|
7146
7146
|
});
|
|
7147
|
-
const
|
|
7147
|
+
const codecPrivate = createSpsPpsData(spsAndPps);
|
|
7148
7148
|
const advancedColor = getVideoColorFromSps(spsAndPps.sps.spsData);
|
|
7149
7149
|
const track = {
|
|
7150
7150
|
m3uStreamFormat: null,
|
|
@@ -7153,7 +7153,7 @@ var handleAvcPacket = async ({
|
|
|
7153
7153
|
type: "video",
|
|
7154
7154
|
originalTimescale: MPEG_TIMESCALE,
|
|
7155
7155
|
codec: getCodecStringFromSpsAndPps(spsAndPps.sps),
|
|
7156
|
-
codecData: { type: "avc-sps-pps", data:
|
|
7156
|
+
codecData: { type: "avc-sps-pps", data: codecPrivate },
|
|
7157
7157
|
fps: null,
|
|
7158
7158
|
codedWidth: dimensions.width,
|
|
7159
7159
|
codedHeight: dimensions.height,
|
|
@@ -7526,7 +7526,7 @@ var getSeekingHintsFromMp4 = ({
|
|
|
7526
7526
|
structureState,
|
|
7527
7527
|
isoState,
|
|
7528
7528
|
mp4HeaderSegment,
|
|
7529
|
-
mediaSectionState
|
|
7529
|
+
mediaSectionState
|
|
7530
7530
|
}) => {
|
|
7531
7531
|
const structure = structureState.getIsoStructure();
|
|
7532
7532
|
const moovAtom = getMoovBoxFromState({
|
|
@@ -7551,7 +7551,7 @@ var getSeekingHintsFromMp4 = ({
|
|
|
7551
7551
|
moovBox: moovAtom,
|
|
7552
7552
|
moofBoxes,
|
|
7553
7553
|
tfraBoxes,
|
|
7554
|
-
mediaSections:
|
|
7554
|
+
mediaSections: mediaSectionState.getMediaSections(),
|
|
7555
7555
|
mfraAlreadyLoaded: isoState.mfra.getIfAlreadyLoaded()
|
|
7556
7556
|
};
|
|
7557
7557
|
};
|
|
@@ -7568,7 +7568,7 @@ var getSeekingHintsForM3u = () => {
|
|
|
7568
7568
|
var getSeekingHintsForMp3 = ({
|
|
7569
7569
|
mp3State,
|
|
7570
7570
|
samplesObserved,
|
|
7571
|
-
mediaSectionState
|
|
7571
|
+
mediaSectionState,
|
|
7572
7572
|
contentLength
|
|
7573
7573
|
}) => {
|
|
7574
7574
|
return {
|
|
@@ -7577,7 +7577,7 @@ var getSeekingHintsForMp3 = ({
|
|
|
7577
7577
|
lastSampleObserved: samplesObserved.getLastSampleObserved(),
|
|
7578
7578
|
mp3BitrateInfo: mp3State.getMp3BitrateInfo(),
|
|
7579
7579
|
mp3Info: mp3State.getMp3Info(),
|
|
7580
|
-
mediaSection:
|
|
7580
|
+
mediaSection: mediaSectionState.getMediaSections()[0] ?? null,
|
|
7581
7581
|
contentLength
|
|
7582
7582
|
};
|
|
7583
7583
|
};
|
|
@@ -7597,7 +7597,7 @@ var riffHasIndex = (structure) => {
|
|
|
7597
7597
|
var getSeekingHintsForRiff = ({
|
|
7598
7598
|
structureState,
|
|
7599
7599
|
riffState,
|
|
7600
|
-
mediaSectionState
|
|
7600
|
+
mediaSectionState
|
|
7601
7601
|
}) => {
|
|
7602
7602
|
const structure = structureState.getRiffStructure();
|
|
7603
7603
|
const strl = getStrlBoxes(structure);
|
|
@@ -7618,7 +7618,7 @@ var getSeekingHintsForRiff = ({
|
|
|
7618
7618
|
hasIndex: riffHasIndex(structure),
|
|
7619
7619
|
idx1Entries: riffState.lazyIdx1.getIfAlreadyLoaded(),
|
|
7620
7620
|
samplesPerSecond,
|
|
7621
|
-
moviOffset:
|
|
7621
|
+
moviOffset: mediaSectionState.getMediaSections()[0]?.start ?? null,
|
|
7622
7622
|
observedKeyframes: riffState.sampleCounter.riffKeys.getKeyframes()
|
|
7623
7623
|
};
|
|
7624
7624
|
};
|
|
@@ -7657,13 +7657,13 @@ var setSeekingHintsForTransportStream = ({
|
|
|
7657
7657
|
// src/containers/wav/seeking-hints.ts
|
|
7658
7658
|
var getSeekingHintsFromWav = ({
|
|
7659
7659
|
structure,
|
|
7660
|
-
mediaSectionState
|
|
7660
|
+
mediaSectionState
|
|
7661
7661
|
}) => {
|
|
7662
7662
|
const fmtBox = structure.boxes.find((box) => box.type === "wav-fmt");
|
|
7663
7663
|
if (!fmtBox) {
|
|
7664
7664
|
return null;
|
|
7665
7665
|
}
|
|
7666
|
-
const mediaSection =
|
|
7666
|
+
const mediaSection = mediaSectionState.getMediaSections();
|
|
7667
7667
|
if (mediaSection.length !== 1) {
|
|
7668
7668
|
return null;
|
|
7669
7669
|
}
|
|
@@ -7683,8 +7683,8 @@ var setSeekingHintsForWav = ({
|
|
|
7683
7683
|
|
|
7684
7684
|
// src/containers/webm/seek/seeking-hints.ts
|
|
7685
7685
|
var getSeekingHintsFromMatroska = (tracksState, keyframesState, webmState) => {
|
|
7686
|
-
const
|
|
7687
|
-
const firstVideoTrack =
|
|
7686
|
+
const tracks = tracksState.getTracks();
|
|
7687
|
+
const firstVideoTrack = tracks.find((track) => track.type === "video");
|
|
7688
7688
|
const keyframes = keyframesState.getKeyframes();
|
|
7689
7689
|
const loadedCues = webmState.cues.getIfAlreadyLoaded();
|
|
7690
7690
|
return {
|
|
@@ -7711,7 +7711,7 @@ var setSeekingHintsForWebm = ({
|
|
|
7711
7711
|
var getSeekingHints = ({
|
|
7712
7712
|
structureState,
|
|
7713
7713
|
m3uPlaylistContext,
|
|
7714
|
-
mediaSectionState
|
|
7714
|
+
mediaSectionState,
|
|
7715
7715
|
isoState,
|
|
7716
7716
|
transportStream,
|
|
7717
7717
|
tracksState,
|
|
@@ -7733,13 +7733,13 @@ var getSeekingHints = ({
|
|
|
7733
7733
|
structureState,
|
|
7734
7734
|
isoState,
|
|
7735
7735
|
mp4HeaderSegment: m3uPlaylistContext?.mp4HeaderSegment ?? null,
|
|
7736
|
-
mediaSectionState
|
|
7736
|
+
mediaSectionState
|
|
7737
7737
|
});
|
|
7738
7738
|
}
|
|
7739
7739
|
if (structure.type === "wav") {
|
|
7740
7740
|
return getSeekingHintsFromWav({
|
|
7741
7741
|
structure,
|
|
7742
|
-
mediaSectionState
|
|
7742
|
+
mediaSectionState
|
|
7743
7743
|
});
|
|
7744
7744
|
}
|
|
7745
7745
|
if (structure.type === "matroska") {
|
|
@@ -7758,14 +7758,14 @@ var getSeekingHints = ({
|
|
|
7758
7758
|
return getSeekingHintsForRiff({
|
|
7759
7759
|
structureState,
|
|
7760
7760
|
riffState,
|
|
7761
|
-
mediaSectionState
|
|
7761
|
+
mediaSectionState
|
|
7762
7762
|
});
|
|
7763
7763
|
}
|
|
7764
7764
|
if (structure.type === "mp3") {
|
|
7765
7765
|
return getSeekingHintsForMp3({
|
|
7766
7766
|
mp3State,
|
|
7767
7767
|
samplesObserved,
|
|
7768
|
-
mediaSectionState
|
|
7768
|
+
mediaSectionState,
|
|
7769
7769
|
contentLength
|
|
7770
7770
|
});
|
|
7771
7771
|
}
|
|
@@ -8010,8 +8010,8 @@ var performSeek = async ({
|
|
|
8010
8010
|
|
|
8011
8011
|
// src/work-on-seek-request.ts
|
|
8012
8012
|
var turnSeekIntoByte = async ({
|
|
8013
|
-
seek
|
|
8014
|
-
mediaSectionState
|
|
8013
|
+
seek,
|
|
8014
|
+
mediaSectionState,
|
|
8015
8015
|
logLevel,
|
|
8016
8016
|
iterator,
|
|
8017
8017
|
structureState,
|
|
@@ -8030,21 +8030,21 @@ var turnSeekIntoByte = async ({
|
|
|
8030
8030
|
m3uState,
|
|
8031
8031
|
avcState
|
|
8032
8032
|
}) => {
|
|
8033
|
-
const mediaSections =
|
|
8033
|
+
const mediaSections = mediaSectionState.getMediaSections();
|
|
8034
8034
|
if (mediaSections.length === 0) {
|
|
8035
8035
|
Log.trace(logLevel, "No media sections defined, cannot seek yet");
|
|
8036
8036
|
return {
|
|
8037
8037
|
type: "valid-but-must-wait"
|
|
8038
8038
|
};
|
|
8039
8039
|
}
|
|
8040
|
-
if (
|
|
8041
|
-
throw new Error(`Cannot seek to a negative time: ${JSON.stringify(
|
|
8040
|
+
if (seek < 0) {
|
|
8041
|
+
throw new Error(`Cannot seek to a negative time: ${JSON.stringify(seek)}`);
|
|
8042
8042
|
}
|
|
8043
8043
|
const seekingHints = getSeekingHints({
|
|
8044
8044
|
riffState,
|
|
8045
8045
|
samplesObserved,
|
|
8046
8046
|
structureState,
|
|
8047
|
-
mediaSectionState
|
|
8047
|
+
mediaSectionState,
|
|
8048
8048
|
isoState,
|
|
8049
8049
|
transportStream,
|
|
8050
8050
|
tracksState,
|
|
@@ -8064,13 +8064,13 @@ var turnSeekIntoByte = async ({
|
|
|
8064
8064
|
}
|
|
8065
8065
|
const seekingByte = await getSeekingByte({
|
|
8066
8066
|
info: seekingHints,
|
|
8067
|
-
time:
|
|
8067
|
+
time: seek,
|
|
8068
8068
|
logLevel,
|
|
8069
8069
|
currentPosition: iterator.counter.getOffset(),
|
|
8070
8070
|
isoState,
|
|
8071
8071
|
transportStream,
|
|
8072
8072
|
webmState,
|
|
8073
|
-
mediaSection:
|
|
8073
|
+
mediaSection: mediaSectionState,
|
|
8074
8074
|
m3uPlaylistContext,
|
|
8075
8075
|
structure: structureState,
|
|
8076
8076
|
riffState,
|
|
@@ -8140,13 +8140,13 @@ var workOnSeekRequest = async (options) => {
|
|
|
8140
8140
|
m3uState,
|
|
8141
8141
|
avcState
|
|
8142
8142
|
} = options;
|
|
8143
|
-
const
|
|
8144
|
-
if (
|
|
8143
|
+
const seek = controller._internals.seekSignal.getSeek();
|
|
8144
|
+
if (seek === null) {
|
|
8145
8145
|
return;
|
|
8146
8146
|
}
|
|
8147
|
-
Log.trace(logLevel, `Has seek request for ${src}: ${JSON.stringify(
|
|
8147
|
+
Log.trace(logLevel, `Has seek request for ${src}: ${JSON.stringify(seek)}`);
|
|
8148
8148
|
const resolution = await turnSeekIntoByte({
|
|
8149
|
-
seek
|
|
8149
|
+
seek,
|
|
8150
8150
|
mediaSectionState: mediaSection,
|
|
8151
8151
|
logLevel,
|
|
8152
8152
|
iterator,
|
|
@@ -8207,7 +8207,7 @@ var workOnSeekRequest = async (options) => {
|
|
|
8207
8207
|
prefetchCache,
|
|
8208
8208
|
isoState
|
|
8209
8209
|
});
|
|
8210
|
-
const { hasChanged } = controller._internals.seekSignal.clearSeekIfStillSame(
|
|
8210
|
+
const { hasChanged } = controller._internals.seekSignal.clearSeekIfStillSame(seek);
|
|
8211
8211
|
if (hasChanged) {
|
|
8212
8212
|
Log.trace(logLevel, `Seek request has changed while seeking, seeking again`);
|
|
8213
8213
|
await workOnSeekRequest(options);
|
|
@@ -8215,7 +8215,7 @@ var workOnSeekRequest = async (options) => {
|
|
|
8215
8215
|
return;
|
|
8216
8216
|
}
|
|
8217
8217
|
if (resolution.type === "invalid") {
|
|
8218
|
-
throw new Error(`The seek request ${JSON.stringify(
|
|
8218
|
+
throw new Error(`The seek request ${JSON.stringify(seek)} cannot be processed`);
|
|
8219
8219
|
}
|
|
8220
8220
|
if (resolution.type === "valid-but-must-wait") {
|
|
8221
8221
|
Log.trace(logLevel, "Seek request is valid but cannot be processed yet");
|
|
@@ -8371,10 +8371,10 @@ var emitAvailableInfo = async ({
|
|
|
8371
8371
|
}
|
|
8372
8372
|
if (key === "tracks") {
|
|
8373
8373
|
if (!emittedFields.tracks && hasInfo.tracks) {
|
|
8374
|
-
const
|
|
8375
|
-
await callbackFunctions.onTracks?.(
|
|
8374
|
+
const tracks = getTracks(state, true);
|
|
8375
|
+
await callbackFunctions.onTracks?.(tracks);
|
|
8376
8376
|
if (fieldsInReturnValue.tracks) {
|
|
8377
|
-
returnValue.tracks =
|
|
8377
|
+
returnValue.tracks = tracks;
|
|
8378
8378
|
}
|
|
8379
8379
|
emittedFields.tracks = true;
|
|
8380
8380
|
}
|
|
@@ -8792,7 +8792,7 @@ var parseAac = async (state) => {
|
|
|
8792
8792
|
const sampleRate = getSampleRateFromSampleFrequencyIndex(samplingFrequencyIndex);
|
|
8793
8793
|
iterator.getBits(1);
|
|
8794
8794
|
const channelConfiguration = iterator.getBits(3);
|
|
8795
|
-
const
|
|
8795
|
+
const codecPrivate = createAacCodecPrivate({
|
|
8796
8796
|
audioObjectType,
|
|
8797
8797
|
sampleRate,
|
|
8798
8798
|
channelConfiguration,
|
|
@@ -8821,8 +8821,8 @@ var parseAac = async (state) => {
|
|
|
8821
8821
|
track: {
|
|
8822
8822
|
codec: mapAudioObjectTypeToCodecString(audioObjectType),
|
|
8823
8823
|
codecEnum: "aac",
|
|
8824
|
-
codecData: { type: "aac-config", data:
|
|
8825
|
-
description:
|
|
8824
|
+
codecData: { type: "aac-config", data: codecPrivate },
|
|
8825
|
+
description: codecPrivate,
|
|
8826
8826
|
numberOfChannels: channelConfiguration,
|
|
8827
8827
|
sampleRate,
|
|
8828
8828
|
originalTimescale: WEBCODECS_TIMESCALE,
|
|
@@ -8839,17 +8839,17 @@ var parseAac = async (state) => {
|
|
|
8839
8839
|
});
|
|
8840
8840
|
state.callbacks.tracks.setIsDone(state.logLevel);
|
|
8841
8841
|
}
|
|
8842
|
-
const
|
|
8842
|
+
const duration = 1024 / sampleRate;
|
|
8843
8843
|
const { index } = state.aac.addSample({ offset: startOffset, size: frameLength });
|
|
8844
8844
|
const timestamp = 1024 / sampleRate * index;
|
|
8845
8845
|
state.aac.audioSamples.addSample({
|
|
8846
8846
|
timeInSeconds: timestamp,
|
|
8847
8847
|
offset: startOffset,
|
|
8848
|
-
durationInSeconds:
|
|
8848
|
+
durationInSeconds: duration
|
|
8849
8849
|
});
|
|
8850
8850
|
const audioSample = convertAudioOrVideoSampleToWebCodecsTimestamps({
|
|
8851
8851
|
sample: {
|
|
8852
|
-
duration
|
|
8852
|
+
duration,
|
|
8853
8853
|
type: "key",
|
|
8854
8854
|
data,
|
|
8855
8855
|
offset: startOffset,
|
|
@@ -9055,7 +9055,7 @@ var emitSample = async ({
|
|
|
9055
9055
|
throw new Error("Invalid CRC");
|
|
9056
9056
|
}
|
|
9057
9057
|
const { blockSize, num, sampleRate } = parsed;
|
|
9058
|
-
const
|
|
9058
|
+
const duration = blockSize / sampleRate;
|
|
9059
9059
|
const structure = state.structure.getFlacStructure();
|
|
9060
9060
|
const streamInfo = structure.boxes.find((box) => box.type === "flac-streaminfo");
|
|
9061
9061
|
if (!streamInfo) {
|
|
@@ -9068,12 +9068,12 @@ var emitSample = async ({
|
|
|
9068
9068
|
state.flac.audioSamples.addSample({
|
|
9069
9069
|
timeInSeconds: timestamp,
|
|
9070
9070
|
offset,
|
|
9071
|
-
durationInSeconds:
|
|
9071
|
+
durationInSeconds: duration
|
|
9072
9072
|
});
|
|
9073
9073
|
const audioSample = convertAudioOrVideoSampleToWebCodecsTimestamps({
|
|
9074
9074
|
sample: {
|
|
9075
9075
|
data,
|
|
9076
|
-
duration
|
|
9076
|
+
duration,
|
|
9077
9077
|
decodingTimestamp: timestamp,
|
|
9078
9078
|
timestamp,
|
|
9079
9079
|
type: "key",
|
|
@@ -9209,7 +9209,7 @@ var parseStreamInfo = async ({
|
|
|
9209
9209
|
const maximumFrameSize = iterator.getUint24();
|
|
9210
9210
|
iterator.startReadingBits();
|
|
9211
9211
|
const sampleRate = iterator.getBits(20);
|
|
9212
|
-
const
|
|
9212
|
+
const channels = iterator.getBits(3) + 1;
|
|
9213
9213
|
const bitsPerSample = iterator.getBits(5);
|
|
9214
9214
|
const totalSamples = iterator.getBits(36);
|
|
9215
9215
|
iterator.getBits(128);
|
|
@@ -9221,7 +9221,7 @@ var parseStreamInfo = async ({
|
|
|
9221
9221
|
const flacStreamInfo = {
|
|
9222
9222
|
type: "flac-streaminfo",
|
|
9223
9223
|
bitsPerSample,
|
|
9224
|
-
channels
|
|
9224
|
+
channels,
|
|
9225
9225
|
maximumBlockSize,
|
|
9226
9226
|
maximumFrameSize,
|
|
9227
9227
|
minimumBlockSize,
|
|
@@ -9238,7 +9238,7 @@ var parseStreamInfo = async ({
|
|
|
9238
9238
|
description: asUint8Array,
|
|
9239
9239
|
codecData: { type: "flac-description", data: asUint8Array },
|
|
9240
9240
|
codecEnum: "flac",
|
|
9241
|
-
numberOfChannels:
|
|
9241
|
+
numberOfChannels: channels,
|
|
9242
9242
|
sampleRate,
|
|
9243
9243
|
originalTimescale: WEBCODECS_TIMESCALE,
|
|
9244
9244
|
trackId: 0,
|
|
@@ -9302,8 +9302,8 @@ var parseFlac = ({
|
|
|
9302
9302
|
iterator,
|
|
9303
9303
|
state
|
|
9304
9304
|
}) => {
|
|
9305
|
-
const
|
|
9306
|
-
if (
|
|
9305
|
+
const mediaSectionState = state.mediaSection.isCurrentByteInMediaSection(iterator);
|
|
9306
|
+
if (mediaSectionState === "in-section") {
|
|
9307
9307
|
if (maySkipVideoData({ state })) {
|
|
9308
9308
|
return Promise.resolve(makeSkip(state.contentLength));
|
|
9309
9309
|
}
|
|
@@ -9326,7 +9326,7 @@ var calculateSamplePositions = ({
|
|
|
9326
9326
|
mediaSectionStart,
|
|
9327
9327
|
trackIds
|
|
9328
9328
|
}) => {
|
|
9329
|
-
const
|
|
9329
|
+
const tracks = getTracks(state, true);
|
|
9330
9330
|
const moofBoxes = getMoofBoxes(state.structure.getIsoStructure().boxes);
|
|
9331
9331
|
const tfraBoxes = deduplicateTfraBoxesByOffset([
|
|
9332
9332
|
...state.iso.tfra.getTfraBoxes(),
|
|
@@ -9347,7 +9347,7 @@ var calculateSamplePositions = ({
|
|
|
9347
9347
|
throw new Error("No moov box found");
|
|
9348
9348
|
}
|
|
9349
9349
|
const trackIdAndSamplePositions = [];
|
|
9350
|
-
for (const track of
|
|
9350
|
+
for (const track of tracks) {
|
|
9351
9351
|
const trakBox = getTrakBoxByTrackId(moov, track.trackId);
|
|
9352
9352
|
if (!trackIds.includes(track.trackId)) {
|
|
9353
9353
|
Log.verbose(state.logLevel, "Skipping calculating sample positions for track", track.trackId);
|
|
@@ -9516,7 +9516,7 @@ var makeCanSkipTracksState = ({
|
|
|
9516
9516
|
|
|
9517
9517
|
// src/state/has-tracks-section.ts
|
|
9518
9518
|
var makeTracksSectionState = (canSkipTracksState, src) => {
|
|
9519
|
-
const
|
|
9519
|
+
const tracks = [];
|
|
9520
9520
|
let doneWithTracks = false;
|
|
9521
9521
|
return {
|
|
9522
9522
|
hasAllTracks: () => doneWithTracks,
|
|
@@ -9529,10 +9529,10 @@ var makeTracksSectionState = (canSkipTracksState, src) => {
|
|
|
9529
9529
|
doneWithTracks = true;
|
|
9530
9530
|
},
|
|
9531
9531
|
addTrack: (track) => {
|
|
9532
|
-
|
|
9532
|
+
tracks.push(track);
|
|
9533
9533
|
},
|
|
9534
9534
|
getTracks: () => {
|
|
9535
|
-
return
|
|
9535
|
+
return tracks;
|
|
9536
9536
|
},
|
|
9537
9537
|
ensureHasTracksAtEnd: (fields) => {
|
|
9538
9538
|
if (canSkipTracksState.canSkipTracks()) {
|
|
@@ -9857,8 +9857,8 @@ var parseMdhd = ({
|
|
|
9857
9857
|
const creationTime = version === 1 ? Number(data.getUint64()) : data.getUint32();
|
|
9858
9858
|
const modificationTime = version === 1 ? Number(data.getUint64()) : data.getUint32();
|
|
9859
9859
|
const timescale = data.getUint32();
|
|
9860
|
-
const
|
|
9861
|
-
const
|
|
9860
|
+
const duration = version === 1 ? data.getUint64() : data.getUint32();
|
|
9861
|
+
const language = data.getUint16();
|
|
9862
9862
|
const quality = data.getUint16();
|
|
9863
9863
|
const remaining = size - (data.counter.getOffset() - fileOffset);
|
|
9864
9864
|
if (remaining !== 0) {
|
|
@@ -9866,10 +9866,10 @@ var parseMdhd = ({
|
|
|
9866
9866
|
}
|
|
9867
9867
|
return {
|
|
9868
9868
|
type: "mdhd-box",
|
|
9869
|
-
duration: Number(
|
|
9869
|
+
duration: Number(duration),
|
|
9870
9870
|
timescale,
|
|
9871
9871
|
version,
|
|
9872
|
-
language
|
|
9872
|
+
language,
|
|
9873
9873
|
quality,
|
|
9874
9874
|
creationTime,
|
|
9875
9875
|
modificationTime
|
|
@@ -10376,7 +10376,7 @@ var parseColorParameterBox = ({
|
|
|
10376
10376
|
}) => {
|
|
10377
10377
|
const byteString = iterator.getByteString(4, false);
|
|
10378
10378
|
if (byteString === "nclx") {
|
|
10379
|
-
const
|
|
10379
|
+
const primaries = iterator.getUint16();
|
|
10380
10380
|
const transfer = iterator.getUint16();
|
|
10381
10381
|
const matrixIndex = iterator.getUint16();
|
|
10382
10382
|
iterator.startReadingBits();
|
|
@@ -10387,12 +10387,12 @@ var parseColorParameterBox = ({
|
|
|
10387
10387
|
colorType: "transfer-characteristics",
|
|
10388
10388
|
fullRangeFlag,
|
|
10389
10389
|
matrixIndex,
|
|
10390
|
-
primaries
|
|
10390
|
+
primaries,
|
|
10391
10391
|
transfer
|
|
10392
10392
|
};
|
|
10393
10393
|
}
|
|
10394
10394
|
if (byteString === "nclc") {
|
|
10395
|
-
const
|
|
10395
|
+
const primaries = iterator.getUint16();
|
|
10396
10396
|
const transfer = iterator.getUint16();
|
|
10397
10397
|
const matrixIndex = iterator.getUint16();
|
|
10398
10398
|
return {
|
|
@@ -10400,7 +10400,7 @@ var parseColorParameterBox = ({
|
|
|
10400
10400
|
colorType: "transfer-characteristics",
|
|
10401
10401
|
fullRangeFlag: false,
|
|
10402
10402
|
matrixIndex,
|
|
10403
|
-
primaries
|
|
10403
|
+
primaries,
|
|
10404
10404
|
transfer
|
|
10405
10405
|
};
|
|
10406
10406
|
}
|
|
@@ -11047,9 +11047,9 @@ var parseStts = ({
|
|
|
11047
11047
|
var getvp09ConfigurationString = ({
|
|
11048
11048
|
profile,
|
|
11049
11049
|
level,
|
|
11050
|
-
bitDepth
|
|
11050
|
+
bitDepth
|
|
11051
11051
|
}) => {
|
|
11052
|
-
return `${String(profile).padStart(2, "0")}.${String(level).padStart(2, "0")}.${String(
|
|
11052
|
+
return `${String(profile).padStart(2, "0")}.${String(level).padStart(2, "0")}.${String(bitDepth).padStart(2, "0")}`;
|
|
11053
11053
|
};
|
|
11054
11054
|
var parseVpcc = ({
|
|
11055
11055
|
data,
|
|
@@ -11064,7 +11064,7 @@ var parseVpcc = ({
|
|
|
11064
11064
|
const profile = data.getUint8();
|
|
11065
11065
|
const level = data.getUint8();
|
|
11066
11066
|
data.startReadingBits();
|
|
11067
|
-
const
|
|
11067
|
+
const bitDepth = data.getBits(4);
|
|
11068
11068
|
const chromaSubsampling = data.getBits(3);
|
|
11069
11069
|
const videoFullRangeFlag = data.getBits(1);
|
|
11070
11070
|
const videoColorPrimaries = data.getBits(8);
|
|
@@ -11078,7 +11078,7 @@ var parseVpcc = ({
|
|
|
11078
11078
|
type: "vpcc-box",
|
|
11079
11079
|
profile,
|
|
11080
11080
|
level,
|
|
11081
|
-
bitDepth
|
|
11081
|
+
bitDepth,
|
|
11082
11082
|
chromaSubsampling,
|
|
11083
11083
|
videoFullRangeFlag,
|
|
11084
11084
|
videoColorPrimaries,
|
|
@@ -11086,7 +11086,7 @@ var parseVpcc = ({
|
|
|
11086
11086
|
videoMatrixCoefficients,
|
|
11087
11087
|
codecInitializationDataSize,
|
|
11088
11088
|
codecInitializationData,
|
|
11089
|
-
codecString: getvp09ConfigurationString({ profile, level, bitDepth
|
|
11089
|
+
codecString: getvp09ConfigurationString({ profile, level, bitDepth })
|
|
11090
11090
|
};
|
|
11091
11091
|
};
|
|
11092
11092
|
|
|
@@ -11182,7 +11182,7 @@ var parseTkhd = ({
|
|
|
11182
11182
|
const modificationTime = version === 1 ? iterator.getUint64() : iterator.getUint32();
|
|
11183
11183
|
const trackId = iterator.getUint32();
|
|
11184
11184
|
iterator.discard(4);
|
|
11185
|
-
const
|
|
11185
|
+
const duration = version === 1 ? iterator.getUint64() : iterator.getUint32();
|
|
11186
11186
|
iterator.discard(4);
|
|
11187
11187
|
iterator.discard(4);
|
|
11188
11188
|
const layer = iterator.getUint16();
|
|
@@ -11216,7 +11216,7 @@ var parseTkhd = ({
|
|
|
11216
11216
|
creationTime: toUnixTimestamp(Number(creationTime)),
|
|
11217
11217
|
modificationTime: toUnixTimestamp(Number(modificationTime)),
|
|
11218
11218
|
trackId,
|
|
11219
|
-
duration: Number(
|
|
11219
|
+
duration: Number(duration),
|
|
11220
11220
|
layer,
|
|
11221
11221
|
alternateGroup,
|
|
11222
11222
|
volume,
|
|
@@ -11330,8 +11330,8 @@ var processBox = async ({
|
|
|
11330
11330
|
if (!onlyIfMdatAtomExpected) {
|
|
11331
11331
|
return { type: "nothing" };
|
|
11332
11332
|
}
|
|
11333
|
-
const { mediaSectionState
|
|
11334
|
-
|
|
11333
|
+
const { mediaSectionState } = onlyIfMdatAtomExpected;
|
|
11334
|
+
mediaSectionState.addMediaSection({
|
|
11335
11335
|
size: boxSize - headerLength,
|
|
11336
11336
|
start: iterator.counter.getOffset()
|
|
11337
11337
|
});
|
|
@@ -11523,8 +11523,8 @@ var processBox = async ({
|
|
|
11523
11523
|
if (!onlyIfMoovAtomExpected) {
|
|
11524
11524
|
throw new Error("State is required");
|
|
11525
11525
|
}
|
|
11526
|
-
const { tracks
|
|
11527
|
-
if (
|
|
11526
|
+
const { tracks, isoState } = onlyIfMoovAtomExpected;
|
|
11527
|
+
if (tracks.hasAllTracks()) {
|
|
11528
11528
|
iterator.discard(boxSize - 8);
|
|
11529
11529
|
return { type: "nothing" };
|
|
11530
11530
|
}
|
|
@@ -11541,14 +11541,14 @@ var processBox = async ({
|
|
|
11541
11541
|
logLevel,
|
|
11542
11542
|
contentLength
|
|
11543
11543
|
});
|
|
11544
|
-
|
|
11544
|
+
tracks.setIsDone(logLevel);
|
|
11545
11545
|
return { type: "box", box };
|
|
11546
11546
|
}
|
|
11547
11547
|
if (boxType === "trak") {
|
|
11548
11548
|
if (!onlyIfMoovAtomExpected) {
|
|
11549
11549
|
throw new Error("State is required");
|
|
11550
11550
|
}
|
|
11551
|
-
const { tracks
|
|
11551
|
+
const { tracks, onAudioTrack, onVideoTrack } = onlyIfMoovAtomExpected;
|
|
11552
11552
|
const trakBox = await parseTrak({
|
|
11553
11553
|
size: boxSize,
|
|
11554
11554
|
offsetAtStart: fileOffset,
|
|
@@ -11569,7 +11569,7 @@ var processBox = async ({
|
|
|
11569
11569
|
logLevel,
|
|
11570
11570
|
onVideoTrack,
|
|
11571
11571
|
registerVideoSampleCallback: onlyIfMoovAtomExpected.registerVideoSampleCallback,
|
|
11572
|
-
tracks
|
|
11572
|
+
tracks
|
|
11573
11573
|
});
|
|
11574
11574
|
}
|
|
11575
11575
|
if (transformedTrack && transformedTrack.type === "audio") {
|
|
@@ -11577,7 +11577,7 @@ var processBox = async ({
|
|
|
11577
11577
|
track: transformedTrack,
|
|
11578
11578
|
container: "mp4",
|
|
11579
11579
|
registerAudioSampleCallback: onlyIfMoovAtomExpected.registerAudioSampleCallback,
|
|
11580
|
-
tracks
|
|
11580
|
+
tracks,
|
|
11581
11581
|
logLevel,
|
|
11582
11582
|
onAudioTrack
|
|
11583
11583
|
});
|
|
@@ -11879,12 +11879,12 @@ var parseMdatSection = async (state) => {
|
|
|
11879
11879
|
state.structure.getIsoStructure().boxes.push(moov);
|
|
11880
11880
|
return parseMdatSection(state);
|
|
11881
11881
|
}
|
|
11882
|
-
const
|
|
11882
|
+
const tracks = state.callbacks.tracks.getTracks();
|
|
11883
11883
|
if (!state.iso.flatSamples.getSamples(mediaSection.start)) {
|
|
11884
11884
|
const samplePosition = calculateSamplePositions({
|
|
11885
11885
|
state,
|
|
11886
11886
|
mediaSectionStart: mediaSection.start,
|
|
11887
|
-
trackIds:
|
|
11887
|
+
trackIds: tracks.map((t) => t.trackId)
|
|
11888
11888
|
});
|
|
11889
11889
|
state.iso.flatSamples.setSamples(mediaSection.start, samplePosition);
|
|
11890
11890
|
}
|
|
@@ -11911,13 +11911,13 @@ var parseMdatSection = async (state) => {
|
|
|
11911
11911
|
const {
|
|
11912
11912
|
timestamp: rawCts,
|
|
11913
11913
|
decodingTimestamp: rawDts,
|
|
11914
|
-
duration
|
|
11914
|
+
duration,
|
|
11915
11915
|
isKeyframe,
|
|
11916
11916
|
offset,
|
|
11917
11917
|
bigEndian,
|
|
11918
11918
|
chunkSize
|
|
11919
11919
|
} = nextSample.samplePosition;
|
|
11920
|
-
const track =
|
|
11920
|
+
const track = tracks.find((t) => t.trackId === nextSample.trackId);
|
|
11921
11921
|
const {
|
|
11922
11922
|
originalTimescale,
|
|
11923
11923
|
startInSeconds,
|
|
@@ -11936,7 +11936,7 @@ var parseMdatSection = async (state) => {
|
|
|
11936
11936
|
sample: {
|
|
11937
11937
|
data: bytes,
|
|
11938
11938
|
timestamp: cts,
|
|
11939
|
-
duration
|
|
11939
|
+
duration,
|
|
11940
11940
|
decodingTimestamp: dts,
|
|
11941
11941
|
type: isKeyframe ? "key" : "delta",
|
|
11942
11942
|
offset
|
|
@@ -11959,7 +11959,7 @@ var parseMdatSection = async (state) => {
|
|
|
11959
11959
|
sample: {
|
|
11960
11960
|
data: bytes,
|
|
11961
11961
|
timestamp: cts,
|
|
11962
|
-
duration
|
|
11962
|
+
duration,
|
|
11963
11963
|
decodingTimestamp: dts,
|
|
11964
11964
|
type: isKeyframe && !isRecoveryPoint ? "key" : "delta",
|
|
11965
11965
|
offset
|
|
@@ -11977,8 +11977,8 @@ var parseMdatSection = async (state) => {
|
|
|
11977
11977
|
|
|
11978
11978
|
// src/containers/iso-base-media/parse-boxes.ts
|
|
11979
11979
|
var parseIsoBaseMedia = async (state) => {
|
|
11980
|
-
const
|
|
11981
|
-
if (
|
|
11980
|
+
const mediaSectionState = state.mediaSection.isCurrentByteInMediaSection(state.iterator);
|
|
11981
|
+
if (mediaSectionState === "in-section") {
|
|
11982
11982
|
const skipTo = await parseMdatSection(state);
|
|
11983
11983
|
return skipTo;
|
|
11984
11984
|
}
|
|
@@ -12454,12 +12454,12 @@ var getChunkToSeekTo = ({
|
|
|
12454
12454
|
chunks,
|
|
12455
12455
|
seekToSecondsToProcess
|
|
12456
12456
|
}) => {
|
|
12457
|
-
let
|
|
12457
|
+
let duration = 0;
|
|
12458
12458
|
for (let i = 0;i < chunks.length; i++) {
|
|
12459
|
-
if (
|
|
12459
|
+
if (duration >= seekToSecondsToProcess) {
|
|
12460
12460
|
return Math.max(0, i - 1);
|
|
12461
12461
|
}
|
|
12462
|
-
|
|
12462
|
+
duration += chunks[i].duration;
|
|
12463
12463
|
}
|
|
12464
12464
|
return Math.max(0, chunks.length - 1);
|
|
12465
12465
|
};
|
|
@@ -13149,11 +13149,11 @@ var getAudioSampleFromCbr = ({
|
|
|
13149
13149
|
const durationInSeconds = samplesPerFrame / sampleRate;
|
|
13150
13150
|
const timeInSeconds = nthFrame * samplesPerFrame / sampleRate;
|
|
13151
13151
|
const timestamp = Math.floor(timeInSeconds * WEBCODECS_TIMESCALE);
|
|
13152
|
-
const
|
|
13152
|
+
const duration = Math.floor(durationInSeconds * WEBCODECS_TIMESCALE);
|
|
13153
13153
|
const audioSample = {
|
|
13154
13154
|
data,
|
|
13155
13155
|
decodingTimestamp: timestamp,
|
|
13156
|
-
duration
|
|
13156
|
+
duration,
|
|
13157
13157
|
offset: initialOffset,
|
|
13158
13158
|
timestamp,
|
|
13159
13159
|
type: "key"
|
|
@@ -13193,11 +13193,11 @@ var getAudioSampleFromVbr = ({
|
|
|
13193
13193
|
});
|
|
13194
13194
|
const durationInSeconds = samplesPerFrame / info.xingData.sampleRate;
|
|
13195
13195
|
const timestamp = Math.floor(timeInSeconds * WEBCODECS_TIMESCALE);
|
|
13196
|
-
const
|
|
13196
|
+
const duration = Math.floor(durationInSeconds * WEBCODECS_TIMESCALE);
|
|
13197
13197
|
const audioSample = {
|
|
13198
13198
|
data,
|
|
13199
13199
|
decodingTimestamp: timestamp,
|
|
13200
|
-
duration
|
|
13200
|
+
duration,
|
|
13201
13201
|
offset: position,
|
|
13202
13202
|
timestamp,
|
|
13203
13203
|
type: "key"
|
|
@@ -13685,7 +13685,7 @@ var parseStrh = ({
|
|
|
13685
13685
|
}
|
|
13686
13686
|
const flags = iterator.getUint32Le();
|
|
13687
13687
|
const priority = iterator.getUint16Le();
|
|
13688
|
-
const
|
|
13688
|
+
const language = iterator.getUint16Le();
|
|
13689
13689
|
const initialFrames = iterator.getUint32Le();
|
|
13690
13690
|
const scale = iterator.getUint32Le();
|
|
13691
13691
|
const rate = iterator.getUint32Le();
|
|
@@ -13718,7 +13718,7 @@ var parseStrh = ({
|
|
|
13718
13718
|
scale,
|
|
13719
13719
|
start,
|
|
13720
13720
|
suggestedBufferSize,
|
|
13721
|
-
language
|
|
13721
|
+
language,
|
|
13722
13722
|
strf
|
|
13723
13723
|
};
|
|
13724
13724
|
};
|
|
@@ -13955,8 +13955,8 @@ var parseMediaSection = async (state) => {
|
|
|
13955
13955
|
await parseMovi({
|
|
13956
13956
|
state
|
|
13957
13957
|
});
|
|
13958
|
-
const
|
|
13959
|
-
if (!
|
|
13958
|
+
const tracks = getTracks(state, false);
|
|
13959
|
+
if (!tracks.some((t) => t.type === "video" && t.codec === TO_BE_OVERRIDDEN_LATER) && !state.callbacks.tracks.getIsDone()) {
|
|
13960
13960
|
state.callbacks.tracks.setIsDone(state.logLevel);
|
|
13961
13961
|
}
|
|
13962
13962
|
};
|
|
@@ -14303,7 +14303,7 @@ var readAdtsHeader = (buffer) => {
|
|
|
14303
14303
|
const sampleRate = getSampleRateFromSampleFrequencyIndex(samplingFrequencyIndex);
|
|
14304
14304
|
iterator.getBits(1);
|
|
14305
14305
|
const channelConfiguration = iterator.getBits(3);
|
|
14306
|
-
const
|
|
14306
|
+
const codecPrivate = createAacCodecPrivate({
|
|
14307
14307
|
audioObjectType,
|
|
14308
14308
|
sampleRate,
|
|
14309
14309
|
channelConfiguration,
|
|
@@ -14323,7 +14323,7 @@ var readAdtsHeader = (buffer) => {
|
|
|
14323
14323
|
iterator.destroy();
|
|
14324
14324
|
return {
|
|
14325
14325
|
frameLength,
|
|
14326
|
-
codecPrivate
|
|
14326
|
+
codecPrivate,
|
|
14327
14327
|
channelConfiguration,
|
|
14328
14328
|
sampleRate,
|
|
14329
14329
|
audioObjectType
|
|
@@ -14345,7 +14345,7 @@ var handleAacPacket = async ({
|
|
|
14345
14345
|
if (!adtsHeader) {
|
|
14346
14346
|
throw new Error("Invalid ADTS header - too short");
|
|
14347
14347
|
}
|
|
14348
|
-
const { channelConfiguration, codecPrivate
|
|
14348
|
+
const { channelConfiguration, codecPrivate, sampleRate, audioObjectType } = adtsHeader;
|
|
14349
14349
|
const isTrackRegistered = sampleCallbacks.tracks.getTracks().find((t) => {
|
|
14350
14350
|
return t.trackId === programId;
|
|
14351
14351
|
});
|
|
@@ -14357,12 +14357,12 @@ var handleAacPacket = async ({
|
|
|
14357
14357
|
});
|
|
14358
14358
|
const track = {
|
|
14359
14359
|
type: "audio",
|
|
14360
|
-
codecData: { type: "aac-config", data:
|
|
14360
|
+
codecData: { type: "aac-config", data: codecPrivate },
|
|
14361
14361
|
trackId: programId,
|
|
14362
14362
|
originalTimescale: MPEG_TIMESCALE,
|
|
14363
14363
|
codecEnum: "aac",
|
|
14364
14364
|
codec: mapAudioObjectTypeToCodecString(audioObjectType),
|
|
14365
|
-
description:
|
|
14365
|
+
description: codecPrivate,
|
|
14366
14366
|
numberOfChannels: channelConfiguration,
|
|
14367
14367
|
sampleRate,
|
|
14368
14368
|
startInSeconds: 0,
|
|
@@ -14930,18 +14930,18 @@ var CHANNELS = {
|
|
|
14930
14930
|
17: "Top Back Right"
|
|
14931
14931
|
};
|
|
14932
14932
|
function getChannelsFromMask(channelMask) {
|
|
14933
|
-
const
|
|
14933
|
+
const channels = [];
|
|
14934
14934
|
for (let bit = 0;bit < 18; bit++) {
|
|
14935
14935
|
if ((channelMask & 1 << bit) !== 0) {
|
|
14936
14936
|
const channelName = CHANNELS[bit];
|
|
14937
14937
|
if (channelName) {
|
|
14938
|
-
|
|
14938
|
+
channels.push(channelName);
|
|
14939
14939
|
} else {
|
|
14940
|
-
|
|
14940
|
+
channels.push(`Unknown Channel (bit ${bit})`);
|
|
14941
14941
|
}
|
|
14942
14942
|
}
|
|
14943
14943
|
}
|
|
14944
|
-
return
|
|
14944
|
+
return channels;
|
|
14945
14945
|
}
|
|
14946
14946
|
var parseFmt = async ({
|
|
14947
14947
|
state
|
|
@@ -14985,8 +14985,8 @@ var parseFmt = async ({
|
|
|
14985
14985
|
if (subformatIsPcm(subFormat)) {} else if (subformatIsIeeeFloat(subFormat)) {} else {
|
|
14986
14986
|
throw new Error(`Unsupported subformat: ${subFormat}`);
|
|
14987
14987
|
}
|
|
14988
|
-
const
|
|
14989
|
-
wavHeader.numberOfChannels =
|
|
14988
|
+
const channels = getChannelsFromMask(channelMask);
|
|
14989
|
+
wavHeader.numberOfChannels = channels.length;
|
|
14990
14990
|
}
|
|
14991
14991
|
await registerAudioTrack({
|
|
14992
14992
|
track: {
|
|
@@ -15109,14 +15109,14 @@ var parseMediaSection2 = async ({
|
|
|
15109
15109
|
throw new Error("Expected fmt box");
|
|
15110
15110
|
}
|
|
15111
15111
|
const toRead = Math.min(maxRead, fmtBox.sampleRate * fmtBox.blockAlign / WAVE_SAMPLES_PER_SECOND);
|
|
15112
|
-
const
|
|
15112
|
+
const duration = toRead / (fmtBox.sampleRate * fmtBox.blockAlign);
|
|
15113
15113
|
const timestamp = (offset - videoSection.start) / (fmtBox.sampleRate * fmtBox.blockAlign);
|
|
15114
15114
|
const data = iterator.getSlice(toRead);
|
|
15115
15115
|
const audioSample = convertAudioOrVideoSampleToWebCodecsTimestamps({
|
|
15116
15116
|
sample: {
|
|
15117
15117
|
decodingTimestamp: timestamp,
|
|
15118
15118
|
data,
|
|
15119
|
-
duration
|
|
15119
|
+
duration,
|
|
15120
15120
|
timestamp,
|
|
15121
15121
|
type: "key",
|
|
15122
15122
|
offset
|
|
@@ -15175,19 +15175,19 @@ var getByteForSeek = ({
|
|
|
15175
15175
|
if (v.type !== "Seek") {
|
|
15176
15176
|
return null;
|
|
15177
15177
|
}
|
|
15178
|
-
const
|
|
15178
|
+
const seekId = v.value.find((_v) => {
|
|
15179
15179
|
return _v.type === "SeekID" && _v.value === matroskaElements.Cues;
|
|
15180
15180
|
});
|
|
15181
|
-
if (!
|
|
15181
|
+
if (!seekId) {
|
|
15182
15182
|
return null;
|
|
15183
15183
|
}
|
|
15184
|
-
const
|
|
15184
|
+
const seekPosition = v.value.find((_v) => {
|
|
15185
15185
|
return _v.type === "SeekPosition";
|
|
15186
15186
|
});
|
|
15187
|
-
if (!
|
|
15187
|
+
if (!seekPosition) {
|
|
15188
15188
|
return false;
|
|
15189
15189
|
}
|
|
15190
|
-
return
|
|
15190
|
+
return seekPosition.value;
|
|
15191
15191
|
}).filter(truthy);
|
|
15192
15192
|
if (value.length === 0) {
|
|
15193
15193
|
return null;
|
|
@@ -15231,9 +15231,9 @@ var parseBlockFlags = (iterator, type) => {
|
|
|
15231
15231
|
var addAvcToTrackAndActivateTrackIfNecessary = async ({
|
|
15232
15232
|
partialVideoSample,
|
|
15233
15233
|
codec,
|
|
15234
|
-
structureState
|
|
15234
|
+
structureState,
|
|
15235
15235
|
webmState,
|
|
15236
|
-
trackNumber
|
|
15236
|
+
trackNumber,
|
|
15237
15237
|
logLevel,
|
|
15238
15238
|
callbacks,
|
|
15239
15239
|
onVideoTrack,
|
|
@@ -15243,7 +15243,7 @@ var addAvcToTrackAndActivateTrackIfNecessary = async ({
|
|
|
15243
15243
|
return;
|
|
15244
15244
|
}
|
|
15245
15245
|
const missingTracks = getTracksFromMatroska({
|
|
15246
|
-
structureState
|
|
15246
|
+
structureState,
|
|
15247
15247
|
webmState
|
|
15248
15248
|
}).missingInfo;
|
|
15249
15249
|
if (missingTracks.length === 0) {
|
|
@@ -15252,18 +15252,18 @@ var addAvcToTrackAndActivateTrackIfNecessary = async ({
|
|
|
15252
15252
|
const parsed = parseAvc(partialVideoSample.data, avcState);
|
|
15253
15253
|
for (const parse of parsed) {
|
|
15254
15254
|
if (parse.type === "avc-profile") {
|
|
15255
|
-
webmState.setAvcProfileForTrackNumber(
|
|
15256
|
-
const track = missingTracks.find((t) => t.trackId ===
|
|
15255
|
+
webmState.setAvcProfileForTrackNumber(trackNumber, parse);
|
|
15256
|
+
const track = missingTracks.find((t) => t.trackId === trackNumber);
|
|
15257
15257
|
if (!track) {
|
|
15258
|
-
throw new Error("Could not find track " +
|
|
15258
|
+
throw new Error("Could not find track " + trackNumber);
|
|
15259
15259
|
}
|
|
15260
15260
|
const resolvedTracks = getTracksFromMatroska({
|
|
15261
|
-
structureState
|
|
15261
|
+
structureState,
|
|
15262
15262
|
webmState
|
|
15263
15263
|
}).resolved;
|
|
15264
|
-
const resolvedTrack = resolvedTracks.find((t) => t.trackId ===
|
|
15264
|
+
const resolvedTrack = resolvedTracks.find((t) => t.trackId === trackNumber);
|
|
15265
15265
|
if (!resolvedTrack) {
|
|
15266
|
-
throw new Error("Could not find track " +
|
|
15266
|
+
throw new Error("Could not find track " + trackNumber);
|
|
15267
15267
|
}
|
|
15268
15268
|
await registerVideoTrack({
|
|
15269
15269
|
track: resolvedTrack,
|
|
@@ -15280,7 +15280,7 @@ var getSampleFromBlock = async ({
|
|
|
15280
15280
|
ebml,
|
|
15281
15281
|
webmState,
|
|
15282
15282
|
offset,
|
|
15283
|
-
structureState
|
|
15283
|
+
structureState,
|
|
15284
15284
|
callbacks,
|
|
15285
15285
|
logLevel,
|
|
15286
15286
|
onVideoTrack,
|
|
@@ -15291,13 +15291,13 @@ var getSampleFromBlock = async ({
|
|
|
15291
15291
|
maxBytes: ebml.value.length,
|
|
15292
15292
|
logLevel: "error"
|
|
15293
15293
|
});
|
|
15294
|
-
const
|
|
15295
|
-
if (
|
|
15294
|
+
const trackNumber = iterator.getVint();
|
|
15295
|
+
if (trackNumber === null) {
|
|
15296
15296
|
throw new Error("Not enough data to get track number, should not happen");
|
|
15297
15297
|
}
|
|
15298
15298
|
const timecodeRelativeToCluster = iterator.getInt16();
|
|
15299
15299
|
const { keyframe } = parseBlockFlags(iterator, ebml.type === "SimpleBlock" ? matroskaElements.SimpleBlock : matroskaElements.Block);
|
|
15300
|
-
const { codec, trackTimescale } = webmState.getTrackInfoByNumber(
|
|
15300
|
+
const { codec, trackTimescale } = webmState.getTrackInfoByNumber(trackNumber);
|
|
15301
15301
|
const clusterOffset = webmState.getTimestampOffsetForByteOffset(offset);
|
|
15302
15302
|
const timescale = webmState.getTimescale();
|
|
15303
15303
|
if (clusterOffset === undefined) {
|
|
@@ -15306,7 +15306,7 @@ var getSampleFromBlock = async ({
|
|
|
15306
15306
|
const timecodeInNanoSeconds = (timecodeRelativeToCluster + clusterOffset) * timescale * (trackTimescale ?? 1);
|
|
15307
15307
|
const timecodeInMicroseconds = timecodeInNanoSeconds / 1000;
|
|
15308
15308
|
if (!codec) {
|
|
15309
|
-
throw new Error(`Could not find codec for track ${
|
|
15309
|
+
throw new Error(`Could not find codec for track ${trackNumber}`);
|
|
15310
15310
|
}
|
|
15311
15311
|
const remainingNow = ebml.value.length - iterator.counter.getOffset();
|
|
15312
15312
|
if (codec.startsWith("V_")) {
|
|
@@ -15322,16 +15322,16 @@ var getSampleFromBlock = async ({
|
|
|
15322
15322
|
return {
|
|
15323
15323
|
type: "partial-video-sample",
|
|
15324
15324
|
partialVideoSample,
|
|
15325
|
-
trackId:
|
|
15325
|
+
trackId: trackNumber,
|
|
15326
15326
|
timescale: WEBCODECS_TIMESCALE
|
|
15327
15327
|
};
|
|
15328
15328
|
}
|
|
15329
15329
|
await addAvcToTrackAndActivateTrackIfNecessary({
|
|
15330
15330
|
codec,
|
|
15331
15331
|
partialVideoSample,
|
|
15332
|
-
structureState
|
|
15332
|
+
structureState,
|
|
15333
15333
|
webmState,
|
|
15334
|
-
trackNumber
|
|
15334
|
+
trackNumber,
|
|
15335
15335
|
callbacks,
|
|
15336
15336
|
logLevel,
|
|
15337
15337
|
onVideoTrack,
|
|
@@ -15345,7 +15345,7 @@ var getSampleFromBlock = async ({
|
|
|
15345
15345
|
return {
|
|
15346
15346
|
type: "video-sample",
|
|
15347
15347
|
videoSample: sample,
|
|
15348
|
-
trackId:
|
|
15348
|
+
trackId: trackNumber,
|
|
15349
15349
|
timescale: WEBCODECS_TIMESCALE
|
|
15350
15350
|
};
|
|
15351
15351
|
}
|
|
@@ -15362,7 +15362,7 @@ var getSampleFromBlock = async ({
|
|
|
15362
15362
|
return {
|
|
15363
15363
|
type: "audio-sample",
|
|
15364
15364
|
audioSample,
|
|
15365
|
-
trackId:
|
|
15365
|
+
trackId: trackNumber,
|
|
15366
15366
|
timescale: WEBCODECS_TIMESCALE
|
|
15367
15367
|
};
|
|
15368
15368
|
}
|
|
@@ -15474,7 +15474,7 @@ var postprocessEbml = async ({
|
|
|
15474
15474
|
logLevel,
|
|
15475
15475
|
onAudioTrack,
|
|
15476
15476
|
onVideoTrack,
|
|
15477
|
-
structureState
|
|
15477
|
+
structureState,
|
|
15478
15478
|
avcState
|
|
15479
15479
|
}
|
|
15480
15480
|
}) => {
|
|
@@ -15521,7 +15521,7 @@ var postprocessEbml = async ({
|
|
|
15521
15521
|
ebml,
|
|
15522
15522
|
webmState,
|
|
15523
15523
|
offset,
|
|
15524
|
-
structureState
|
|
15524
|
+
structureState,
|
|
15525
15525
|
callbacks,
|
|
15526
15526
|
logLevel,
|
|
15527
15527
|
onVideoTrack,
|
|
@@ -15558,16 +15558,16 @@ var postprocessEbml = async ({
|
|
|
15558
15558
|
}
|
|
15559
15559
|
}
|
|
15560
15560
|
if (ebml.type === "BlockGroup") {
|
|
15561
|
-
const
|
|
15562
|
-
if (!
|
|
15561
|
+
const block = ebml.value.find((c) => c.type === "SimpleBlock" || c.type === "Block");
|
|
15562
|
+
if (!block || block.type !== "SimpleBlock" && block.type !== "Block") {
|
|
15563
15563
|
throw new Error("Expected block segment");
|
|
15564
15564
|
}
|
|
15565
15565
|
const hasReferenceBlock = ebml.value.find((c) => c.type === "ReferenceBlock");
|
|
15566
|
-
const sample =
|
|
15567
|
-
ebml:
|
|
15566
|
+
const sample = block.value.length === 0 ? null : await getSampleFromBlock({
|
|
15567
|
+
ebml: block,
|
|
15568
15568
|
webmState,
|
|
15569
15569
|
offset,
|
|
15570
|
-
structureState
|
|
15570
|
+
structureState,
|
|
15571
15571
|
callbacks,
|
|
15572
15572
|
logLevel,
|
|
15573
15573
|
onVideoTrack,
|
|
@@ -15598,7 +15598,7 @@ var expectSegment = async ({
|
|
|
15598
15598
|
isInsideSegment,
|
|
15599
15599
|
iterator,
|
|
15600
15600
|
logLevel,
|
|
15601
|
-
mediaSectionState
|
|
15601
|
+
mediaSectionState
|
|
15602
15602
|
}) => {
|
|
15603
15603
|
if (iterator.bytesRemaining() === 0) {
|
|
15604
15604
|
throw new Error("has no bytes");
|
|
@@ -15641,8 +15641,8 @@ var expectSegment = async ({
|
|
|
15641
15641
|
if (!statesForProcessing) {
|
|
15642
15642
|
throw new Error("States for processing are required");
|
|
15643
15643
|
}
|
|
15644
|
-
if (
|
|
15645
|
-
|
|
15644
|
+
if (mediaSectionState) {
|
|
15645
|
+
mediaSectionState.addMediaSection({
|
|
15646
15646
|
start: offset,
|
|
15647
15647
|
size
|
|
15648
15648
|
});
|
|
@@ -15792,8 +15792,8 @@ var initVideo = async ({ state }) => {
|
|
|
15792
15792
|
if (!moovAtom) {
|
|
15793
15793
|
throw new Error("No moov box found");
|
|
15794
15794
|
}
|
|
15795
|
-
const
|
|
15796
|
-
for (const track of
|
|
15795
|
+
const tracks = getTracksFromMoovBox(moovAtom);
|
|
15796
|
+
for (const track of tracks.filter((t) => t.type === "video")) {
|
|
15797
15797
|
await registerVideoTrack({
|
|
15798
15798
|
track,
|
|
15799
15799
|
container: "mp4",
|
|
@@ -15803,7 +15803,7 @@ var initVideo = async ({ state }) => {
|
|
|
15803
15803
|
tracks: state.callbacks.tracks
|
|
15804
15804
|
});
|
|
15805
15805
|
}
|
|
15806
|
-
for (const track of
|
|
15806
|
+
for (const track of tracks.filter((t) => t.type === "audio")) {
|
|
15807
15807
|
await registerAudioTrack({
|
|
15808
15808
|
track,
|
|
15809
15809
|
container: "mp4",
|
|
@@ -16603,7 +16603,7 @@ var keyframesState = () => {
|
|
|
16603
16603
|
}
|
|
16604
16604
|
keyframes.push(keyframe);
|
|
16605
16605
|
};
|
|
16606
|
-
const
|
|
16606
|
+
const getKeyframes = () => {
|
|
16607
16607
|
keyframes.sort((a, b) => a.positionInBytes - b.positionInBytes);
|
|
16608
16608
|
return keyframes;
|
|
16609
16609
|
};
|
|
@@ -16614,7 +16614,7 @@ var keyframesState = () => {
|
|
|
16614
16614
|
};
|
|
16615
16615
|
return {
|
|
16616
16616
|
addKeyframe,
|
|
16617
|
-
getKeyframes
|
|
16617
|
+
getKeyframes,
|
|
16618
16618
|
setFromSeekingHints
|
|
16619
16619
|
};
|
|
16620
16620
|
};
|
|
@@ -17008,19 +17008,19 @@ var webmState = ({
|
|
|
17008
17008
|
prefetchCache
|
|
17009
17009
|
}) => {
|
|
17010
17010
|
const trackEntries = {};
|
|
17011
|
-
const onTrackEntrySegment = (
|
|
17012
|
-
const trackId = getTrackId(
|
|
17011
|
+
const onTrackEntrySegment = (trackEntry) => {
|
|
17012
|
+
const trackId = getTrackId(trackEntry);
|
|
17013
17013
|
if (!trackId) {
|
|
17014
17014
|
throw new Error("Expected track id");
|
|
17015
17015
|
}
|
|
17016
17016
|
if (trackEntries[trackId]) {
|
|
17017
17017
|
return;
|
|
17018
17018
|
}
|
|
17019
|
-
const codec = getTrackCodec(
|
|
17019
|
+
const codec = getTrackCodec(trackEntry);
|
|
17020
17020
|
if (!codec) {
|
|
17021
17021
|
throw new Error("Expected codec");
|
|
17022
17022
|
}
|
|
17023
|
-
const trackTimescale = getTrackTimestampScale(
|
|
17023
|
+
const trackTimescale = getTrackTimestampScale(trackEntry);
|
|
17024
17024
|
trackEntries[trackId] = {
|
|
17025
17025
|
codec: codec.value,
|
|
17026
17026
|
trackTimescale: trackTimescale?.value ?? null
|
|
@@ -17056,11 +17056,11 @@ var webmState = ({
|
|
|
17056
17056
|
const segments = [];
|
|
17057
17057
|
const clusters = [];
|
|
17058
17058
|
const avcProfilesMap = {};
|
|
17059
|
-
const setAvcProfileForTrackNumber = (
|
|
17060
|
-
avcProfilesMap[
|
|
17059
|
+
const setAvcProfileForTrackNumber = (trackNumber, avcProfile) => {
|
|
17060
|
+
avcProfilesMap[trackNumber] = avcProfile;
|
|
17061
17061
|
};
|
|
17062
|
-
const getAvcProfileForTrackNumber = (
|
|
17063
|
-
return avcProfilesMap[
|
|
17062
|
+
const getAvcProfileForTrackNumber = (trackNumber) => {
|
|
17063
|
+
return avcProfilesMap[trackNumber] ?? null;
|
|
17064
17064
|
};
|
|
17065
17065
|
const cues = lazyCuesFetch({
|
|
17066
17066
|
controller,
|
|
@@ -17312,7 +17312,7 @@ var riffKeyframesState = () => {
|
|
|
17312
17312
|
keyframes.push(keyframe);
|
|
17313
17313
|
keyframes.sort((a, b) => a.positionInBytes - b.positionInBytes);
|
|
17314
17314
|
};
|
|
17315
|
-
const
|
|
17315
|
+
const getKeyframes = () => {
|
|
17316
17316
|
return keyframes;
|
|
17317
17317
|
};
|
|
17318
17318
|
const setFromSeekingHints = (keyframesFromHints) => {
|
|
@@ -17322,7 +17322,7 @@ var riffKeyframesState = () => {
|
|
|
17322
17322
|
};
|
|
17323
17323
|
return {
|
|
17324
17324
|
addKeyframe,
|
|
17325
|
-
getKeyframes
|
|
17325
|
+
getKeyframes,
|
|
17326
17326
|
setFromSeekingHints
|
|
17327
17327
|
};
|
|
17328
17328
|
};
|
|
@@ -17603,9 +17603,9 @@ var samplesObservedState = () => {
|
|
|
17603
17603
|
const addVideoSample = (videoSample) => {
|
|
17604
17604
|
videoSamples.set(videoSample.timestamp, videoSample.data.byteLength);
|
|
17605
17605
|
const presentationTimeInSeconds = videoSample.timestamp / WEBCODECS_TIMESCALE;
|
|
17606
|
-
const
|
|
17606
|
+
const duration = (videoSample.duration ?? 0) / WEBCODECS_TIMESCALE;
|
|
17607
17607
|
if (largestVideoSample === undefined || presentationTimeInSeconds > largestVideoSample) {
|
|
17608
|
-
largestVideoSample = presentationTimeInSeconds +
|
|
17608
|
+
largestVideoSample = presentationTimeInSeconds + duration;
|
|
17609
17609
|
}
|
|
17610
17610
|
if (smallestVideoSample === undefined || presentationTimeInSeconds < smallestVideoSample) {
|
|
17611
17611
|
smallestVideoSample = presentationTimeInSeconds;
|
|
@@ -17614,15 +17614,15 @@ var samplesObservedState = () => {
|
|
|
17614
17614
|
const addAudioSample = (audioSample) => {
|
|
17615
17615
|
audioSamples.set(audioSample.timestamp, audioSample.data.byteLength);
|
|
17616
17616
|
const presentationTimeInSeconds = audioSample.timestamp / WEBCODECS_TIMESCALE;
|
|
17617
|
-
const
|
|
17617
|
+
const duration = (audioSample.duration ?? 0) / WEBCODECS_TIMESCALE;
|
|
17618
17618
|
if (largestAudioSample === undefined || presentationTimeInSeconds > largestAudioSample) {
|
|
17619
|
-
largestAudioSample = presentationTimeInSeconds +
|
|
17619
|
+
largestAudioSample = presentationTimeInSeconds + duration;
|
|
17620
17620
|
}
|
|
17621
17621
|
if (smallestAudioSample === undefined || presentationTimeInSeconds < smallestAudioSample) {
|
|
17622
17622
|
smallestAudioSample = presentationTimeInSeconds;
|
|
17623
17623
|
}
|
|
17624
17624
|
};
|
|
17625
|
-
const
|
|
17625
|
+
const getFps = () => {
|
|
17626
17626
|
const videoDuration = (largestVideoSample ?? 0) - (smallestVideoSample ?? 0);
|
|
17627
17627
|
if (videoDuration === 0) {
|
|
17628
17628
|
return 0;
|
|
@@ -17654,7 +17654,7 @@ var samplesObservedState = () => {
|
|
|
17654
17654
|
addVideoSample,
|
|
17655
17655
|
addAudioSample,
|
|
17656
17656
|
getSlowDurationInSeconds,
|
|
17657
|
-
getFps
|
|
17657
|
+
getFps,
|
|
17658
17658
|
getSlowNumberOfFrames,
|
|
17659
17659
|
getAudioBitrate,
|
|
17660
17660
|
getVideoBitrate,
|
|
@@ -18064,44 +18064,44 @@ var internalParseMedia = async function({
|
|
|
18064
18064
|
contentLength: state.contentLength,
|
|
18065
18065
|
aacState: state.aac
|
|
18066
18066
|
})));
|
|
18067
|
-
controller._internals.attachSimulateSeekResolution((
|
|
18067
|
+
controller._internals.attachSimulateSeekResolution((seek) => {
|
|
18068
18068
|
const {
|
|
18069
|
-
aacState
|
|
18070
|
-
avcState
|
|
18071
|
-
flacState
|
|
18069
|
+
aacState,
|
|
18070
|
+
avcState,
|
|
18071
|
+
flacState,
|
|
18072
18072
|
isoState,
|
|
18073
18073
|
iterator,
|
|
18074
18074
|
keyframes,
|
|
18075
|
-
m3uState
|
|
18075
|
+
m3uState,
|
|
18076
18076
|
mediaSection,
|
|
18077
18077
|
mp3State,
|
|
18078
18078
|
riffState,
|
|
18079
18079
|
samplesObserved,
|
|
18080
|
-
structureState
|
|
18080
|
+
structureState,
|
|
18081
18081
|
tracksState,
|
|
18082
18082
|
transportStream,
|
|
18083
|
-
webmState
|
|
18083
|
+
webmState
|
|
18084
18084
|
} = getWorkOnSeekRequestOptions(state);
|
|
18085
18085
|
return turnSeekIntoByte({
|
|
18086
|
-
aacState
|
|
18087
|
-
seek
|
|
18088
|
-
avcState
|
|
18086
|
+
aacState,
|
|
18087
|
+
seek,
|
|
18088
|
+
avcState,
|
|
18089
18089
|
contentLength,
|
|
18090
|
-
flacState
|
|
18090
|
+
flacState,
|
|
18091
18091
|
isoState,
|
|
18092
18092
|
iterator,
|
|
18093
18093
|
keyframes,
|
|
18094
18094
|
logLevel,
|
|
18095
18095
|
m3uPlaylistContext,
|
|
18096
|
-
m3uState
|
|
18096
|
+
m3uState,
|
|
18097
18097
|
mediaSectionState: mediaSection,
|
|
18098
18098
|
mp3State,
|
|
18099
18099
|
riffState,
|
|
18100
18100
|
samplesObserved,
|
|
18101
|
-
structureState
|
|
18101
|
+
structureState,
|
|
18102
18102
|
tracksState,
|
|
18103
18103
|
transportStream,
|
|
18104
|
-
webmState
|
|
18104
|
+
webmState
|
|
18105
18105
|
});
|
|
18106
18106
|
});
|
|
18107
18107
|
if (!hasAudioTrackHandlers && !hasVideoTrackHandlers && Object.values(state.fields).every((v) => !v) && mode === "query") {
|
|
@@ -18493,10 +18493,10 @@ var startParsing = async (message, reader) => {
|
|
|
18493
18493
|
value: structure
|
|
18494
18494
|
});
|
|
18495
18495
|
} : null,
|
|
18496
|
-
onTracks: postTracks ? async (
|
|
18496
|
+
onTracks: postTracks ? async (tracks) => {
|
|
18497
18497
|
await executeCallback({
|
|
18498
18498
|
callbackType: "tracks",
|
|
18499
|
-
value:
|
|
18499
|
+
value: tracks
|
|
18500
18500
|
});
|
|
18501
18501
|
} : null,
|
|
18502
18502
|
onUnrotatedDimensions: postUnrotatedDimensions ? async (dimensions) => {
|