@remotion/media-parser 4.0.534 → 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
package/dist/esm/index.mjs
CHANGED
|
@@ -1900,16 +1900,16 @@ var registerVideoTrack = async ({
|
|
|
1900
1900
|
logLevel,
|
|
1901
1901
|
onVideoTrack,
|
|
1902
1902
|
registerVideoSampleCallback,
|
|
1903
|
-
tracks
|
|
1903
|
+
tracks
|
|
1904
1904
|
}) => {
|
|
1905
|
-
if (
|
|
1905
|
+
if (tracks.getTracks().find((t) => t.trackId === track.trackId)) {
|
|
1906
1906
|
Log.trace(logLevel, `Track ${track.trackId} already registered, skipping`);
|
|
1907
1907
|
return null;
|
|
1908
1908
|
}
|
|
1909
1909
|
if (track.type !== "video") {
|
|
1910
1910
|
throw new Error("Expected video track");
|
|
1911
1911
|
}
|
|
1912
|
-
|
|
1912
|
+
tracks.addTrack(track);
|
|
1913
1913
|
if (!onVideoTrack) {
|
|
1914
1914
|
return null;
|
|
1915
1915
|
}
|
|
@@ -1923,19 +1923,19 @@ var registerVideoTrack = async ({
|
|
|
1923
1923
|
var registerAudioTrack = async ({
|
|
1924
1924
|
track,
|
|
1925
1925
|
container,
|
|
1926
|
-
tracks
|
|
1926
|
+
tracks,
|
|
1927
1927
|
logLevel,
|
|
1928
1928
|
onAudioTrack,
|
|
1929
1929
|
registerAudioSampleCallback
|
|
1930
1930
|
}) => {
|
|
1931
|
-
if (
|
|
1931
|
+
if (tracks.getTracks().find((t) => t.trackId === track.trackId)) {
|
|
1932
1932
|
Log.trace(logLevel, `Track ${track.trackId} already registered, skipping`);
|
|
1933
1933
|
return null;
|
|
1934
1934
|
}
|
|
1935
1935
|
if (track.type !== "audio") {
|
|
1936
1936
|
throw new Error("Expected audio track");
|
|
1937
1937
|
}
|
|
1938
|
-
|
|
1938
|
+
tracks.addTrack(track);
|
|
1939
1939
|
if (!onAudioTrack) {
|
|
1940
1940
|
return null;
|
|
1941
1941
|
}
|
|
@@ -2526,7 +2526,7 @@ var makeAviVideoTrack = ({
|
|
|
2526
2526
|
};
|
|
2527
2527
|
};
|
|
2528
2528
|
var getTracksFromAvi = (structure, state) => {
|
|
2529
|
-
const
|
|
2529
|
+
const tracks = [];
|
|
2530
2530
|
const boxes = getStrlBoxes(structure);
|
|
2531
2531
|
let i = 0;
|
|
2532
2532
|
for (const box of boxes) {
|
|
@@ -2536,22 +2536,22 @@ var getTracksFromAvi = (structure, state) => {
|
|
|
2536
2536
|
}
|
|
2537
2537
|
const { strf } = strh;
|
|
2538
2538
|
if (strf.type === "strf-box-video") {
|
|
2539
|
-
|
|
2539
|
+
tracks.push(addAvcProfileToTrack(makeAviVideoTrack({ strh, strf, index: i }), state.riff.getAvcProfile()));
|
|
2540
2540
|
} else if (strh.fccType === "auds") {
|
|
2541
|
-
|
|
2541
|
+
tracks.push(makeAviAudioTrack({ strf, index: i }));
|
|
2542
2542
|
} else {
|
|
2543
2543
|
throw new Error(`Unsupported track type ${strh.fccType}`);
|
|
2544
2544
|
}
|
|
2545
2545
|
i++;
|
|
2546
2546
|
}
|
|
2547
|
-
return
|
|
2547
|
+
return tracks;
|
|
2548
2548
|
};
|
|
2549
2549
|
var hasAllTracksFromAvi = (state) => {
|
|
2550
2550
|
try {
|
|
2551
2551
|
const structure = state.structure.getRiffStructure();
|
|
2552
2552
|
const numberOfTracks = getNumberOfTracks(structure);
|
|
2553
|
-
const
|
|
2554
|
-
return
|
|
2553
|
+
const tracks = getTracksFromAvi(structure, state);
|
|
2554
|
+
return tracks.length === numberOfTracks && !tracks.find((t) => t.type === "video" && t.codec === TO_BE_OVERRIDDEN_LATER);
|
|
2555
2555
|
} catch {
|
|
2556
2556
|
return false;
|
|
2557
2557
|
}
|
|
@@ -2650,12 +2650,12 @@ var getHvc1CodecString = (data) => {
|
|
|
2650
2650
|
};
|
|
2651
2651
|
|
|
2652
2652
|
// src/containers/iso-base-media/color-to-webcodecs-colors.ts
|
|
2653
|
-
var mediaParserAdvancedColorToWebCodecsColor = (
|
|
2653
|
+
var mediaParserAdvancedColorToWebCodecsColor = (color) => {
|
|
2654
2654
|
return {
|
|
2655
|
-
transfer:
|
|
2656
|
-
matrix:
|
|
2657
|
-
primaries:
|
|
2658
|
-
fullRange:
|
|
2655
|
+
transfer: color.transfer,
|
|
2656
|
+
matrix: color.matrix,
|
|
2657
|
+
primaries: color.primaries,
|
|
2658
|
+
fullRange: color.fullRange
|
|
2659
2659
|
};
|
|
2660
2660
|
};
|
|
2661
2661
|
|
|
@@ -2687,8 +2687,8 @@ var parseAv1PrivateData = (data, colrAtom) => {
|
|
|
2687
2687
|
str += ".";
|
|
2688
2688
|
const high_bitdepth = iterator.getBits(1);
|
|
2689
2689
|
const twelve_bit = iterator.getBits(1);
|
|
2690
|
-
const
|
|
2691
|
-
str +=
|
|
2690
|
+
const bitDepth = high_bitdepth && seqProfile === 2 ? twelve_bit ? 12 : 10 : high_bitdepth ? 10 : 8;
|
|
2691
|
+
str += bitDepth.toString().padStart(2, "0");
|
|
2692
2692
|
str += ".";
|
|
2693
2693
|
const mono_chrome = iterator.getBits(1);
|
|
2694
2694
|
str += mono_chrome ? "1" : "0";
|
|
@@ -2817,106 +2817,106 @@ var getCodecSegment = (track) => {
|
|
|
2817
2817
|
return codec;
|
|
2818
2818
|
};
|
|
2819
2819
|
var getColourSegment = (track) => {
|
|
2820
|
-
const
|
|
2821
|
-
if (!
|
|
2820
|
+
const videoSegment = getVideoSegment(track);
|
|
2821
|
+
if (!videoSegment) {
|
|
2822
2822
|
return null;
|
|
2823
2823
|
}
|
|
2824
|
-
const colour =
|
|
2824
|
+
const colour = videoSegment.value.find((b) => b.type === "Colour");
|
|
2825
2825
|
if (!colour || colour.type !== "Colour") {
|
|
2826
2826
|
return null;
|
|
2827
2827
|
}
|
|
2828
2828
|
return colour;
|
|
2829
2829
|
};
|
|
2830
|
-
var getTransferCharacteristicsSegment = (
|
|
2831
|
-
if (!
|
|
2830
|
+
var getTransferCharacteristicsSegment = (color) => {
|
|
2831
|
+
if (!color || color.type !== "Colour") {
|
|
2832
2832
|
return null;
|
|
2833
2833
|
}
|
|
2834
|
-
const box =
|
|
2834
|
+
const box = color.value.find((b) => b.type === "TransferCharacteristics");
|
|
2835
2835
|
if (!box || box.type !== "TransferCharacteristics") {
|
|
2836
2836
|
return null;
|
|
2837
2837
|
}
|
|
2838
2838
|
return box;
|
|
2839
2839
|
};
|
|
2840
|
-
var getMatrixCoefficientsSegment = (
|
|
2841
|
-
if (!
|
|
2840
|
+
var getMatrixCoefficientsSegment = (color) => {
|
|
2841
|
+
if (!color || color.type !== "Colour") {
|
|
2842
2842
|
return null;
|
|
2843
2843
|
}
|
|
2844
|
-
const box =
|
|
2844
|
+
const box = color.value.find((b) => b.type === "MatrixCoefficients");
|
|
2845
2845
|
if (!box || box.type !== "MatrixCoefficients") {
|
|
2846
2846
|
return null;
|
|
2847
2847
|
}
|
|
2848
2848
|
return box;
|
|
2849
2849
|
};
|
|
2850
|
-
var getPrimariesSegment = (
|
|
2851
|
-
if (!
|
|
2850
|
+
var getPrimariesSegment = (color) => {
|
|
2851
|
+
if (!color || color.type !== "Colour") {
|
|
2852
2852
|
return null;
|
|
2853
2853
|
}
|
|
2854
|
-
const box =
|
|
2854
|
+
const box = color.value.find((b) => b.type === "Primaries");
|
|
2855
2855
|
if (!box || box.type !== "Primaries") {
|
|
2856
2856
|
return null;
|
|
2857
2857
|
}
|
|
2858
2858
|
return box;
|
|
2859
2859
|
};
|
|
2860
|
-
var getRangeSegment = (
|
|
2861
|
-
if (!
|
|
2860
|
+
var getRangeSegment = (color) => {
|
|
2861
|
+
if (!color || color.type !== "Colour") {
|
|
2862
2862
|
return null;
|
|
2863
2863
|
}
|
|
2864
|
-
const box =
|
|
2864
|
+
const box = color.value.find((b) => b.type === "Range");
|
|
2865
2865
|
if (!box || box.type !== "Range") {
|
|
2866
2866
|
return null;
|
|
2867
2867
|
}
|
|
2868
2868
|
return box;
|
|
2869
2869
|
};
|
|
2870
2870
|
var getDisplayHeightSegment = (track) => {
|
|
2871
|
-
const
|
|
2872
|
-
if (!
|
|
2871
|
+
const videoSegment = getVideoSegment(track);
|
|
2872
|
+
if (!videoSegment) {
|
|
2873
2873
|
return null;
|
|
2874
2874
|
}
|
|
2875
|
-
const
|
|
2876
|
-
if (!
|
|
2875
|
+
const displayHeight = videoSegment.value.find((b) => b.type === "DisplayHeight");
|
|
2876
|
+
if (!displayHeight || displayHeight.type !== "DisplayHeight") {
|
|
2877
2877
|
return null;
|
|
2878
2878
|
}
|
|
2879
|
-
return
|
|
2879
|
+
return displayHeight;
|
|
2880
2880
|
};
|
|
2881
2881
|
var getTrackTypeSegment = (track) => {
|
|
2882
|
-
const
|
|
2883
|
-
if (!
|
|
2882
|
+
const trackType = track.value.find((b) => b.type === "TrackType");
|
|
2883
|
+
if (!trackType || trackType.type !== "TrackType") {
|
|
2884
2884
|
return null;
|
|
2885
2885
|
}
|
|
2886
|
-
return
|
|
2886
|
+
return trackType;
|
|
2887
2887
|
};
|
|
2888
2888
|
var getWidthSegment = (track) => {
|
|
2889
|
-
const
|
|
2890
|
-
if (!
|
|
2889
|
+
const videoSegment = getVideoSegment(track);
|
|
2890
|
+
if (!videoSegment) {
|
|
2891
2891
|
return null;
|
|
2892
2892
|
}
|
|
2893
|
-
const width =
|
|
2893
|
+
const width = videoSegment.value.find((b) => b.type === "PixelWidth");
|
|
2894
2894
|
if (!width || width.type !== "PixelWidth") {
|
|
2895
2895
|
return null;
|
|
2896
2896
|
}
|
|
2897
2897
|
return width;
|
|
2898
2898
|
};
|
|
2899
2899
|
var getHeightSegment = (track) => {
|
|
2900
|
-
const
|
|
2901
|
-
if (!
|
|
2900
|
+
const videoSegment = getVideoSegment(track);
|
|
2901
|
+
if (!videoSegment) {
|
|
2902
2902
|
return null;
|
|
2903
2903
|
}
|
|
2904
|
-
const height =
|
|
2904
|
+
const height = videoSegment.value.find((b) => b.type === "PixelHeight");
|
|
2905
2905
|
if (!height || height.type !== "PixelHeight") {
|
|
2906
2906
|
return null;
|
|
2907
2907
|
}
|
|
2908
2908
|
return height;
|
|
2909
2909
|
};
|
|
2910
2910
|
var getDisplayWidthSegment = (track) => {
|
|
2911
|
-
const
|
|
2912
|
-
if (!
|
|
2911
|
+
const videoSegment = getVideoSegment(track);
|
|
2912
|
+
if (!videoSegment) {
|
|
2913
2913
|
return null;
|
|
2914
2914
|
}
|
|
2915
|
-
const
|
|
2916
|
-
if (!
|
|
2915
|
+
const displayWidth = videoSegment.value.find((b) => b.type === "DisplayWidth");
|
|
2916
|
+
if (!displayWidth || displayWidth.type !== "DisplayWidth") {
|
|
2917
2917
|
return null;
|
|
2918
2918
|
}
|
|
2919
|
-
return
|
|
2919
|
+
return displayWidth;
|
|
2920
2920
|
};
|
|
2921
2921
|
var getTracksSegment = (segment) => {
|
|
2922
2922
|
const tracksSegment = segment.value.find((b) => b.type === "Tracks");
|
|
@@ -2931,60 +2931,60 @@ var getTrackWithUid = (segment, trackUid) => {
|
|
|
2931
2931
|
return null;
|
|
2932
2932
|
}
|
|
2933
2933
|
const trackEntries = tracksSegment.value.filter((t) => t.type === "TrackEntry");
|
|
2934
|
-
const
|
|
2934
|
+
const trackEntry = trackEntries.find((entry) => {
|
|
2935
2935
|
return entry?.value.find((t) => t.type === "TrackUID" && t.value === trackUid);
|
|
2936
2936
|
});
|
|
2937
|
-
if (!
|
|
2937
|
+
if (!trackEntry) {
|
|
2938
2938
|
return null;
|
|
2939
2939
|
}
|
|
2940
|
-
return
|
|
2940
|
+
return trackEntry.value.find((t) => t.type === "TrackNumber")?.value.value ?? null;
|
|
2941
2941
|
};
|
|
2942
2942
|
var getVideoSegment = (track) => {
|
|
2943
|
-
const
|
|
2944
|
-
if (!
|
|
2943
|
+
const videoSegment = track.value.find((b) => b.type === "Video");
|
|
2944
|
+
if (!videoSegment || videoSegment.type !== "Video") {
|
|
2945
2945
|
return null;
|
|
2946
2946
|
}
|
|
2947
|
-
return
|
|
2947
|
+
return videoSegment ?? null;
|
|
2948
2948
|
};
|
|
2949
2949
|
var getAudioSegment = (track) => {
|
|
2950
|
-
const
|
|
2951
|
-
if (!
|
|
2950
|
+
const audioSegment = track.value.find((b) => b.type === "Audio");
|
|
2951
|
+
if (!audioSegment || audioSegment.type !== "Audio") {
|
|
2952
2952
|
return null;
|
|
2953
2953
|
}
|
|
2954
|
-
return
|
|
2954
|
+
return audioSegment ?? null;
|
|
2955
2955
|
};
|
|
2956
2956
|
var getSampleRate = (track) => {
|
|
2957
|
-
const
|
|
2958
|
-
if (!
|
|
2957
|
+
const audioSegment = getAudioSegment(track);
|
|
2958
|
+
if (!audioSegment) {
|
|
2959
2959
|
return null;
|
|
2960
2960
|
}
|
|
2961
|
-
const
|
|
2962
|
-
if (!
|
|
2961
|
+
const samplingFrequency = audioSegment.value.find((b) => b.type === "SamplingFrequency");
|
|
2962
|
+
if (!samplingFrequency || samplingFrequency.type !== "SamplingFrequency") {
|
|
2963
2963
|
return null;
|
|
2964
2964
|
}
|
|
2965
|
-
return
|
|
2965
|
+
return samplingFrequency.value.value;
|
|
2966
2966
|
};
|
|
2967
2967
|
var getNumberOfChannels = (track) => {
|
|
2968
|
-
const
|
|
2969
|
-
if (!
|
|
2968
|
+
const audioSegment = getAudioSegment(track);
|
|
2969
|
+
if (!audioSegment) {
|
|
2970
2970
|
throw new Error("Could not find audio segment");
|
|
2971
2971
|
}
|
|
2972
|
-
const
|
|
2973
|
-
if (!
|
|
2972
|
+
const channels = audioSegment.value.find((b) => b.type === "Channels");
|
|
2973
|
+
if (!channels || channels.type !== "Channels") {
|
|
2974
2974
|
return 1;
|
|
2975
2975
|
}
|
|
2976
|
-
return
|
|
2976
|
+
return channels.value.value;
|
|
2977
2977
|
};
|
|
2978
2978
|
var getBitDepth = (track) => {
|
|
2979
|
-
const
|
|
2980
|
-
if (!
|
|
2979
|
+
const audioSegment = getAudioSegment(track);
|
|
2980
|
+
if (!audioSegment) {
|
|
2981
2981
|
return null;
|
|
2982
2982
|
}
|
|
2983
|
-
const
|
|
2984
|
-
if (!
|
|
2983
|
+
const bitDepth = audioSegment.value.find((b) => b.type === "BitDepth");
|
|
2984
|
+
if (!bitDepth || bitDepth.type !== "BitDepth") {
|
|
2985
2985
|
return null;
|
|
2986
2986
|
}
|
|
2987
|
-
return
|
|
2987
|
+
return bitDepth.value.value;
|
|
2988
2988
|
};
|
|
2989
2989
|
var getPrivateData = (track) => {
|
|
2990
2990
|
const privateData = track.value.find((b) => b.type === "CodecPrivate");
|
|
@@ -2996,15 +2996,15 @@ var getPrivateData = (track) => {
|
|
|
2996
2996
|
|
|
2997
2997
|
// src/containers/webm/color.ts
|
|
2998
2998
|
var parseColorSegment = (colourSegment) => {
|
|
2999
|
-
const
|
|
3000
|
-
const
|
|
3001
|
-
const
|
|
3002
|
-
const
|
|
2999
|
+
const transferCharacteristics = getTransferCharacteristicsSegment(colourSegment);
|
|
3000
|
+
const matrixCoefficients = getMatrixCoefficientsSegment(colourSegment);
|
|
3001
|
+
const primaries = getPrimariesSegment(colourSegment);
|
|
3002
|
+
const range = getRangeSegment(colourSegment);
|
|
3003
3003
|
return {
|
|
3004
|
-
transfer:
|
|
3005
|
-
matrix:
|
|
3006
|
-
primaries:
|
|
3007
|
-
fullRange:
|
|
3004
|
+
transfer: transferCharacteristics ? getTransferCharacteristicsFromIndex(transferCharacteristics.value.value) : null,
|
|
3005
|
+
matrix: matrixCoefficients ? getMatrixCoefficientsFromIndex(matrixCoefficients.value.value) : null,
|
|
3006
|
+
primaries: primaries ? getPrimariesFromIndex(primaries.value.value) : null,
|
|
3007
|
+
fullRange: transferCharacteristics?.value.value && matrixCoefficients?.value.value ? null : range ? Boolean(range?.value.value) : null
|
|
3008
3008
|
};
|
|
3009
3009
|
};
|
|
3010
3010
|
|
|
@@ -3074,8 +3074,8 @@ var getAudioDescription = (track) => {
|
|
|
3074
3074
|
};
|
|
3075
3075
|
|
|
3076
3076
|
// src/containers/webm/segments/track-entry.ts
|
|
3077
|
-
var trackTypeToString = (
|
|
3078
|
-
switch (
|
|
3077
|
+
var trackTypeToString = (trackType) => {
|
|
3078
|
+
switch (trackType) {
|
|
3079
3079
|
case 1:
|
|
3080
3080
|
return "video";
|
|
3081
3081
|
case 2:
|
|
@@ -3091,7 +3091,7 @@ var trackTypeToString = (trackType2) => {
|
|
|
3091
3091
|
case 7:
|
|
3092
3092
|
return "metadata";
|
|
3093
3093
|
default:
|
|
3094
|
-
throw new Error(`Unknown track type: ${
|
|
3094
|
+
throw new Error(`Unknown track type: ${trackType}`);
|
|
3095
3095
|
}
|
|
3096
3096
|
};
|
|
3097
3097
|
|
|
@@ -3183,17 +3183,17 @@ var getMatroskaAudioCodecEnum = ({
|
|
|
3183
3183
|
return "vorbis";
|
|
3184
3184
|
}
|
|
3185
3185
|
if (codec.value === "A_PCM/INT/LIT") {
|
|
3186
|
-
const
|
|
3187
|
-
if (
|
|
3186
|
+
const bitDepth = getBitDepth(track);
|
|
3187
|
+
if (bitDepth === null) {
|
|
3188
3188
|
throw new Error("Expected bit depth");
|
|
3189
3189
|
}
|
|
3190
|
-
if (
|
|
3190
|
+
if (bitDepth === 8) {
|
|
3191
3191
|
return "pcm-u8";
|
|
3192
3192
|
}
|
|
3193
|
-
if (
|
|
3193
|
+
if (bitDepth === 16) {
|
|
3194
3194
|
return "pcm-s16";
|
|
3195
3195
|
}
|
|
3196
|
-
if (
|
|
3196
|
+
if (bitDepth === 24) {
|
|
3197
3197
|
return "pcm-s24";
|
|
3198
3198
|
}
|
|
3199
3199
|
throw new Error("Unknown audio format");
|
|
@@ -3218,14 +3218,14 @@ var getMatroskaAudioCodecString = (track) => {
|
|
|
3218
3218
|
return "vorbis";
|
|
3219
3219
|
}
|
|
3220
3220
|
if (codec.value === "A_PCM/INT/LIT") {
|
|
3221
|
-
const
|
|
3222
|
-
if (
|
|
3221
|
+
const bitDepth = getBitDepth(track);
|
|
3222
|
+
if (bitDepth === null) {
|
|
3223
3223
|
throw new Error("Expected bit depth");
|
|
3224
3224
|
}
|
|
3225
|
-
if (
|
|
3225
|
+
if (bitDepth === 8) {
|
|
3226
3226
|
return "pcm-u8";
|
|
3227
3227
|
}
|
|
3228
|
-
return "pcm-s" +
|
|
3228
|
+
return "pcm-s" + bitDepth;
|
|
3229
3229
|
}
|
|
3230
3230
|
if (codec.value === "A_AAC") {
|
|
3231
3231
|
const priv = getPrivateData(track);
|
|
@@ -3249,12 +3249,12 @@ var getTrack = ({
|
|
|
3249
3249
|
timescale,
|
|
3250
3250
|
track
|
|
3251
3251
|
}) => {
|
|
3252
|
-
const
|
|
3253
|
-
if (!
|
|
3252
|
+
const trackType = getTrackTypeSegment(track);
|
|
3253
|
+
if (!trackType) {
|
|
3254
3254
|
throw new Error("Expected track type segment");
|
|
3255
3255
|
}
|
|
3256
3256
|
const trackId = getTrackId(track);
|
|
3257
|
-
if (trackTypeToString(
|
|
3257
|
+
if (trackTypeToString(trackType.value.value) === "video") {
|
|
3258
3258
|
const width = getWidthSegment(track);
|
|
3259
3259
|
if (width === null) {
|
|
3260
3260
|
throw new Error("Expected width segment");
|
|
@@ -3263,13 +3263,13 @@ var getTrack = ({
|
|
|
3263
3263
|
if (height === null) {
|
|
3264
3264
|
throw new Error("Expected height segment");
|
|
3265
3265
|
}
|
|
3266
|
-
const
|
|
3267
|
-
const
|
|
3266
|
+
const displayHeight = getDisplayHeightSegment(track);
|
|
3267
|
+
const displayWidth = getDisplayWidthSegment(track);
|
|
3268
3268
|
const codec = getCodecSegment(track);
|
|
3269
3269
|
if (!codec) {
|
|
3270
3270
|
return null;
|
|
3271
3271
|
}
|
|
3272
|
-
const
|
|
3272
|
+
const codecPrivate = getPrivateData(track);
|
|
3273
3273
|
const codecString = getMatroskaVideoCodecString({
|
|
3274
3274
|
track,
|
|
3275
3275
|
codecSegment: codec
|
|
@@ -3281,18 +3281,18 @@ var getTrack = ({
|
|
|
3281
3281
|
const codecEnum = getMatroskaVideoCodecEnum({
|
|
3282
3282
|
codecSegment: codec
|
|
3283
3283
|
});
|
|
3284
|
-
const codecData =
|
|
3284
|
+
const codecData = codecPrivate === null ? null : codecEnum === "h264" ? { type: "avc-sps-pps", data: codecPrivate } : codecEnum === "av1" ? {
|
|
3285
3285
|
type: "av1c-data",
|
|
3286
|
-
data:
|
|
3286
|
+
data: codecPrivate
|
|
3287
3287
|
} : codecEnum === "h265" ? {
|
|
3288
3288
|
type: "hvcc-data",
|
|
3289
|
-
data:
|
|
3289
|
+
data: codecPrivate
|
|
3290
3290
|
} : codecEnum === "vp8" ? {
|
|
3291
3291
|
type: "unknown-data",
|
|
3292
|
-
data:
|
|
3292
|
+
data: codecPrivate
|
|
3293
3293
|
} : codecEnum === "vp9" ? {
|
|
3294
3294
|
type: "unknown-data",
|
|
3295
|
-
data:
|
|
3295
|
+
data: codecPrivate
|
|
3296
3296
|
} : null;
|
|
3297
3297
|
const advancedColor = colour ? parseColorSegment(colour) : {
|
|
3298
3298
|
fullRange: null,
|
|
@@ -3306,8 +3306,8 @@ var getTrack = ({
|
|
|
3306
3306
|
trackId,
|
|
3307
3307
|
codec: codecString,
|
|
3308
3308
|
description: getDescription(track),
|
|
3309
|
-
height:
|
|
3310
|
-
width:
|
|
3309
|
+
height: displayHeight ? displayHeight.value.value : height.value.value,
|
|
3310
|
+
width: displayWidth ? displayWidth.value.value : width.value.value,
|
|
3311
3311
|
sampleAspectRatio: {
|
|
3312
3312
|
numerator: 1,
|
|
3313
3313
|
denominator: 1
|
|
@@ -3315,8 +3315,8 @@ var getTrack = ({
|
|
|
3315
3315
|
originalTimescale: timescale,
|
|
3316
3316
|
codedHeight: height.value.value,
|
|
3317
3317
|
codedWidth: width.value.value,
|
|
3318
|
-
displayAspectHeight:
|
|
3319
|
-
displayAspectWidth:
|
|
3318
|
+
displayAspectHeight: displayHeight ? displayHeight.value.value : height.value.value,
|
|
3319
|
+
displayAspectWidth: displayWidth ? displayWidth.value.value : width.value.value,
|
|
3320
3320
|
rotation: 0,
|
|
3321
3321
|
codecData,
|
|
3322
3322
|
colorSpace: mediaParserAdvancedColorToWebCodecsColor(advancedColor),
|
|
@@ -3328,10 +3328,10 @@ var getTrack = ({
|
|
|
3328
3328
|
trackMediaTimeOffsetInTrackTimescale: 0
|
|
3329
3329
|
};
|
|
3330
3330
|
}
|
|
3331
|
-
if (trackTypeToString(
|
|
3331
|
+
if (trackTypeToString(trackType.value.value) === "audio") {
|
|
3332
3332
|
const sampleRate = getSampleRate(track);
|
|
3333
3333
|
const numberOfChannels = getNumberOfChannels(track);
|
|
3334
|
-
const
|
|
3334
|
+
const codecPrivate = getPrivateData(track);
|
|
3335
3335
|
if (sampleRate === null) {
|
|
3336
3336
|
throw new Error("Could not find sample rate or number of channels");
|
|
3337
3337
|
}
|
|
@@ -3344,7 +3344,7 @@ var getTrack = ({
|
|
|
3344
3344
|
numberOfChannels,
|
|
3345
3345
|
sampleRate,
|
|
3346
3346
|
description: getAudioDescription(track),
|
|
3347
|
-
codecData:
|
|
3347
|
+
codecData: codecPrivate ? codecString === "opus" ? { type: "ogg-identification", data: codecPrivate } : { type: "unknown-data", data: codecPrivate } : null,
|
|
3348
3348
|
codecEnum: getMatroskaAudioCodecEnum({
|
|
3349
3349
|
track
|
|
3350
3350
|
}),
|
|
@@ -3469,8 +3469,8 @@ var getCategorizedTracksFromMatroska = (state) => {
|
|
|
3469
3469
|
};
|
|
3470
3470
|
var getTracksFromMoovBox = (moovBox) => {
|
|
3471
3471
|
const mediaParserTracks = [];
|
|
3472
|
-
const
|
|
3473
|
-
for (const trakBox of
|
|
3472
|
+
const tracks = getTraks(moovBox);
|
|
3473
|
+
for (const trakBox of tracks) {
|
|
3474
3474
|
const mvhdBox = getMvhdBox(moovBox);
|
|
3475
3475
|
if (!mvhdBox) {
|
|
3476
3476
|
throw new Error("Mvhd box is not found");
|
|
@@ -3505,11 +3505,11 @@ var getTracksFromIsoBaseMedia = ({
|
|
|
3505
3505
|
return getTracksFromMoovBox(moovBox);
|
|
3506
3506
|
};
|
|
3507
3507
|
var defaultGetTracks = (parserState) => {
|
|
3508
|
-
const
|
|
3509
|
-
if (
|
|
3508
|
+
const tracks = parserState.callbacks.tracks.getTracks();
|
|
3509
|
+
if (tracks.length === 0) {
|
|
3510
3510
|
throw new Error("No tracks found");
|
|
3511
3511
|
}
|
|
3512
|
-
return
|
|
3512
|
+
return tracks;
|
|
3513
3513
|
};
|
|
3514
3514
|
var getTracks = (state, mayUsePrecomputed) => {
|
|
3515
3515
|
const structure = state.structure.getStructure();
|
|
@@ -3538,11 +3538,11 @@ var getTracks = (state, mayUsePrecomputed) => {
|
|
|
3538
3538
|
|
|
3539
3539
|
// src/get-audio-codec.ts
|
|
3540
3540
|
var getAudioCodec = (parserState) => {
|
|
3541
|
-
const
|
|
3542
|
-
if (
|
|
3541
|
+
const tracks = getTracks(parserState, true);
|
|
3542
|
+
if (tracks.length === 0) {
|
|
3543
3543
|
throw new Error("No tracks yet");
|
|
3544
3544
|
}
|
|
3545
|
-
const audioTrack =
|
|
3545
|
+
const audioTrack = tracks.find((t) => t.type === "audio");
|
|
3546
3546
|
if (!audioTrack) {
|
|
3547
3547
|
return null;
|
|
3548
3548
|
}
|
|
@@ -4164,7 +4164,7 @@ var normalizeVideoRotation = (rotation) => {
|
|
|
4164
4164
|
// src/containers/iso-base-media/get-actual-number-of-channels.ts
|
|
4165
4165
|
var getActualDecoderParameters = ({
|
|
4166
4166
|
audioCodec,
|
|
4167
|
-
codecPrivate
|
|
4167
|
+
codecPrivate,
|
|
4168
4168
|
numberOfChannels,
|
|
4169
4169
|
sampleRate
|
|
4170
4170
|
}) => {
|
|
@@ -4172,19 +4172,19 @@ var getActualDecoderParameters = ({
|
|
|
4172
4172
|
return {
|
|
4173
4173
|
numberOfChannels,
|
|
4174
4174
|
sampleRate,
|
|
4175
|
-
codecPrivate
|
|
4175
|
+
codecPrivate
|
|
4176
4176
|
};
|
|
4177
4177
|
}
|
|
4178
|
-
if (
|
|
4179
|
-
return { numberOfChannels, sampleRate, codecPrivate
|
|
4178
|
+
if (codecPrivate === null) {
|
|
4179
|
+
return { numberOfChannels, sampleRate, codecPrivate };
|
|
4180
4180
|
}
|
|
4181
|
-
if (
|
|
4181
|
+
if (codecPrivate.type !== "aac-config") {
|
|
4182
4182
|
throw new Error("Expected AAC codec private data");
|
|
4183
4183
|
}
|
|
4184
|
-
const parsed = parseAacCodecPrivate(
|
|
4184
|
+
const parsed = parseAacCodecPrivate(codecPrivate.data);
|
|
4185
4185
|
const actual = createAacCodecPrivate({
|
|
4186
4186
|
...parsed,
|
|
4187
|
-
codecPrivate:
|
|
4187
|
+
codecPrivate: codecPrivate.data
|
|
4188
4188
|
});
|
|
4189
4189
|
return {
|
|
4190
4190
|
numberOfChannels: parsed.channelConfiguration,
|
|
@@ -4261,11 +4261,11 @@ var makeBaseMediaTrack = (trakBox, startTimeInSeconds) => {
|
|
|
4261
4261
|
throw new Error("Could not find sample rate");
|
|
4262
4262
|
}
|
|
4263
4263
|
const { codecString, description } = getAudioCodecStringFromTrak(trakBox);
|
|
4264
|
-
const
|
|
4264
|
+
const codecPrivate = getCodecPrivateFromTrak(trakBox) ?? description ?? null;
|
|
4265
4265
|
const codecEnum = getAudioCodecFromTrack(trakBox);
|
|
4266
4266
|
const actual = getActualDecoderParameters({
|
|
4267
4267
|
audioCodec: codecEnum,
|
|
4268
|
-
codecPrivate:
|
|
4268
|
+
codecPrivate: codecPrivate ?? null,
|
|
4269
4269
|
numberOfChannels,
|
|
4270
4270
|
sampleRate
|
|
4271
4271
|
});
|
|
@@ -4364,8 +4364,8 @@ var parseMdhd = ({
|
|
|
4364
4364
|
const creationTime = version === 1 ? Number(data.getUint64()) : data.getUint32();
|
|
4365
4365
|
const modificationTime = version === 1 ? Number(data.getUint64()) : data.getUint32();
|
|
4366
4366
|
const timescale = data.getUint32();
|
|
4367
|
-
const
|
|
4368
|
-
const
|
|
4367
|
+
const duration = version === 1 ? data.getUint64() : data.getUint32();
|
|
4368
|
+
const language = data.getUint16();
|
|
4369
4369
|
const quality = data.getUint16();
|
|
4370
4370
|
const remaining = size - (data.counter.getOffset() - fileOffset);
|
|
4371
4371
|
if (remaining !== 0) {
|
|
@@ -4373,10 +4373,10 @@ var parseMdhd = ({
|
|
|
4373
4373
|
}
|
|
4374
4374
|
return {
|
|
4375
4375
|
type: "mdhd-box",
|
|
4376
|
-
duration: Number(
|
|
4376
|
+
duration: Number(duration),
|
|
4377
4377
|
timescale,
|
|
4378
4378
|
version,
|
|
4379
|
-
language
|
|
4379
|
+
language,
|
|
4380
4380
|
quality,
|
|
4381
4381
|
creationTime,
|
|
4382
4382
|
modificationTime
|
|
@@ -4810,7 +4810,7 @@ var parseColorParameterBox = ({
|
|
|
4810
4810
|
}) => {
|
|
4811
4811
|
const byteString = iterator.getByteString(4, false);
|
|
4812
4812
|
if (byteString === "nclx") {
|
|
4813
|
-
const
|
|
4813
|
+
const primaries = iterator.getUint16();
|
|
4814
4814
|
const transfer = iterator.getUint16();
|
|
4815
4815
|
const matrixIndex = iterator.getUint16();
|
|
4816
4816
|
iterator.startReadingBits();
|
|
@@ -4821,12 +4821,12 @@ var parseColorParameterBox = ({
|
|
|
4821
4821
|
colorType: "transfer-characteristics",
|
|
4822
4822
|
fullRangeFlag,
|
|
4823
4823
|
matrixIndex,
|
|
4824
|
-
primaries
|
|
4824
|
+
primaries,
|
|
4825
4825
|
transfer
|
|
4826
4826
|
};
|
|
4827
4827
|
}
|
|
4828
4828
|
if (byteString === "nclc") {
|
|
4829
|
-
const
|
|
4829
|
+
const primaries = iterator.getUint16();
|
|
4830
4830
|
const transfer = iterator.getUint16();
|
|
4831
4831
|
const matrixIndex = iterator.getUint16();
|
|
4832
4832
|
return {
|
|
@@ -4834,7 +4834,7 @@ var parseColorParameterBox = ({
|
|
|
4834
4834
|
colorType: "transfer-characteristics",
|
|
4835
4835
|
fullRangeFlag: false,
|
|
4836
4836
|
matrixIndex,
|
|
4837
|
-
primaries
|
|
4837
|
+
primaries,
|
|
4838
4838
|
transfer
|
|
4839
4839
|
};
|
|
4840
4840
|
}
|
|
@@ -5192,9 +5192,9 @@ var parseStts = ({
|
|
|
5192
5192
|
var getvp09ConfigurationString = ({
|
|
5193
5193
|
profile,
|
|
5194
5194
|
level,
|
|
5195
|
-
bitDepth
|
|
5195
|
+
bitDepth
|
|
5196
5196
|
}) => {
|
|
5197
|
-
return `${String(profile).padStart(2, "0")}.${String(level).padStart(2, "0")}.${String(
|
|
5197
|
+
return `${String(profile).padStart(2, "0")}.${String(level).padStart(2, "0")}.${String(bitDepth).padStart(2, "0")}`;
|
|
5198
5198
|
};
|
|
5199
5199
|
var parseVpcc = ({
|
|
5200
5200
|
data,
|
|
@@ -5209,7 +5209,7 @@ var parseVpcc = ({
|
|
|
5209
5209
|
const profile = data.getUint8();
|
|
5210
5210
|
const level = data.getUint8();
|
|
5211
5211
|
data.startReadingBits();
|
|
5212
|
-
const
|
|
5212
|
+
const bitDepth = data.getBits(4);
|
|
5213
5213
|
const chromaSubsampling = data.getBits(3);
|
|
5214
5214
|
const videoFullRangeFlag = data.getBits(1);
|
|
5215
5215
|
const videoColorPrimaries = data.getBits(8);
|
|
@@ -5223,7 +5223,7 @@ var parseVpcc = ({
|
|
|
5223
5223
|
type: "vpcc-box",
|
|
5224
5224
|
profile,
|
|
5225
5225
|
level,
|
|
5226
|
-
bitDepth
|
|
5226
|
+
bitDepth,
|
|
5227
5227
|
chromaSubsampling,
|
|
5228
5228
|
videoFullRangeFlag,
|
|
5229
5229
|
videoColorPrimaries,
|
|
@@ -5231,7 +5231,7 @@ var parseVpcc = ({
|
|
|
5231
5231
|
videoMatrixCoefficients,
|
|
5232
5232
|
codecInitializationDataSize,
|
|
5233
5233
|
codecInitializationData,
|
|
5234
|
-
codecString: getvp09ConfigurationString({ profile, level, bitDepth
|
|
5234
|
+
codecString: getvp09ConfigurationString({ profile, level, bitDepth })
|
|
5235
5235
|
};
|
|
5236
5236
|
};
|
|
5237
5237
|
|
|
@@ -5327,7 +5327,7 @@ var parseTkhd = ({
|
|
|
5327
5327
|
const modificationTime = version === 1 ? iterator.getUint64() : iterator.getUint32();
|
|
5328
5328
|
const trackId = iterator.getUint32();
|
|
5329
5329
|
iterator.discard(4);
|
|
5330
|
-
const
|
|
5330
|
+
const duration = version === 1 ? iterator.getUint64() : iterator.getUint32();
|
|
5331
5331
|
iterator.discard(4);
|
|
5332
5332
|
iterator.discard(4);
|
|
5333
5333
|
const layer = iterator.getUint16();
|
|
@@ -5361,7 +5361,7 @@ var parseTkhd = ({
|
|
|
5361
5361
|
creationTime: toUnixTimestamp(Number(creationTime)),
|
|
5362
5362
|
modificationTime: toUnixTimestamp(Number(modificationTime)),
|
|
5363
5363
|
trackId,
|
|
5364
|
-
duration: Number(
|
|
5364
|
+
duration: Number(duration),
|
|
5365
5365
|
layer,
|
|
5366
5366
|
alternateGroup,
|
|
5367
5367
|
volume,
|
|
@@ -5668,8 +5668,8 @@ var processBox = async ({
|
|
|
5668
5668
|
if (!onlyIfMoovAtomExpected) {
|
|
5669
5669
|
throw new Error("State is required");
|
|
5670
5670
|
}
|
|
5671
|
-
const { tracks
|
|
5672
|
-
if (
|
|
5671
|
+
const { tracks, isoState } = onlyIfMoovAtomExpected;
|
|
5672
|
+
if (tracks.hasAllTracks()) {
|
|
5673
5673
|
iterator.discard(boxSize - 8);
|
|
5674
5674
|
return { type: "nothing" };
|
|
5675
5675
|
}
|
|
@@ -5686,14 +5686,14 @@ var processBox = async ({
|
|
|
5686
5686
|
logLevel,
|
|
5687
5687
|
contentLength
|
|
5688
5688
|
});
|
|
5689
|
-
|
|
5689
|
+
tracks.setIsDone(logLevel);
|
|
5690
5690
|
return { type: "box", box };
|
|
5691
5691
|
}
|
|
5692
5692
|
if (boxType === "trak") {
|
|
5693
5693
|
if (!onlyIfMoovAtomExpected) {
|
|
5694
5694
|
throw new Error("State is required");
|
|
5695
5695
|
}
|
|
5696
|
-
const { tracks
|
|
5696
|
+
const { tracks, onAudioTrack, onVideoTrack } = onlyIfMoovAtomExpected;
|
|
5697
5697
|
const trakBox = await parseTrak({
|
|
5698
5698
|
size: boxSize,
|
|
5699
5699
|
offsetAtStart: fileOffset,
|
|
@@ -5714,7 +5714,7 @@ var processBox = async ({
|
|
|
5714
5714
|
logLevel,
|
|
5715
5715
|
onVideoTrack,
|
|
5716
5716
|
registerVideoSampleCallback: onlyIfMoovAtomExpected.registerVideoSampleCallback,
|
|
5717
|
-
tracks
|
|
5717
|
+
tracks
|
|
5718
5718
|
});
|
|
5719
5719
|
}
|
|
5720
5720
|
if (transformedTrack && transformedTrack.type === "audio") {
|
|
@@ -5722,7 +5722,7 @@ var processBox = async ({
|
|
|
5722
5722
|
track: transformedTrack,
|
|
5723
5723
|
container: "mp4",
|
|
5724
5724
|
registerAudioSampleCallback: onlyIfMoovAtomExpected.registerAudioSampleCallback,
|
|
5725
|
-
tracks
|
|
5725
|
+
tracks,
|
|
5726
5726
|
logLevel,
|
|
5727
5727
|
onAudioTrack
|
|
5728
5728
|
});
|
|
@@ -6506,7 +6506,7 @@ var addAvcToTrackAndActivateTrackIfNecessary = async ({
|
|
|
6506
6506
|
codec,
|
|
6507
6507
|
structureState,
|
|
6508
6508
|
webmState,
|
|
6509
|
-
trackNumber
|
|
6509
|
+
trackNumber,
|
|
6510
6510
|
logLevel,
|
|
6511
6511
|
callbacks,
|
|
6512
6512
|
onVideoTrack,
|
|
@@ -6525,18 +6525,18 @@ var addAvcToTrackAndActivateTrackIfNecessary = async ({
|
|
|
6525
6525
|
const parsed = parseAvc(partialVideoSample.data, avcState);
|
|
6526
6526
|
for (const parse of parsed) {
|
|
6527
6527
|
if (parse.type === "avc-profile") {
|
|
6528
|
-
webmState.setAvcProfileForTrackNumber(
|
|
6529
|
-
const track = missingTracks.find((t) => t.trackId ===
|
|
6528
|
+
webmState.setAvcProfileForTrackNumber(trackNumber, parse);
|
|
6529
|
+
const track = missingTracks.find((t) => t.trackId === trackNumber);
|
|
6530
6530
|
if (!track) {
|
|
6531
|
-
throw new Error("Could not find track " +
|
|
6531
|
+
throw new Error("Could not find track " + trackNumber);
|
|
6532
6532
|
}
|
|
6533
6533
|
const resolvedTracks = getTracksFromMatroska({
|
|
6534
6534
|
structureState,
|
|
6535
6535
|
webmState
|
|
6536
6536
|
}).resolved;
|
|
6537
|
-
const resolvedTrack = resolvedTracks.find((t) => t.trackId ===
|
|
6537
|
+
const resolvedTrack = resolvedTracks.find((t) => t.trackId === trackNumber);
|
|
6538
6538
|
if (!resolvedTrack) {
|
|
6539
|
-
throw new Error("Could not find track " +
|
|
6539
|
+
throw new Error("Could not find track " + trackNumber);
|
|
6540
6540
|
}
|
|
6541
6541
|
await registerVideoTrack({
|
|
6542
6542
|
track: resolvedTrack,
|
|
@@ -6564,13 +6564,13 @@ var getSampleFromBlock = async ({
|
|
|
6564
6564
|
maxBytes: ebml.value.length,
|
|
6565
6565
|
logLevel: "error"
|
|
6566
6566
|
});
|
|
6567
|
-
const
|
|
6568
|
-
if (
|
|
6567
|
+
const trackNumber = iterator.getVint();
|
|
6568
|
+
if (trackNumber === null) {
|
|
6569
6569
|
throw new Error("Not enough data to get track number, should not happen");
|
|
6570
6570
|
}
|
|
6571
6571
|
const timecodeRelativeToCluster = iterator.getInt16();
|
|
6572
6572
|
const { keyframe } = parseBlockFlags(iterator, ebml.type === "SimpleBlock" ? matroskaElements.SimpleBlock : matroskaElements.Block);
|
|
6573
|
-
const { codec, trackTimescale } = webmState.getTrackInfoByNumber(
|
|
6573
|
+
const { codec, trackTimescale } = webmState.getTrackInfoByNumber(trackNumber);
|
|
6574
6574
|
const clusterOffset = webmState.getTimestampOffsetForByteOffset(offset);
|
|
6575
6575
|
const timescale = webmState.getTimescale();
|
|
6576
6576
|
if (clusterOffset === undefined) {
|
|
@@ -6579,7 +6579,7 @@ var getSampleFromBlock = async ({
|
|
|
6579
6579
|
const timecodeInNanoSeconds = (timecodeRelativeToCluster + clusterOffset) * timescale * (trackTimescale ?? 1);
|
|
6580
6580
|
const timecodeInMicroseconds = timecodeInNanoSeconds / 1000;
|
|
6581
6581
|
if (!codec) {
|
|
6582
|
-
throw new Error(`Could not find codec for track ${
|
|
6582
|
+
throw new Error(`Could not find codec for track ${trackNumber}`);
|
|
6583
6583
|
}
|
|
6584
6584
|
const remainingNow = ebml.value.length - iterator.counter.getOffset();
|
|
6585
6585
|
if (codec.startsWith("V_")) {
|
|
@@ -6595,7 +6595,7 @@ var getSampleFromBlock = async ({
|
|
|
6595
6595
|
return {
|
|
6596
6596
|
type: "partial-video-sample",
|
|
6597
6597
|
partialVideoSample,
|
|
6598
|
-
trackId:
|
|
6598
|
+
trackId: trackNumber,
|
|
6599
6599
|
timescale: WEBCODECS_TIMESCALE
|
|
6600
6600
|
};
|
|
6601
6601
|
}
|
|
@@ -6604,7 +6604,7 @@ var getSampleFromBlock = async ({
|
|
|
6604
6604
|
partialVideoSample,
|
|
6605
6605
|
structureState,
|
|
6606
6606
|
webmState,
|
|
6607
|
-
trackNumber
|
|
6607
|
+
trackNumber,
|
|
6608
6608
|
callbacks,
|
|
6609
6609
|
logLevel,
|
|
6610
6610
|
onVideoTrack,
|
|
@@ -6618,7 +6618,7 @@ var getSampleFromBlock = async ({
|
|
|
6618
6618
|
return {
|
|
6619
6619
|
type: "video-sample",
|
|
6620
6620
|
videoSample: sample,
|
|
6621
|
-
trackId:
|
|
6621
|
+
trackId: trackNumber,
|
|
6622
6622
|
timescale: WEBCODECS_TIMESCALE
|
|
6623
6623
|
};
|
|
6624
6624
|
}
|
|
@@ -6635,7 +6635,7 @@ var getSampleFromBlock = async ({
|
|
|
6635
6635
|
return {
|
|
6636
6636
|
type: "audio-sample",
|
|
6637
6637
|
audioSample,
|
|
6638
|
-
trackId:
|
|
6638
|
+
trackId: trackNumber,
|
|
6639
6639
|
timescale: WEBCODECS_TIMESCALE
|
|
6640
6640
|
};
|
|
6641
6641
|
}
|
|
@@ -6831,13 +6831,13 @@ var postprocessEbml = async ({
|
|
|
6831
6831
|
}
|
|
6832
6832
|
}
|
|
6833
6833
|
if (ebml.type === "BlockGroup") {
|
|
6834
|
-
const
|
|
6835
|
-
if (!
|
|
6834
|
+
const block = ebml.value.find((c) => c.type === "SimpleBlock" || c.type === "Block");
|
|
6835
|
+
if (!block || block.type !== "SimpleBlock" && block.type !== "Block") {
|
|
6836
6836
|
throw new Error("Expected block segment");
|
|
6837
6837
|
}
|
|
6838
6838
|
const hasReferenceBlock = ebml.value.find((c) => c.type === "ReferenceBlock");
|
|
6839
|
-
const sample =
|
|
6840
|
-
ebml:
|
|
6839
|
+
const sample = block.value.length === 0 ? null : await getSampleFromBlock({
|
|
6840
|
+
ebml: block,
|
|
6841
6841
|
webmState,
|
|
6842
6842
|
offset,
|
|
6843
6843
|
structureState,
|
|
@@ -7001,9 +7001,9 @@ class MediaParserEmitter {
|
|
|
7001
7001
|
this.dispatchEvent("abort", { reason });
|
|
7002
7002
|
});
|
|
7003
7003
|
};
|
|
7004
|
-
dispatchSeek = (
|
|
7004
|
+
dispatchSeek = (seek) => {
|
|
7005
7005
|
this.readyPromise = this.readyPromise.then(() => {
|
|
7006
|
-
this.dispatchEvent("seek", { seek
|
|
7006
|
+
this.dispatchEvent("seek", { seek });
|
|
7007
7007
|
});
|
|
7008
7008
|
};
|
|
7009
7009
|
}
|
|
@@ -7052,8 +7052,8 @@ var performedSeeksStats = () => {
|
|
|
7052
7052
|
}
|
|
7053
7053
|
};
|
|
7054
7054
|
return {
|
|
7055
|
-
recordSeek: (
|
|
7056
|
-
performedSeeks.push(
|
|
7055
|
+
recordSeek: (seek) => {
|
|
7056
|
+
performedSeeks.push(seek);
|
|
7057
7057
|
},
|
|
7058
7058
|
getPerformedSeeks: () => {
|
|
7059
7059
|
return performedSeeks;
|
|
@@ -7064,18 +7064,18 @@ var performedSeeksStats = () => {
|
|
|
7064
7064
|
|
|
7065
7065
|
// src/controller/seek-signal.ts
|
|
7066
7066
|
var makeSeekSignal = (emitter) => {
|
|
7067
|
-
let
|
|
7067
|
+
let seek = null;
|
|
7068
7068
|
return {
|
|
7069
7069
|
seek: (seekRequest) => {
|
|
7070
|
-
|
|
7070
|
+
seek = seekRequest;
|
|
7071
7071
|
emitter.dispatchSeek(seekRequest);
|
|
7072
7072
|
},
|
|
7073
7073
|
getSeek() {
|
|
7074
|
-
return
|
|
7074
|
+
return seek;
|
|
7075
7075
|
},
|
|
7076
7076
|
clearSeekIfStillSame(previousSeek) {
|
|
7077
|
-
if (
|
|
7078
|
-
|
|
7077
|
+
if (seek === previousSeek) {
|
|
7078
|
+
seek = null;
|
|
7079
7079
|
return { hasChanged: false };
|
|
7080
7080
|
}
|
|
7081
7081
|
return { hasChanged: true };
|
|
@@ -7276,11 +7276,11 @@ var getDimensions = (state) => {
|
|
|
7276
7276
|
if (structure && isAudioStructure(structure)) {
|
|
7277
7277
|
return null;
|
|
7278
7278
|
}
|
|
7279
|
-
const
|
|
7280
|
-
if (!
|
|
7279
|
+
const tracks = getTracks(state, true);
|
|
7280
|
+
if (!tracks.length) {
|
|
7281
7281
|
return null;
|
|
7282
7282
|
}
|
|
7283
|
-
const firstVideoTrack =
|
|
7283
|
+
const firstVideoTrack = tracks.find((t) => t.type === "video");
|
|
7284
7284
|
if (!firstVideoTrack) {
|
|
7285
7285
|
return null;
|
|
7286
7286
|
}
|
|
@@ -7349,8 +7349,8 @@ var getSamplesFromTraf = (trafSegment, moofOffset, trexBoxes) => {
|
|
|
7349
7349
|
}
|
|
7350
7350
|
for (const sample of trunBox.samples) {
|
|
7351
7351
|
i++;
|
|
7352
|
-
const
|
|
7353
|
-
if (
|
|
7352
|
+
const duration = sample.sampleDuration || defaultTrackSampleDuration;
|
|
7353
|
+
if (duration === null) {
|
|
7354
7354
|
throw new Error("Expected duration");
|
|
7355
7355
|
}
|
|
7356
7356
|
const size = sample.sampleSize ?? defaultTrackSampleSize;
|
|
@@ -7368,7 +7368,7 @@ var getSamplesFromTraf = (trafSegment, moofOffset, trexBoxes) => {
|
|
|
7368
7368
|
offset: offset + (moofOffset ?? 0) + (dataOffset ?? 0),
|
|
7369
7369
|
decodingTimestamp: dts,
|
|
7370
7370
|
timestamp: dts + (sample.sampleCompositionTimeOffset ?? 0),
|
|
7371
|
-
duration
|
|
7371
|
+
duration,
|
|
7372
7372
|
isKeyframe: keyframe,
|
|
7373
7373
|
size,
|
|
7374
7374
|
chunk: 0,
|
|
@@ -7377,7 +7377,7 @@ var getSamplesFromTraf = (trafSegment, moofOffset, trexBoxes) => {
|
|
|
7377
7377
|
};
|
|
7378
7378
|
samples.push(samplePosition);
|
|
7379
7379
|
offset += size;
|
|
7380
|
-
time +=
|
|
7380
|
+
time += duration;
|
|
7381
7381
|
}
|
|
7382
7382
|
}
|
|
7383
7383
|
return samples;
|
|
@@ -7645,11 +7645,11 @@ var getPlaylist = (structure, src) => {
|
|
|
7645
7645
|
return playlists;
|
|
7646
7646
|
};
|
|
7647
7647
|
var getDurationFromPlaylist = (playlist) => {
|
|
7648
|
-
const
|
|
7649
|
-
if (
|
|
7648
|
+
const duration = playlist.boxes.filter((box) => box.type === "m3u-extinf");
|
|
7649
|
+
if (duration.length === 0) {
|
|
7650
7650
|
throw new Error("Expected duration in m3u playlist");
|
|
7651
7651
|
}
|
|
7652
|
-
return
|
|
7652
|
+
return duration.reduce((acc, d) => acc + d.value, 0);
|
|
7653
7653
|
};
|
|
7654
7654
|
|
|
7655
7655
|
// src/containers/m3u/get-duration-from-m3u.ts
|
|
@@ -7667,19 +7667,19 @@ var getDurationFromM3u = (state) => {
|
|
|
7667
7667
|
var getUnroundedMpegFrameLength = ({
|
|
7668
7668
|
samplesPerFrame,
|
|
7669
7669
|
bitrateKbit,
|
|
7670
|
-
samplingFrequency
|
|
7670
|
+
samplingFrequency,
|
|
7671
7671
|
padding,
|
|
7672
7672
|
layer
|
|
7673
7673
|
}) => {
|
|
7674
7674
|
if (layer === 1) {
|
|
7675
7675
|
throw new Error("MPEG Layer I is not supported");
|
|
7676
7676
|
}
|
|
7677
|
-
return samplesPerFrame / 8 * bitrateKbit /
|
|
7677
|
+
return samplesPerFrame / 8 * bitrateKbit / samplingFrequency * 1000 + (padding ? layer === 1 ? 4 : 1 : 0);
|
|
7678
7678
|
};
|
|
7679
7679
|
var getAverageMpegFrameLength = ({
|
|
7680
7680
|
samplesPerFrame,
|
|
7681
7681
|
bitrateKbit,
|
|
7682
|
-
samplingFrequency
|
|
7682
|
+
samplingFrequency,
|
|
7683
7683
|
layer
|
|
7684
7684
|
}) => {
|
|
7685
7685
|
const withoutPadding = getUnroundedMpegFrameLength({
|
|
@@ -7687,7 +7687,7 @@ var getAverageMpegFrameLength = ({
|
|
|
7687
7687
|
layer,
|
|
7688
7688
|
padding: false,
|
|
7689
7689
|
samplesPerFrame,
|
|
7690
|
-
samplingFrequency
|
|
7690
|
+
samplingFrequency
|
|
7691
7691
|
});
|
|
7692
7692
|
const rounded = Math.floor(withoutPadding);
|
|
7693
7693
|
const rest = withoutPadding % 1;
|
|
@@ -7696,7 +7696,7 @@ var getAverageMpegFrameLength = ({
|
|
|
7696
7696
|
var getMpegFrameLength = ({
|
|
7697
7697
|
samplesPerFrame,
|
|
7698
7698
|
bitrateKbit,
|
|
7699
|
-
samplingFrequency
|
|
7699
|
+
samplingFrequency,
|
|
7700
7700
|
padding,
|
|
7701
7701
|
layer
|
|
7702
7702
|
}) => {
|
|
@@ -7705,7 +7705,7 @@ var getMpegFrameLength = ({
|
|
|
7705
7705
|
layer,
|
|
7706
7706
|
padding,
|
|
7707
7707
|
samplesPerFrame,
|
|
7708
|
-
samplingFrequency
|
|
7708
|
+
samplingFrequency
|
|
7709
7709
|
}));
|
|
7710
7710
|
};
|
|
7711
7711
|
|
|
@@ -7841,15 +7841,15 @@ var getDurationFromMatroska = (segments) => {
|
|
|
7841
7841
|
...mainSegment.value,
|
|
7842
7842
|
...infoSegment && infoSegment.type === "Info" ? infoSegment.value : []
|
|
7843
7843
|
];
|
|
7844
|
-
const
|
|
7845
|
-
if (!
|
|
7844
|
+
const timestampScale = relevantBoxes.find((s) => s.type === "TimestampScale");
|
|
7845
|
+
if (!timestampScale || timestampScale.type !== "TimestampScale") {
|
|
7846
7846
|
return null;
|
|
7847
7847
|
}
|
|
7848
|
-
const
|
|
7849
|
-
if (!
|
|
7848
|
+
const duration = relevantBoxes.find((s) => s.type === "Duration");
|
|
7849
|
+
if (!duration || duration.type !== "Duration") {
|
|
7850
7850
|
return null;
|
|
7851
7851
|
}
|
|
7852
|
-
return
|
|
7852
|
+
return duration.value.value / timestampScale.value.value * 1000;
|
|
7853
7853
|
};
|
|
7854
7854
|
var getDurationFromIsoBaseMedia = (parserState) => {
|
|
7855
7855
|
const structure = parserState.structure.getIsoStructure();
|
|
@@ -7881,8 +7881,8 @@ var getDurationFromIsoBaseMedia = (parserState) => {
|
|
|
7881
7881
|
if (mvhdBox.durationInSeconds > 0) {
|
|
7882
7882
|
return mvhdBox.durationInSeconds;
|
|
7883
7883
|
}
|
|
7884
|
-
const
|
|
7885
|
-
const allSamples =
|
|
7884
|
+
const tracks = getTracks(parserState, true);
|
|
7885
|
+
const allSamples = tracks.map((t) => {
|
|
7886
7886
|
const { originalTimescale: ts } = t;
|
|
7887
7887
|
const trakBox = getTrakBoxByTrackId(moovBox, t.trackId);
|
|
7888
7888
|
if (!trakBox) {
|
|
@@ -7963,8 +7963,8 @@ var isVideoTrackHdr = (track) => {
|
|
|
7963
7963
|
return track.advancedColor.matrix === "bt2020-ncl" && (track.advancedColor.transfer === "hlg" || track.advancedColor.transfer === "pq") && track.advancedColor.primaries === "bt2020";
|
|
7964
7964
|
};
|
|
7965
7965
|
var getIsHdr = (state) => {
|
|
7966
|
-
const
|
|
7967
|
-
return
|
|
7966
|
+
const tracks = getTracks(state, true);
|
|
7967
|
+
return tracks.some((track) => track.type === "video" && isVideoTrackHdr(track));
|
|
7968
7968
|
};
|
|
7969
7969
|
var hasHdr = (state) => {
|
|
7970
7970
|
return getHasTracks(state, true);
|
|
@@ -7972,13 +7972,13 @@ var hasHdr = (state) => {
|
|
|
7972
7972
|
|
|
7973
7973
|
// src/containers/iso-base-media/get-keyframes.ts
|
|
7974
7974
|
var getKeyframesFromIsoBaseMedia = (state) => {
|
|
7975
|
-
const
|
|
7975
|
+
const tracks = getTracksFromIsoBaseMedia({
|
|
7976
7976
|
isoState: state.iso,
|
|
7977
7977
|
m3uPlaylistContext: state.m3uPlaylistContext,
|
|
7978
7978
|
structure: state.structure,
|
|
7979
7979
|
mayUsePrecomputed: true
|
|
7980
7980
|
});
|
|
7981
|
-
const videoTracks =
|
|
7981
|
+
const videoTracks = tracks.filter((t) => t.type === "video");
|
|
7982
7982
|
const structure = state.structure.getIsoStructure();
|
|
7983
7983
|
const moofBoxes = getMoofBoxes(structure.boxes);
|
|
7984
7984
|
const tfraBoxes = getTfraBoxes(structure.boxes);
|
|
@@ -8196,8 +8196,8 @@ var getMetadataFromMatroska = (structure) => {
|
|
|
8196
8196
|
if (segment.type !== "Segment") {
|
|
8197
8197
|
continue;
|
|
8198
8198
|
}
|
|
8199
|
-
const
|
|
8200
|
-
for (const tag of
|
|
8199
|
+
const tags = segment.value.filter((s) => s.type === "Tags");
|
|
8200
|
+
for (const tag of tags) {
|
|
8201
8201
|
for (const child of tag.value) {
|
|
8202
8202
|
if (child.type !== "Tag") {
|
|
8203
8203
|
continue;
|
|
@@ -8255,8 +8255,8 @@ var getMetadata = (state) => {
|
|
|
8255
8255
|
return [];
|
|
8256
8256
|
}
|
|
8257
8257
|
if (structure.type === "mp3") {
|
|
8258
|
-
const
|
|
8259
|
-
return
|
|
8258
|
+
const tags = getMetadataFromMp3(structure);
|
|
8259
|
+
return tags ?? [];
|
|
8260
8260
|
}
|
|
8261
8261
|
if (structure.type === "wav") {
|
|
8262
8262
|
return getMetadataFromWav(structure) ?? [];
|
|
@@ -8622,13 +8622,13 @@ var getSeekingByteFromFragmentedMp4 = async ({
|
|
|
8622
8622
|
logLevel,
|
|
8623
8623
|
currentPosition,
|
|
8624
8624
|
isoState,
|
|
8625
|
-
tracks
|
|
8625
|
+
tracks,
|
|
8626
8626
|
isLastChunkInPlaylist,
|
|
8627
8627
|
structure,
|
|
8628
8628
|
mp4HeaderSegment
|
|
8629
8629
|
}) => {
|
|
8630
|
-
const firstVideoTrack =
|
|
8631
|
-
const firstTrack = firstVideoTrack ??
|
|
8630
|
+
const firstVideoTrack = tracks.find((t) => t.type === "video");
|
|
8631
|
+
const firstTrack = firstVideoTrack ?? tracks.find((t) => t.type === "audio");
|
|
8632
8632
|
if (!firstTrack) {
|
|
8633
8633
|
throw new Error("no video and no audio tracks");
|
|
8634
8634
|
}
|
|
@@ -8730,7 +8730,7 @@ var getSeekingByteFromIsoBaseMedia = ({
|
|
|
8730
8730
|
m3uPlaylistContext,
|
|
8731
8731
|
structure
|
|
8732
8732
|
}) => {
|
|
8733
|
-
const
|
|
8733
|
+
const tracks = getTracksFromIsoBaseMedia({
|
|
8734
8734
|
isoState,
|
|
8735
8735
|
m3uPlaylistContext,
|
|
8736
8736
|
structure,
|
|
@@ -8755,13 +8755,13 @@ var getSeekingByteFromIsoBaseMedia = ({
|
|
|
8755
8755
|
logLevel,
|
|
8756
8756
|
currentPosition,
|
|
8757
8757
|
isoState,
|
|
8758
|
-
tracks
|
|
8758
|
+
tracks,
|
|
8759
8759
|
isLastChunkInPlaylist: m3uPlaylistContext?.isLastChunkInPlaylist ?? false,
|
|
8760
8760
|
structure,
|
|
8761
8761
|
mp4HeaderSegment: m3uPlaylistContext?.mp4HeaderSegment ?? null
|
|
8762
8762
|
});
|
|
8763
8763
|
}
|
|
8764
|
-
const trackWithSamplePositions = findTrackToSeek(
|
|
8764
|
+
const trackWithSamplePositions = findTrackToSeek(tracks, structure);
|
|
8765
8765
|
if (!trackWithSamplePositions) {
|
|
8766
8766
|
return Promise.resolve({
|
|
8767
8767
|
type: "valid-but-must-wait"
|
|
@@ -9002,7 +9002,7 @@ var getSeekPointFromXing = ({
|
|
|
9002
9002
|
layer: mp3Info.layer,
|
|
9003
9003
|
mpegVersion: mp3Info.mpegVersion
|
|
9004
9004
|
});
|
|
9005
|
-
const
|
|
9005
|
+
const duration = getDurationFromMp3Xing({
|
|
9006
9006
|
xingData,
|
|
9007
9007
|
samplesPerFrame
|
|
9008
9008
|
});
|
|
@@ -9014,7 +9014,7 @@ var getSeekPointFromXing = ({
|
|
|
9014
9014
|
}
|
|
9015
9015
|
return getSeekPointInBytes({
|
|
9016
9016
|
fileSize: xingData.fileSize,
|
|
9017
|
-
percentBetween0And100: timeToTarget /
|
|
9017
|
+
percentBetween0And100: timeToTarget / duration * 100,
|
|
9018
9018
|
tableOfContents: xingData.tableOfContents
|
|
9019
9019
|
});
|
|
9020
9020
|
};
|
|
@@ -9192,12 +9192,12 @@ var getSampleAspectRatioFromSps = (sps) => {
|
|
|
9192
9192
|
};
|
|
9193
9193
|
};
|
|
9194
9194
|
var getVideoColorFromSps = (sps) => {
|
|
9195
|
-
const
|
|
9196
|
-
const
|
|
9195
|
+
const matrixCoefficients = sps.vui_parameters?.matrix_coefficients;
|
|
9196
|
+
const transferCharacteristics = sps.vui_parameters?.transfer_characteristics;
|
|
9197
9197
|
const colorPrimaries = sps.vui_parameters?.colour_primaries;
|
|
9198
9198
|
return {
|
|
9199
|
-
matrix:
|
|
9200
|
-
transfer:
|
|
9199
|
+
matrix: matrixCoefficients ? getMatrixCoefficientsFromIndex(matrixCoefficients) : null,
|
|
9200
|
+
transfer: transferCharacteristics ? getTransferCharacteristicsFromIndex(transferCharacteristics) : null,
|
|
9201
9201
|
primaries: colorPrimaries ? getPrimariesFromIndex(colorPrimaries) : null,
|
|
9202
9202
|
fullRange: sps.vui_parameters?.video_full_range_flag ?? null
|
|
9203
9203
|
};
|
|
@@ -9248,7 +9248,7 @@ var handleAvcPacket = async ({
|
|
|
9248
9248
|
trackId: programId,
|
|
9249
9249
|
newOffset: startOffset
|
|
9250
9250
|
});
|
|
9251
|
-
const
|
|
9251
|
+
const codecPrivate = createSpsPpsData(spsAndPps);
|
|
9252
9252
|
const advancedColor = getVideoColorFromSps(spsAndPps.sps.spsData);
|
|
9253
9253
|
const track = {
|
|
9254
9254
|
m3uStreamFormat: null,
|
|
@@ -9257,7 +9257,7 @@ var handleAvcPacket = async ({
|
|
|
9257
9257
|
type: "video",
|
|
9258
9258
|
originalTimescale: MPEG_TIMESCALE,
|
|
9259
9259
|
codec: getCodecStringFromSpsAndPps(spsAndPps.sps),
|
|
9260
|
-
codecData: { type: "avc-sps-pps", data:
|
|
9260
|
+
codecData: { type: "avc-sps-pps", data: codecPrivate },
|
|
9261
9261
|
fps: null,
|
|
9262
9262
|
codedWidth: dimensions.width,
|
|
9263
9263
|
codedHeight: dimensions.height,
|
|
@@ -9630,7 +9630,7 @@ var getSeekingHintsFromMp4 = ({
|
|
|
9630
9630
|
structureState,
|
|
9631
9631
|
isoState,
|
|
9632
9632
|
mp4HeaderSegment,
|
|
9633
|
-
mediaSectionState
|
|
9633
|
+
mediaSectionState
|
|
9634
9634
|
}) => {
|
|
9635
9635
|
const structure = structureState.getIsoStructure();
|
|
9636
9636
|
const moovAtom = getMoovBoxFromState({
|
|
@@ -9655,7 +9655,7 @@ var getSeekingHintsFromMp4 = ({
|
|
|
9655
9655
|
moovBox: moovAtom,
|
|
9656
9656
|
moofBoxes,
|
|
9657
9657
|
tfraBoxes,
|
|
9658
|
-
mediaSections:
|
|
9658
|
+
mediaSections: mediaSectionState.getMediaSections(),
|
|
9659
9659
|
mfraAlreadyLoaded: isoState.mfra.getIfAlreadyLoaded()
|
|
9660
9660
|
};
|
|
9661
9661
|
};
|
|
@@ -9672,7 +9672,7 @@ var getSeekingHintsForM3u = () => {
|
|
|
9672
9672
|
var getSeekingHintsForMp3 = ({
|
|
9673
9673
|
mp3State,
|
|
9674
9674
|
samplesObserved,
|
|
9675
|
-
mediaSectionState
|
|
9675
|
+
mediaSectionState,
|
|
9676
9676
|
contentLength
|
|
9677
9677
|
}) => {
|
|
9678
9678
|
return {
|
|
@@ -9681,7 +9681,7 @@ var getSeekingHintsForMp3 = ({
|
|
|
9681
9681
|
lastSampleObserved: samplesObserved.getLastSampleObserved(),
|
|
9682
9682
|
mp3BitrateInfo: mp3State.getMp3BitrateInfo(),
|
|
9683
9683
|
mp3Info: mp3State.getMp3Info(),
|
|
9684
|
-
mediaSection:
|
|
9684
|
+
mediaSection: mediaSectionState.getMediaSections()[0] ?? null,
|
|
9685
9685
|
contentLength
|
|
9686
9686
|
};
|
|
9687
9687
|
};
|
|
@@ -9701,7 +9701,7 @@ var riffHasIndex = (structure) => {
|
|
|
9701
9701
|
var getSeekingHintsForRiff = ({
|
|
9702
9702
|
structureState,
|
|
9703
9703
|
riffState,
|
|
9704
|
-
mediaSectionState
|
|
9704
|
+
mediaSectionState
|
|
9705
9705
|
}) => {
|
|
9706
9706
|
const structure = structureState.getRiffStructure();
|
|
9707
9707
|
const strl = getStrlBoxes(structure);
|
|
@@ -9722,7 +9722,7 @@ var getSeekingHintsForRiff = ({
|
|
|
9722
9722
|
hasIndex: riffHasIndex(structure),
|
|
9723
9723
|
idx1Entries: riffState.lazyIdx1.getIfAlreadyLoaded(),
|
|
9724
9724
|
samplesPerSecond,
|
|
9725
|
-
moviOffset:
|
|
9725
|
+
moviOffset: mediaSectionState.getMediaSections()[0]?.start ?? null,
|
|
9726
9726
|
observedKeyframes: riffState.sampleCounter.riffKeys.getKeyframes()
|
|
9727
9727
|
};
|
|
9728
9728
|
};
|
|
@@ -9761,13 +9761,13 @@ var setSeekingHintsForTransportStream = ({
|
|
|
9761
9761
|
// src/containers/wav/seeking-hints.ts
|
|
9762
9762
|
var getSeekingHintsFromWav = ({
|
|
9763
9763
|
structure,
|
|
9764
|
-
mediaSectionState
|
|
9764
|
+
mediaSectionState
|
|
9765
9765
|
}) => {
|
|
9766
9766
|
const fmtBox = structure.boxes.find((box) => box.type === "wav-fmt");
|
|
9767
9767
|
if (!fmtBox) {
|
|
9768
9768
|
return null;
|
|
9769
9769
|
}
|
|
9770
|
-
const mediaSection =
|
|
9770
|
+
const mediaSection = mediaSectionState.getMediaSections();
|
|
9771
9771
|
if (mediaSection.length !== 1) {
|
|
9772
9772
|
return null;
|
|
9773
9773
|
}
|
|
@@ -9787,8 +9787,8 @@ var setSeekingHintsForWav = ({
|
|
|
9787
9787
|
|
|
9788
9788
|
// src/containers/webm/seek/seeking-hints.ts
|
|
9789
9789
|
var getSeekingHintsFromMatroska = (tracksState, keyframesState, webmState) => {
|
|
9790
|
-
const
|
|
9791
|
-
const firstVideoTrack =
|
|
9790
|
+
const tracks = tracksState.getTracks();
|
|
9791
|
+
const firstVideoTrack = tracks.find((track) => track.type === "video");
|
|
9792
9792
|
const keyframes = keyframesState.getKeyframes();
|
|
9793
9793
|
const loadedCues = webmState.cues.getIfAlreadyLoaded();
|
|
9794
9794
|
return {
|
|
@@ -9815,7 +9815,7 @@ var setSeekingHintsForWebm = ({
|
|
|
9815
9815
|
var getSeekingHints = ({
|
|
9816
9816
|
structureState,
|
|
9817
9817
|
m3uPlaylistContext,
|
|
9818
|
-
mediaSectionState
|
|
9818
|
+
mediaSectionState,
|
|
9819
9819
|
isoState,
|
|
9820
9820
|
transportStream,
|
|
9821
9821
|
tracksState,
|
|
@@ -9837,13 +9837,13 @@ var getSeekingHints = ({
|
|
|
9837
9837
|
structureState,
|
|
9838
9838
|
isoState,
|
|
9839
9839
|
mp4HeaderSegment: m3uPlaylistContext?.mp4HeaderSegment ?? null,
|
|
9840
|
-
mediaSectionState
|
|
9840
|
+
mediaSectionState
|
|
9841
9841
|
});
|
|
9842
9842
|
}
|
|
9843
9843
|
if (structure.type === "wav") {
|
|
9844
9844
|
return getSeekingHintsFromWav({
|
|
9845
9845
|
structure,
|
|
9846
|
-
mediaSectionState
|
|
9846
|
+
mediaSectionState
|
|
9847
9847
|
});
|
|
9848
9848
|
}
|
|
9849
9849
|
if (structure.type === "matroska") {
|
|
@@ -9862,14 +9862,14 @@ var getSeekingHints = ({
|
|
|
9862
9862
|
return getSeekingHintsForRiff({
|
|
9863
9863
|
structureState,
|
|
9864
9864
|
riffState,
|
|
9865
|
-
mediaSectionState
|
|
9865
|
+
mediaSectionState
|
|
9866
9866
|
});
|
|
9867
9867
|
}
|
|
9868
9868
|
if (structure.type === "mp3") {
|
|
9869
9869
|
return getSeekingHintsForMp3({
|
|
9870
9870
|
mp3State,
|
|
9871
9871
|
samplesObserved,
|
|
9872
|
-
mediaSectionState
|
|
9872
|
+
mediaSectionState,
|
|
9873
9873
|
contentLength
|
|
9874
9874
|
});
|
|
9875
9875
|
}
|
|
@@ -10114,8 +10114,8 @@ var performSeek = async ({
|
|
|
10114
10114
|
|
|
10115
10115
|
// src/work-on-seek-request.ts
|
|
10116
10116
|
var turnSeekIntoByte = async ({
|
|
10117
|
-
seek
|
|
10118
|
-
mediaSectionState
|
|
10117
|
+
seek,
|
|
10118
|
+
mediaSectionState,
|
|
10119
10119
|
logLevel,
|
|
10120
10120
|
iterator,
|
|
10121
10121
|
structureState,
|
|
@@ -10134,21 +10134,21 @@ var turnSeekIntoByte = async ({
|
|
|
10134
10134
|
m3uState,
|
|
10135
10135
|
avcState
|
|
10136
10136
|
}) => {
|
|
10137
|
-
const mediaSections =
|
|
10137
|
+
const mediaSections = mediaSectionState.getMediaSections();
|
|
10138
10138
|
if (mediaSections.length === 0) {
|
|
10139
10139
|
Log.trace(logLevel, "No media sections defined, cannot seek yet");
|
|
10140
10140
|
return {
|
|
10141
10141
|
type: "valid-but-must-wait"
|
|
10142
10142
|
};
|
|
10143
10143
|
}
|
|
10144
|
-
if (
|
|
10145
|
-
throw new Error(`Cannot seek to a negative time: ${JSON.stringify(
|
|
10144
|
+
if (seek < 0) {
|
|
10145
|
+
throw new Error(`Cannot seek to a negative time: ${JSON.stringify(seek)}`);
|
|
10146
10146
|
}
|
|
10147
10147
|
const seekingHints = getSeekingHints({
|
|
10148
10148
|
riffState,
|
|
10149
10149
|
samplesObserved,
|
|
10150
10150
|
structureState,
|
|
10151
|
-
mediaSectionState
|
|
10151
|
+
mediaSectionState,
|
|
10152
10152
|
isoState,
|
|
10153
10153
|
transportStream,
|
|
10154
10154
|
tracksState,
|
|
@@ -10168,13 +10168,13 @@ var turnSeekIntoByte = async ({
|
|
|
10168
10168
|
}
|
|
10169
10169
|
const seekingByte = await getSeekingByte({
|
|
10170
10170
|
info: seekingHints,
|
|
10171
|
-
time:
|
|
10171
|
+
time: seek,
|
|
10172
10172
|
logLevel,
|
|
10173
10173
|
currentPosition: iterator.counter.getOffset(),
|
|
10174
10174
|
isoState,
|
|
10175
10175
|
transportStream,
|
|
10176
10176
|
webmState,
|
|
10177
|
-
mediaSection:
|
|
10177
|
+
mediaSection: mediaSectionState,
|
|
10178
10178
|
m3uPlaylistContext,
|
|
10179
10179
|
structure: structureState,
|
|
10180
10180
|
riffState,
|
|
@@ -10244,13 +10244,13 @@ var workOnSeekRequest = async (options) => {
|
|
|
10244
10244
|
m3uState,
|
|
10245
10245
|
avcState
|
|
10246
10246
|
} = options;
|
|
10247
|
-
const
|
|
10248
|
-
if (
|
|
10247
|
+
const seek = controller._internals.seekSignal.getSeek();
|
|
10248
|
+
if (seek === null) {
|
|
10249
10249
|
return;
|
|
10250
10250
|
}
|
|
10251
|
-
Log.trace(logLevel, `Has seek request for ${src}: ${JSON.stringify(
|
|
10251
|
+
Log.trace(logLevel, `Has seek request for ${src}: ${JSON.stringify(seek)}`);
|
|
10252
10252
|
const resolution = await turnSeekIntoByte({
|
|
10253
|
-
seek
|
|
10253
|
+
seek,
|
|
10254
10254
|
mediaSectionState: mediaSection,
|
|
10255
10255
|
logLevel,
|
|
10256
10256
|
iterator,
|
|
@@ -10311,7 +10311,7 @@ var workOnSeekRequest = async (options) => {
|
|
|
10311
10311
|
prefetchCache,
|
|
10312
10312
|
isoState
|
|
10313
10313
|
});
|
|
10314
|
-
const { hasChanged } = controller._internals.seekSignal.clearSeekIfStillSame(
|
|
10314
|
+
const { hasChanged } = controller._internals.seekSignal.clearSeekIfStillSame(seek);
|
|
10315
10315
|
if (hasChanged) {
|
|
10316
10316
|
Log.trace(logLevel, `Seek request has changed while seeking, seeking again`);
|
|
10317
10317
|
await workOnSeekRequest(options);
|
|
@@ -10319,7 +10319,7 @@ var workOnSeekRequest = async (options) => {
|
|
|
10319
10319
|
return;
|
|
10320
10320
|
}
|
|
10321
10321
|
if (resolution.type === "invalid") {
|
|
10322
|
-
throw new Error(`The seek request ${JSON.stringify(
|
|
10322
|
+
throw new Error(`The seek request ${JSON.stringify(seek)} cannot be processed`);
|
|
10323
10323
|
}
|
|
10324
10324
|
if (resolution.type === "valid-but-must-wait") {
|
|
10325
10325
|
Log.trace(logLevel, "Seek request is valid but cannot be processed yet");
|
|
@@ -10475,10 +10475,10 @@ var emitAvailableInfo = async ({
|
|
|
10475
10475
|
}
|
|
10476
10476
|
if (key === "tracks") {
|
|
10477
10477
|
if (!emittedFields.tracks && hasInfo.tracks) {
|
|
10478
|
-
const
|
|
10479
|
-
await callbackFunctions.onTracks?.(
|
|
10478
|
+
const tracks = getTracks(state, true);
|
|
10479
|
+
await callbackFunctions.onTracks?.(tracks);
|
|
10480
10480
|
if (fieldsInReturnValue.tracks) {
|
|
10481
|
-
returnValue.tracks =
|
|
10481
|
+
returnValue.tracks = tracks;
|
|
10482
10482
|
}
|
|
10483
10483
|
emittedFields.tracks = true;
|
|
10484
10484
|
}
|
|
@@ -10896,7 +10896,7 @@ var parseAac = async (state) => {
|
|
|
10896
10896
|
const sampleRate = getSampleRateFromSampleFrequencyIndex(samplingFrequencyIndex);
|
|
10897
10897
|
iterator.getBits(1);
|
|
10898
10898
|
const channelConfiguration = iterator.getBits(3);
|
|
10899
|
-
const
|
|
10899
|
+
const codecPrivate = createAacCodecPrivate({
|
|
10900
10900
|
audioObjectType,
|
|
10901
10901
|
sampleRate,
|
|
10902
10902
|
channelConfiguration,
|
|
@@ -10925,8 +10925,8 @@ var parseAac = async (state) => {
|
|
|
10925
10925
|
track: {
|
|
10926
10926
|
codec: mapAudioObjectTypeToCodecString(audioObjectType),
|
|
10927
10927
|
codecEnum: "aac",
|
|
10928
|
-
codecData: { type: "aac-config", data:
|
|
10929
|
-
description:
|
|
10928
|
+
codecData: { type: "aac-config", data: codecPrivate },
|
|
10929
|
+
description: codecPrivate,
|
|
10930
10930
|
numberOfChannels: channelConfiguration,
|
|
10931
10931
|
sampleRate,
|
|
10932
10932
|
originalTimescale: WEBCODECS_TIMESCALE,
|
|
@@ -10943,17 +10943,17 @@ var parseAac = async (state) => {
|
|
|
10943
10943
|
});
|
|
10944
10944
|
state.callbacks.tracks.setIsDone(state.logLevel);
|
|
10945
10945
|
}
|
|
10946
|
-
const
|
|
10946
|
+
const duration = 1024 / sampleRate;
|
|
10947
10947
|
const { index } = state.aac.addSample({ offset: startOffset, size: frameLength });
|
|
10948
10948
|
const timestamp = 1024 / sampleRate * index;
|
|
10949
10949
|
state.aac.audioSamples.addSample({
|
|
10950
10950
|
timeInSeconds: timestamp,
|
|
10951
10951
|
offset: startOffset,
|
|
10952
|
-
durationInSeconds:
|
|
10952
|
+
durationInSeconds: duration
|
|
10953
10953
|
});
|
|
10954
10954
|
const audioSample = convertAudioOrVideoSampleToWebCodecsTimestamps({
|
|
10955
10955
|
sample: {
|
|
10956
|
-
duration
|
|
10956
|
+
duration,
|
|
10957
10957
|
type: "key",
|
|
10958
10958
|
data,
|
|
10959
10959
|
offset: startOffset,
|
|
@@ -11149,7 +11149,7 @@ var emitSample = async ({
|
|
|
11149
11149
|
throw new Error("Invalid CRC");
|
|
11150
11150
|
}
|
|
11151
11151
|
const { blockSize, num, sampleRate } = parsed;
|
|
11152
|
-
const
|
|
11152
|
+
const duration = blockSize / sampleRate;
|
|
11153
11153
|
const structure = state.structure.getFlacStructure();
|
|
11154
11154
|
const streamInfo = structure.boxes.find((box) => box.type === "flac-streaminfo");
|
|
11155
11155
|
if (!streamInfo) {
|
|
@@ -11162,12 +11162,12 @@ var emitSample = async ({
|
|
|
11162
11162
|
state.flac.audioSamples.addSample({
|
|
11163
11163
|
timeInSeconds: timestamp,
|
|
11164
11164
|
offset,
|
|
11165
|
-
durationInSeconds:
|
|
11165
|
+
durationInSeconds: duration
|
|
11166
11166
|
});
|
|
11167
11167
|
const audioSample = convertAudioOrVideoSampleToWebCodecsTimestamps({
|
|
11168
11168
|
sample: {
|
|
11169
11169
|
data,
|
|
11170
|
-
duration
|
|
11170
|
+
duration,
|
|
11171
11171
|
decodingTimestamp: timestamp,
|
|
11172
11172
|
timestamp,
|
|
11173
11173
|
type: "key",
|
|
@@ -11303,7 +11303,7 @@ var parseStreamInfo = async ({
|
|
|
11303
11303
|
const maximumFrameSize = iterator.getUint24();
|
|
11304
11304
|
iterator.startReadingBits();
|
|
11305
11305
|
const sampleRate = iterator.getBits(20);
|
|
11306
|
-
const
|
|
11306
|
+
const channels = iterator.getBits(3) + 1;
|
|
11307
11307
|
const bitsPerSample = iterator.getBits(5);
|
|
11308
11308
|
const totalSamples = iterator.getBits(36);
|
|
11309
11309
|
iterator.getBits(128);
|
|
@@ -11315,7 +11315,7 @@ var parseStreamInfo = async ({
|
|
|
11315
11315
|
const flacStreamInfo = {
|
|
11316
11316
|
type: "flac-streaminfo",
|
|
11317
11317
|
bitsPerSample,
|
|
11318
|
-
channels
|
|
11318
|
+
channels,
|
|
11319
11319
|
maximumBlockSize,
|
|
11320
11320
|
maximumFrameSize,
|
|
11321
11321
|
minimumBlockSize,
|
|
@@ -11332,7 +11332,7 @@ var parseStreamInfo = async ({
|
|
|
11332
11332
|
description: asUint8Array,
|
|
11333
11333
|
codecData: { type: "flac-description", data: asUint8Array },
|
|
11334
11334
|
codecEnum: "flac",
|
|
11335
|
-
numberOfChannels:
|
|
11335
|
+
numberOfChannels: channels,
|
|
11336
11336
|
sampleRate,
|
|
11337
11337
|
originalTimescale: WEBCODECS_TIMESCALE,
|
|
11338
11338
|
trackId: 0,
|
|
@@ -11396,8 +11396,8 @@ var parseFlac = ({
|
|
|
11396
11396
|
iterator,
|
|
11397
11397
|
state
|
|
11398
11398
|
}) => {
|
|
11399
|
-
const
|
|
11400
|
-
if (
|
|
11399
|
+
const mediaSectionState = state.mediaSection.isCurrentByteInMediaSection(iterator);
|
|
11400
|
+
if (mediaSectionState === "in-section") {
|
|
11401
11401
|
if (maySkipVideoData({ state })) {
|
|
11402
11402
|
return Promise.resolve(makeSkip(state.contentLength));
|
|
11403
11403
|
}
|
|
@@ -11420,7 +11420,7 @@ var calculateSamplePositions = ({
|
|
|
11420
11420
|
mediaSectionStart,
|
|
11421
11421
|
trackIds
|
|
11422
11422
|
}) => {
|
|
11423
|
-
const
|
|
11423
|
+
const tracks = getTracks(state, true);
|
|
11424
11424
|
const moofBoxes = getMoofBoxes(state.structure.getIsoStructure().boxes);
|
|
11425
11425
|
const tfraBoxes = deduplicateTfraBoxesByOffset([
|
|
11426
11426
|
...state.iso.tfra.getTfraBoxes(),
|
|
@@ -11441,7 +11441,7 @@ var calculateSamplePositions = ({
|
|
|
11441
11441
|
throw new Error("No moov box found");
|
|
11442
11442
|
}
|
|
11443
11443
|
const trackIdAndSamplePositions = [];
|
|
11444
|
-
for (const track of
|
|
11444
|
+
for (const track of tracks) {
|
|
11445
11445
|
const trakBox = getTrakBoxByTrackId(moov, track.trackId);
|
|
11446
11446
|
if (!trackIds.includes(track.trackId)) {
|
|
11447
11447
|
Log.verbose(state.logLevel, "Skipping calculating sample positions for track", track.trackId);
|
|
@@ -11610,7 +11610,7 @@ var makeCanSkipTracksState = ({
|
|
|
11610
11610
|
|
|
11611
11611
|
// src/state/has-tracks-section.ts
|
|
11612
11612
|
var makeTracksSectionState = (canSkipTracksState, src) => {
|
|
11613
|
-
const
|
|
11613
|
+
const tracks = [];
|
|
11614
11614
|
let doneWithTracks = false;
|
|
11615
11615
|
return {
|
|
11616
11616
|
hasAllTracks: () => doneWithTracks,
|
|
@@ -11623,10 +11623,10 @@ var makeTracksSectionState = (canSkipTracksState, src) => {
|
|
|
11623
11623
|
doneWithTracks = true;
|
|
11624
11624
|
},
|
|
11625
11625
|
addTrack: (track) => {
|
|
11626
|
-
|
|
11626
|
+
tracks.push(track);
|
|
11627
11627
|
},
|
|
11628
11628
|
getTracks: () => {
|
|
11629
|
-
return
|
|
11629
|
+
return tracks;
|
|
11630
11630
|
},
|
|
11631
11631
|
ensureHasTracksAtEnd: (fields) => {
|
|
11632
11632
|
if (canSkipTracksState.canSkipTracks()) {
|
|
@@ -11897,12 +11897,12 @@ var parseMdatSection = async (state) => {
|
|
|
11897
11897
|
state.structure.getIsoStructure().boxes.push(moov);
|
|
11898
11898
|
return parseMdatSection(state);
|
|
11899
11899
|
}
|
|
11900
|
-
const
|
|
11900
|
+
const tracks = state.callbacks.tracks.getTracks();
|
|
11901
11901
|
if (!state.iso.flatSamples.getSamples(mediaSection.start)) {
|
|
11902
11902
|
const samplePosition = calculateSamplePositions({
|
|
11903
11903
|
state,
|
|
11904
11904
|
mediaSectionStart: mediaSection.start,
|
|
11905
|
-
trackIds:
|
|
11905
|
+
trackIds: tracks.map((t) => t.trackId)
|
|
11906
11906
|
});
|
|
11907
11907
|
state.iso.flatSamples.setSamples(mediaSection.start, samplePosition);
|
|
11908
11908
|
}
|
|
@@ -11929,13 +11929,13 @@ var parseMdatSection = async (state) => {
|
|
|
11929
11929
|
const {
|
|
11930
11930
|
timestamp: rawCts,
|
|
11931
11931
|
decodingTimestamp: rawDts,
|
|
11932
|
-
duration
|
|
11932
|
+
duration,
|
|
11933
11933
|
isKeyframe,
|
|
11934
11934
|
offset,
|
|
11935
11935
|
bigEndian,
|
|
11936
11936
|
chunkSize
|
|
11937
11937
|
} = nextSample.samplePosition;
|
|
11938
|
-
const track =
|
|
11938
|
+
const track = tracks.find((t) => t.trackId === nextSample.trackId);
|
|
11939
11939
|
const {
|
|
11940
11940
|
originalTimescale,
|
|
11941
11941
|
startInSeconds,
|
|
@@ -11954,7 +11954,7 @@ var parseMdatSection = async (state) => {
|
|
|
11954
11954
|
sample: {
|
|
11955
11955
|
data: bytes,
|
|
11956
11956
|
timestamp: cts,
|
|
11957
|
-
duration
|
|
11957
|
+
duration,
|
|
11958
11958
|
decodingTimestamp: dts,
|
|
11959
11959
|
type: isKeyframe ? "key" : "delta",
|
|
11960
11960
|
offset
|
|
@@ -11977,7 +11977,7 @@ var parseMdatSection = async (state) => {
|
|
|
11977
11977
|
sample: {
|
|
11978
11978
|
data: bytes,
|
|
11979
11979
|
timestamp: cts,
|
|
11980
|
-
duration
|
|
11980
|
+
duration,
|
|
11981
11981
|
decodingTimestamp: dts,
|
|
11982
11982
|
type: isKeyframe && !isRecoveryPoint ? "key" : "delta",
|
|
11983
11983
|
offset
|
|
@@ -11995,8 +11995,8 @@ var parseMdatSection = async (state) => {
|
|
|
11995
11995
|
|
|
11996
11996
|
// src/containers/iso-base-media/parse-boxes.ts
|
|
11997
11997
|
var parseIsoBaseMedia = async (state) => {
|
|
11998
|
-
const
|
|
11999
|
-
if (
|
|
11998
|
+
const mediaSectionState = state.mediaSection.isCurrentByteInMediaSection(state.iterator);
|
|
11999
|
+
if (mediaSectionState === "in-section") {
|
|
12000
12000
|
const skipTo = await parseMdatSection(state);
|
|
12001
12001
|
return skipTo;
|
|
12002
12002
|
}
|
|
@@ -12487,16 +12487,16 @@ function parseContentRange(input) {
|
|
|
12487
12487
|
if (!matches)
|
|
12488
12488
|
return null;
|
|
12489
12489
|
const [, unit, , start, end, size] = matches;
|
|
12490
|
-
const
|
|
12490
|
+
const range = {
|
|
12491
12491
|
unit,
|
|
12492
12492
|
start: start != null ? Number(start) : null,
|
|
12493
12493
|
end: end != null ? Number(end) : null,
|
|
12494
12494
|
size: size === "*" ? null : Number(size)
|
|
12495
12495
|
};
|
|
12496
|
-
if (
|
|
12496
|
+
if (range.start === null && range.end === null && range.size === null) {
|
|
12497
12497
|
return null;
|
|
12498
12498
|
}
|
|
12499
|
-
return
|
|
12499
|
+
return range;
|
|
12500
12500
|
}
|
|
12501
12501
|
var validateContentRangeAndDetectIfSupported = ({
|
|
12502
12502
|
requestedRange,
|
|
@@ -12518,7 +12518,7 @@ var validateContentRangeAndDetectIfSupported = ({
|
|
|
12518
12518
|
return { supportsContentRange: true };
|
|
12519
12519
|
};
|
|
12520
12520
|
var makeFetchRequest = async ({
|
|
12521
|
-
range
|
|
12521
|
+
range,
|
|
12522
12522
|
src,
|
|
12523
12523
|
controller
|
|
12524
12524
|
}) => {
|
|
@@ -12529,7 +12529,7 @@ var makeFetchRequest = async ({
|
|
|
12529
12529
|
}
|
|
12530
12530
|
const ownController = new AbortController;
|
|
12531
12531
|
const cache = typeof navigator !== "undefined" && navigator.userAgent.includes("Cloudflare-Workers") ? undefined : "no-store";
|
|
12532
|
-
const requestedRange =
|
|
12532
|
+
const requestedRange = range === null ? 0 : range;
|
|
12533
12533
|
const asString = typeof resolvedUrl === "string" ? resolvedUrl : resolvedUrl.pathname;
|
|
12534
12534
|
const requestWithoutRange = asString.endsWith(".m3u8");
|
|
12535
12535
|
const canLiveWithoutContentLength = asString.endsWith(".m3u8") || asString.endsWith(".ts");
|
|
@@ -12578,31 +12578,31 @@ var makeFetchRequest = async ({
|
|
|
12578
12578
|
};
|
|
12579
12579
|
var cacheKey = ({
|
|
12580
12580
|
src,
|
|
12581
|
-
range
|
|
12581
|
+
range
|
|
12582
12582
|
}) => {
|
|
12583
|
-
return `${src}-${JSON.stringify(
|
|
12583
|
+
return `${src}-${JSON.stringify(range)}`;
|
|
12584
12584
|
};
|
|
12585
12585
|
var makeFetchRequestOrGetCached = ({
|
|
12586
|
-
range
|
|
12586
|
+
range,
|
|
12587
12587
|
src,
|
|
12588
12588
|
controller,
|
|
12589
12589
|
logLevel,
|
|
12590
12590
|
prefetchCache
|
|
12591
12591
|
}) => {
|
|
12592
|
-
const key = cacheKey({ src, range
|
|
12592
|
+
const key = cacheKey({ src, range });
|
|
12593
12593
|
const cached = prefetchCache.get(key);
|
|
12594
12594
|
if (cached) {
|
|
12595
12595
|
Log.verbose(logLevel, `Reading from preload cache for ${key}`);
|
|
12596
12596
|
return cached;
|
|
12597
12597
|
}
|
|
12598
12598
|
Log.verbose(logLevel, `Fetching ${key}`);
|
|
12599
|
-
const result = makeFetchRequest({ range
|
|
12599
|
+
const result = makeFetchRequest({ range, src, controller });
|
|
12600
12600
|
prefetchCache.set(key, result);
|
|
12601
12601
|
return result;
|
|
12602
12602
|
};
|
|
12603
12603
|
var fetchReadContent = async ({
|
|
12604
12604
|
src,
|
|
12605
|
-
range
|
|
12605
|
+
range,
|
|
12606
12606
|
controller,
|
|
12607
12607
|
logLevel,
|
|
12608
12608
|
prefetchCache
|
|
@@ -12612,13 +12612,13 @@ var fetchReadContent = async ({
|
|
|
12612
12612
|
}
|
|
12613
12613
|
const fallbackName = src.toString().split("/").pop();
|
|
12614
12614
|
const res = makeFetchRequestOrGetCached({
|
|
12615
|
-
range
|
|
12615
|
+
range,
|
|
12616
12616
|
src,
|
|
12617
12617
|
controller,
|
|
12618
12618
|
logLevel,
|
|
12619
12619
|
prefetchCache
|
|
12620
12620
|
});
|
|
12621
|
-
const key = cacheKey({ src, range
|
|
12621
|
+
const key = cacheKey({ src, range });
|
|
12622
12622
|
prefetchCache.delete(key);
|
|
12623
12623
|
const {
|
|
12624
12624
|
reader,
|
|
@@ -12644,19 +12644,19 @@ var fetchReadContent = async ({
|
|
|
12644
12644
|
};
|
|
12645
12645
|
var fetchPreload = ({
|
|
12646
12646
|
src,
|
|
12647
|
-
range
|
|
12647
|
+
range,
|
|
12648
12648
|
logLevel,
|
|
12649
12649
|
prefetchCache
|
|
12650
12650
|
}) => {
|
|
12651
12651
|
if (typeof src !== "string" && src instanceof URL === false) {
|
|
12652
12652
|
throw new Error("src must be a string when using `fetchReader`");
|
|
12653
12653
|
}
|
|
12654
|
-
const key = cacheKey({ src, range
|
|
12654
|
+
const key = cacheKey({ src, range });
|
|
12655
12655
|
if (prefetchCache.has(key)) {
|
|
12656
12656
|
return prefetchCache.get(key);
|
|
12657
12657
|
}
|
|
12658
12658
|
makeFetchRequestOrGetCached({
|
|
12659
|
-
range
|
|
12659
|
+
range,
|
|
12660
12660
|
src,
|
|
12661
12661
|
controller: null,
|
|
12662
12662
|
logLevel,
|
|
@@ -12681,11 +12681,11 @@ var fetchCreateAdjacentFileSource = (relativePath, src) => {
|
|
|
12681
12681
|
};
|
|
12682
12682
|
|
|
12683
12683
|
// src/readers/from-web-file.ts
|
|
12684
|
-
var webFileReadContent = ({ src, range
|
|
12684
|
+
var webFileReadContent = ({ src, range, controller }) => {
|
|
12685
12685
|
if (typeof src === "string" || src instanceof URL) {
|
|
12686
12686
|
throw new Error("`inputTypeFileReader` only supports `File` objects");
|
|
12687
12687
|
}
|
|
12688
|
-
const part =
|
|
12688
|
+
const part = range === null ? src : typeof range === "number" ? src.slice(range) : src.slice(range[0], range[1] + 1);
|
|
12689
12689
|
const stream = part.stream();
|
|
12690
12690
|
const streamReader = stream.getReader();
|
|
12691
12691
|
if (controller) {
|
|
@@ -12737,11 +12737,11 @@ var webReader = {
|
|
|
12737
12737
|
}
|
|
12738
12738
|
return fetchReadWholeAsText(src);
|
|
12739
12739
|
},
|
|
12740
|
-
preload: ({ range
|
|
12740
|
+
preload: ({ range, src, logLevel, prefetchCache }) => {
|
|
12741
12741
|
if (src instanceof Blob) {
|
|
12742
12742
|
return;
|
|
12743
12743
|
}
|
|
12744
|
-
return fetchPreload({ range
|
|
12744
|
+
return fetchPreload({ range, src, logLevel, prefetchCache });
|
|
12745
12745
|
}
|
|
12746
12746
|
};
|
|
12747
12747
|
// src/parse-media.ts
|
|
@@ -12854,12 +12854,12 @@ var getChunkToSeekTo = ({
|
|
|
12854
12854
|
chunks,
|
|
12855
12855
|
seekToSecondsToProcess
|
|
12856
12856
|
}) => {
|
|
12857
|
-
let
|
|
12857
|
+
let duration = 0;
|
|
12858
12858
|
for (let i = 0;i < chunks.length; i++) {
|
|
12859
|
-
if (
|
|
12859
|
+
if (duration >= seekToSecondsToProcess) {
|
|
12860
12860
|
return Math.max(0, i - 1);
|
|
12861
12861
|
}
|
|
12862
|
-
|
|
12862
|
+
duration += chunks[i].duration;
|
|
12863
12863
|
}
|
|
12864
12864
|
return Math.max(0, chunks.length - 1);
|
|
12865
12865
|
};
|
|
@@ -13549,11 +13549,11 @@ var getAudioSampleFromCbr = ({
|
|
|
13549
13549
|
const durationInSeconds = samplesPerFrame / sampleRate;
|
|
13550
13550
|
const timeInSeconds = nthFrame * samplesPerFrame / sampleRate;
|
|
13551
13551
|
const timestamp = Math.floor(timeInSeconds * WEBCODECS_TIMESCALE);
|
|
13552
|
-
const
|
|
13552
|
+
const duration = Math.floor(durationInSeconds * WEBCODECS_TIMESCALE);
|
|
13553
13553
|
const audioSample = {
|
|
13554
13554
|
data,
|
|
13555
13555
|
decodingTimestamp: timestamp,
|
|
13556
|
-
duration
|
|
13556
|
+
duration,
|
|
13557
13557
|
offset: initialOffset,
|
|
13558
13558
|
timestamp,
|
|
13559
13559
|
type: "key"
|
|
@@ -13593,11 +13593,11 @@ var getAudioSampleFromVbr = ({
|
|
|
13593
13593
|
});
|
|
13594
13594
|
const durationInSeconds = samplesPerFrame / info.xingData.sampleRate;
|
|
13595
13595
|
const timestamp = Math.floor(timeInSeconds * WEBCODECS_TIMESCALE);
|
|
13596
|
-
const
|
|
13596
|
+
const duration = Math.floor(durationInSeconds * WEBCODECS_TIMESCALE);
|
|
13597
13597
|
const audioSample = {
|
|
13598
13598
|
data,
|
|
13599
13599
|
decodingTimestamp: timestamp,
|
|
13600
|
-
duration
|
|
13600
|
+
duration,
|
|
13601
13601
|
offset: position,
|
|
13602
13602
|
timestamp,
|
|
13603
13603
|
type: "key"
|
|
@@ -14085,7 +14085,7 @@ var parseStrh = ({
|
|
|
14085
14085
|
}
|
|
14086
14086
|
const flags = iterator.getUint32Le();
|
|
14087
14087
|
const priority = iterator.getUint16Le();
|
|
14088
|
-
const
|
|
14088
|
+
const language = iterator.getUint16Le();
|
|
14089
14089
|
const initialFrames = iterator.getUint32Le();
|
|
14090
14090
|
const scale = iterator.getUint32Le();
|
|
14091
14091
|
const rate = iterator.getUint32Le();
|
|
@@ -14118,7 +14118,7 @@ var parseStrh = ({
|
|
|
14118
14118
|
scale,
|
|
14119
14119
|
start,
|
|
14120
14120
|
suggestedBufferSize,
|
|
14121
|
-
language
|
|
14121
|
+
language,
|
|
14122
14122
|
strf
|
|
14123
14123
|
};
|
|
14124
14124
|
};
|
|
@@ -14355,8 +14355,8 @@ var parseMediaSection = async (state) => {
|
|
|
14355
14355
|
await parseMovi({
|
|
14356
14356
|
state
|
|
14357
14357
|
});
|
|
14358
|
-
const
|
|
14359
|
-
if (!
|
|
14358
|
+
const tracks = getTracks(state, false);
|
|
14359
|
+
if (!tracks.some((t) => t.type === "video" && t.codec === TO_BE_OVERRIDDEN_LATER) && !state.callbacks.tracks.getIsDone()) {
|
|
14360
14360
|
state.callbacks.tracks.setIsDone(state.logLevel);
|
|
14361
14361
|
}
|
|
14362
14362
|
};
|
|
@@ -14703,7 +14703,7 @@ var readAdtsHeader = (buffer) => {
|
|
|
14703
14703
|
const sampleRate = getSampleRateFromSampleFrequencyIndex(samplingFrequencyIndex);
|
|
14704
14704
|
iterator.getBits(1);
|
|
14705
14705
|
const channelConfiguration = iterator.getBits(3);
|
|
14706
|
-
const
|
|
14706
|
+
const codecPrivate = createAacCodecPrivate({
|
|
14707
14707
|
audioObjectType,
|
|
14708
14708
|
sampleRate,
|
|
14709
14709
|
channelConfiguration,
|
|
@@ -14723,7 +14723,7 @@ var readAdtsHeader = (buffer) => {
|
|
|
14723
14723
|
iterator.destroy();
|
|
14724
14724
|
return {
|
|
14725
14725
|
frameLength,
|
|
14726
|
-
codecPrivate
|
|
14726
|
+
codecPrivate,
|
|
14727
14727
|
channelConfiguration,
|
|
14728
14728
|
sampleRate,
|
|
14729
14729
|
audioObjectType
|
|
@@ -14745,7 +14745,7 @@ var handleAacPacket = async ({
|
|
|
14745
14745
|
if (!adtsHeader) {
|
|
14746
14746
|
throw new Error("Invalid ADTS header - too short");
|
|
14747
14747
|
}
|
|
14748
|
-
const { channelConfiguration, codecPrivate
|
|
14748
|
+
const { channelConfiguration, codecPrivate, sampleRate, audioObjectType } = adtsHeader;
|
|
14749
14749
|
const isTrackRegistered = sampleCallbacks.tracks.getTracks().find((t) => {
|
|
14750
14750
|
return t.trackId === programId;
|
|
14751
14751
|
});
|
|
@@ -14757,12 +14757,12 @@ var handleAacPacket = async ({
|
|
|
14757
14757
|
});
|
|
14758
14758
|
const track = {
|
|
14759
14759
|
type: "audio",
|
|
14760
|
-
codecData: { type: "aac-config", data:
|
|
14760
|
+
codecData: { type: "aac-config", data: codecPrivate },
|
|
14761
14761
|
trackId: programId,
|
|
14762
14762
|
originalTimescale: MPEG_TIMESCALE,
|
|
14763
14763
|
codecEnum: "aac",
|
|
14764
14764
|
codec: mapAudioObjectTypeToCodecString(audioObjectType),
|
|
14765
|
-
description:
|
|
14765
|
+
description: codecPrivate,
|
|
14766
14766
|
numberOfChannels: channelConfiguration,
|
|
14767
14767
|
sampleRate,
|
|
14768
14768
|
startInSeconds: 0,
|
|
@@ -15330,18 +15330,18 @@ var CHANNELS = {
|
|
|
15330
15330
|
17: "Top Back Right"
|
|
15331
15331
|
};
|
|
15332
15332
|
function getChannelsFromMask(channelMask) {
|
|
15333
|
-
const
|
|
15333
|
+
const channels = [];
|
|
15334
15334
|
for (let bit = 0;bit < 18; bit++) {
|
|
15335
15335
|
if ((channelMask & 1 << bit) !== 0) {
|
|
15336
15336
|
const channelName = CHANNELS[bit];
|
|
15337
15337
|
if (channelName) {
|
|
15338
|
-
|
|
15338
|
+
channels.push(channelName);
|
|
15339
15339
|
} else {
|
|
15340
|
-
|
|
15340
|
+
channels.push(`Unknown Channel (bit ${bit})`);
|
|
15341
15341
|
}
|
|
15342
15342
|
}
|
|
15343
15343
|
}
|
|
15344
|
-
return
|
|
15344
|
+
return channels;
|
|
15345
15345
|
}
|
|
15346
15346
|
var parseFmt = async ({
|
|
15347
15347
|
state
|
|
@@ -15385,8 +15385,8 @@ var parseFmt = async ({
|
|
|
15385
15385
|
if (subformatIsPcm(subFormat)) {} else if (subformatIsIeeeFloat(subFormat)) {} else {
|
|
15386
15386
|
throw new Error(`Unsupported subformat: ${subFormat}`);
|
|
15387
15387
|
}
|
|
15388
|
-
const
|
|
15389
|
-
wavHeader.numberOfChannels =
|
|
15388
|
+
const channels = getChannelsFromMask(channelMask);
|
|
15389
|
+
wavHeader.numberOfChannels = channels.length;
|
|
15390
15390
|
}
|
|
15391
15391
|
await registerAudioTrack({
|
|
15392
15392
|
track: {
|
|
@@ -15509,14 +15509,14 @@ var parseMediaSection2 = async ({
|
|
|
15509
15509
|
throw new Error("Expected fmt box");
|
|
15510
15510
|
}
|
|
15511
15511
|
const toRead = Math.min(maxRead, fmtBox.sampleRate * fmtBox.blockAlign / WAVE_SAMPLES_PER_SECOND);
|
|
15512
|
-
const
|
|
15512
|
+
const duration = toRead / (fmtBox.sampleRate * fmtBox.blockAlign);
|
|
15513
15513
|
const timestamp = (offset - videoSection.start) / (fmtBox.sampleRate * fmtBox.blockAlign);
|
|
15514
15514
|
const data = iterator.getSlice(toRead);
|
|
15515
15515
|
const audioSample = convertAudioOrVideoSampleToWebCodecsTimestamps({
|
|
15516
15516
|
sample: {
|
|
15517
15517
|
decodingTimestamp: timestamp,
|
|
15518
15518
|
data,
|
|
15519
|
-
duration
|
|
15519
|
+
duration,
|
|
15520
15520
|
timestamp,
|
|
15521
15521
|
type: "key",
|
|
15522
15522
|
offset
|
|
@@ -15575,19 +15575,19 @@ var getByteForSeek = ({
|
|
|
15575
15575
|
if (v.type !== "Seek") {
|
|
15576
15576
|
return null;
|
|
15577
15577
|
}
|
|
15578
|
-
const
|
|
15578
|
+
const seekId = v.value.find((_v) => {
|
|
15579
15579
|
return _v.type === "SeekID" && _v.value === matroskaElements.Cues;
|
|
15580
15580
|
});
|
|
15581
|
-
if (!
|
|
15581
|
+
if (!seekId) {
|
|
15582
15582
|
return null;
|
|
15583
15583
|
}
|
|
15584
|
-
const
|
|
15584
|
+
const seekPosition = v.value.find((_v) => {
|
|
15585
15585
|
return _v.type === "SeekPosition";
|
|
15586
15586
|
});
|
|
15587
|
-
if (!
|
|
15587
|
+
if (!seekPosition) {
|
|
15588
15588
|
return false;
|
|
15589
15589
|
}
|
|
15590
|
-
return
|
|
15590
|
+
return seekPosition.value;
|
|
15591
15591
|
}).filter(truthy);
|
|
15592
15592
|
if (value.length === 0) {
|
|
15593
15593
|
return null;
|
|
@@ -15601,7 +15601,7 @@ var expectSegment = async ({
|
|
|
15601
15601
|
isInsideSegment,
|
|
15602
15602
|
iterator,
|
|
15603
15603
|
logLevel,
|
|
15604
|
-
mediaSectionState
|
|
15604
|
+
mediaSectionState
|
|
15605
15605
|
}) => {
|
|
15606
15606
|
if (iterator.bytesRemaining() === 0) {
|
|
15607
15607
|
throw new Error("has no bytes");
|
|
@@ -15644,8 +15644,8 @@ var expectSegment = async ({
|
|
|
15644
15644
|
if (!statesForProcessing) {
|
|
15645
15645
|
throw new Error("States for processing are required");
|
|
15646
15646
|
}
|
|
15647
|
-
if (
|
|
15648
|
-
|
|
15647
|
+
if (mediaSectionState) {
|
|
15648
|
+
mediaSectionState.addMediaSection({
|
|
15649
15649
|
start: offset,
|
|
15650
15650
|
size
|
|
15651
15651
|
});
|
|
@@ -15795,8 +15795,8 @@ var initVideo = async ({ state }) => {
|
|
|
15795
15795
|
if (!moovAtom) {
|
|
15796
15796
|
throw new Error("No moov box found");
|
|
15797
15797
|
}
|
|
15798
|
-
const
|
|
15799
|
-
for (const track of
|
|
15798
|
+
const tracks = getTracksFromMoovBox(moovAtom);
|
|
15799
|
+
for (const track of tracks.filter((t) => t.type === "video")) {
|
|
15800
15800
|
await registerVideoTrack({
|
|
15801
15801
|
track,
|
|
15802
15802
|
container: "mp4",
|
|
@@ -15806,7 +15806,7 @@ var initVideo = async ({ state }) => {
|
|
|
15806
15806
|
tracks: state.callbacks.tracks
|
|
15807
15807
|
});
|
|
15808
15808
|
}
|
|
15809
|
-
for (const track of
|
|
15809
|
+
for (const track of tracks.filter((t) => t.type === "audio")) {
|
|
15810
15810
|
await registerAudioTrack({
|
|
15811
15811
|
track,
|
|
15812
15812
|
container: "mp4",
|
|
@@ -16606,7 +16606,7 @@ var keyframesState = () => {
|
|
|
16606
16606
|
}
|
|
16607
16607
|
keyframes.push(keyframe);
|
|
16608
16608
|
};
|
|
16609
|
-
const
|
|
16609
|
+
const getKeyframes = () => {
|
|
16610
16610
|
keyframes.sort((a, b) => a.positionInBytes - b.positionInBytes);
|
|
16611
16611
|
return keyframes;
|
|
16612
16612
|
};
|
|
@@ -16617,7 +16617,7 @@ var keyframesState = () => {
|
|
|
16617
16617
|
};
|
|
16618
16618
|
return {
|
|
16619
16619
|
addKeyframe,
|
|
16620
|
-
getKeyframes
|
|
16620
|
+
getKeyframes,
|
|
16621
16621
|
setFromSeekingHints
|
|
16622
16622
|
};
|
|
16623
16623
|
};
|
|
@@ -17011,19 +17011,19 @@ var webmState = ({
|
|
|
17011
17011
|
prefetchCache
|
|
17012
17012
|
}) => {
|
|
17013
17013
|
const trackEntries = {};
|
|
17014
|
-
const onTrackEntrySegment = (
|
|
17015
|
-
const trackId = getTrackId(
|
|
17014
|
+
const onTrackEntrySegment = (trackEntry) => {
|
|
17015
|
+
const trackId = getTrackId(trackEntry);
|
|
17016
17016
|
if (!trackId) {
|
|
17017
17017
|
throw new Error("Expected track id");
|
|
17018
17018
|
}
|
|
17019
17019
|
if (trackEntries[trackId]) {
|
|
17020
17020
|
return;
|
|
17021
17021
|
}
|
|
17022
|
-
const codec = getTrackCodec(
|
|
17022
|
+
const codec = getTrackCodec(trackEntry);
|
|
17023
17023
|
if (!codec) {
|
|
17024
17024
|
throw new Error("Expected codec");
|
|
17025
17025
|
}
|
|
17026
|
-
const trackTimescale = getTrackTimestampScale(
|
|
17026
|
+
const trackTimescale = getTrackTimestampScale(trackEntry);
|
|
17027
17027
|
trackEntries[trackId] = {
|
|
17028
17028
|
codec: codec.value,
|
|
17029
17029
|
trackTimescale: trackTimescale?.value ?? null
|
|
@@ -17059,11 +17059,11 @@ var webmState = ({
|
|
|
17059
17059
|
const segments = [];
|
|
17060
17060
|
const clusters = [];
|
|
17061
17061
|
const avcProfilesMap = {};
|
|
17062
|
-
const setAvcProfileForTrackNumber = (
|
|
17063
|
-
avcProfilesMap[
|
|
17062
|
+
const setAvcProfileForTrackNumber = (trackNumber, avcProfile) => {
|
|
17063
|
+
avcProfilesMap[trackNumber] = avcProfile;
|
|
17064
17064
|
};
|
|
17065
|
-
const getAvcProfileForTrackNumber = (
|
|
17066
|
-
return avcProfilesMap[
|
|
17065
|
+
const getAvcProfileForTrackNumber = (trackNumber) => {
|
|
17066
|
+
return avcProfilesMap[trackNumber] ?? null;
|
|
17067
17067
|
};
|
|
17068
17068
|
const cues = lazyCuesFetch({
|
|
17069
17069
|
controller,
|
|
@@ -17315,7 +17315,7 @@ var riffKeyframesState = () => {
|
|
|
17315
17315
|
keyframes.push(keyframe);
|
|
17316
17316
|
keyframes.sort((a, b) => a.positionInBytes - b.positionInBytes);
|
|
17317
17317
|
};
|
|
17318
|
-
const
|
|
17318
|
+
const getKeyframes = () => {
|
|
17319
17319
|
return keyframes;
|
|
17320
17320
|
};
|
|
17321
17321
|
const setFromSeekingHints = (keyframesFromHints) => {
|
|
@@ -17325,7 +17325,7 @@ var riffKeyframesState = () => {
|
|
|
17325
17325
|
};
|
|
17326
17326
|
return {
|
|
17327
17327
|
addKeyframe,
|
|
17328
|
-
getKeyframes
|
|
17328
|
+
getKeyframes,
|
|
17329
17329
|
setFromSeekingHints
|
|
17330
17330
|
};
|
|
17331
17331
|
};
|
|
@@ -17606,9 +17606,9 @@ var samplesObservedState = () => {
|
|
|
17606
17606
|
const addVideoSample = (videoSample) => {
|
|
17607
17607
|
videoSamples.set(videoSample.timestamp, videoSample.data.byteLength);
|
|
17608
17608
|
const presentationTimeInSeconds = videoSample.timestamp / WEBCODECS_TIMESCALE;
|
|
17609
|
-
const
|
|
17609
|
+
const duration = (videoSample.duration ?? 0) / WEBCODECS_TIMESCALE;
|
|
17610
17610
|
if (largestVideoSample === undefined || presentationTimeInSeconds > largestVideoSample) {
|
|
17611
|
-
largestVideoSample = presentationTimeInSeconds +
|
|
17611
|
+
largestVideoSample = presentationTimeInSeconds + duration;
|
|
17612
17612
|
}
|
|
17613
17613
|
if (smallestVideoSample === undefined || presentationTimeInSeconds < smallestVideoSample) {
|
|
17614
17614
|
smallestVideoSample = presentationTimeInSeconds;
|
|
@@ -17617,15 +17617,15 @@ var samplesObservedState = () => {
|
|
|
17617
17617
|
const addAudioSample = (audioSample) => {
|
|
17618
17618
|
audioSamples.set(audioSample.timestamp, audioSample.data.byteLength);
|
|
17619
17619
|
const presentationTimeInSeconds = audioSample.timestamp / WEBCODECS_TIMESCALE;
|
|
17620
|
-
const
|
|
17620
|
+
const duration = (audioSample.duration ?? 0) / WEBCODECS_TIMESCALE;
|
|
17621
17621
|
if (largestAudioSample === undefined || presentationTimeInSeconds > largestAudioSample) {
|
|
17622
|
-
largestAudioSample = presentationTimeInSeconds +
|
|
17622
|
+
largestAudioSample = presentationTimeInSeconds + duration;
|
|
17623
17623
|
}
|
|
17624
17624
|
if (smallestAudioSample === undefined || presentationTimeInSeconds < smallestAudioSample) {
|
|
17625
17625
|
smallestAudioSample = presentationTimeInSeconds;
|
|
17626
17626
|
}
|
|
17627
17627
|
};
|
|
17628
|
-
const
|
|
17628
|
+
const getFps = () => {
|
|
17629
17629
|
const videoDuration = (largestVideoSample ?? 0) - (smallestVideoSample ?? 0);
|
|
17630
17630
|
if (videoDuration === 0) {
|
|
17631
17631
|
return 0;
|
|
@@ -17657,7 +17657,7 @@ var samplesObservedState = () => {
|
|
|
17657
17657
|
addVideoSample,
|
|
17658
17658
|
addAudioSample,
|
|
17659
17659
|
getSlowDurationInSeconds,
|
|
17660
|
-
getFps
|
|
17660
|
+
getFps,
|
|
17661
17661
|
getSlowNumberOfFrames,
|
|
17662
17662
|
getAudioBitrate,
|
|
17663
17663
|
getVideoBitrate,
|
|
@@ -18067,44 +18067,44 @@ var internalParseMedia = async function({
|
|
|
18067
18067
|
contentLength: state.contentLength,
|
|
18068
18068
|
aacState: state.aac
|
|
18069
18069
|
})));
|
|
18070
|
-
controller._internals.attachSimulateSeekResolution((
|
|
18070
|
+
controller._internals.attachSimulateSeekResolution((seek) => {
|
|
18071
18071
|
const {
|
|
18072
|
-
aacState
|
|
18073
|
-
avcState
|
|
18074
|
-
flacState
|
|
18072
|
+
aacState,
|
|
18073
|
+
avcState,
|
|
18074
|
+
flacState,
|
|
18075
18075
|
isoState,
|
|
18076
18076
|
iterator,
|
|
18077
18077
|
keyframes,
|
|
18078
|
-
m3uState
|
|
18078
|
+
m3uState,
|
|
18079
18079
|
mediaSection,
|
|
18080
18080
|
mp3State,
|
|
18081
18081
|
riffState,
|
|
18082
18082
|
samplesObserved,
|
|
18083
|
-
structureState
|
|
18083
|
+
structureState,
|
|
18084
18084
|
tracksState,
|
|
18085
18085
|
transportStream,
|
|
18086
|
-
webmState
|
|
18086
|
+
webmState
|
|
18087
18087
|
} = getWorkOnSeekRequestOptions(state);
|
|
18088
18088
|
return turnSeekIntoByte({
|
|
18089
|
-
aacState
|
|
18090
|
-
seek
|
|
18091
|
-
avcState
|
|
18089
|
+
aacState,
|
|
18090
|
+
seek,
|
|
18091
|
+
avcState,
|
|
18092
18092
|
contentLength,
|
|
18093
|
-
flacState
|
|
18093
|
+
flacState,
|
|
18094
18094
|
isoState,
|
|
18095
18095
|
iterator,
|
|
18096
18096
|
keyframes,
|
|
18097
18097
|
logLevel,
|
|
18098
18098
|
m3uPlaylistContext,
|
|
18099
|
-
m3uState
|
|
18099
|
+
m3uState,
|
|
18100
18100
|
mediaSectionState: mediaSection,
|
|
18101
18101
|
mp3State,
|
|
18102
18102
|
riffState,
|
|
18103
18103
|
samplesObserved,
|
|
18104
|
-
structureState
|
|
18104
|
+
structureState,
|
|
18105
18105
|
tracksState,
|
|
18106
18106
|
transportStream,
|
|
18107
|
-
webmState
|
|
18107
|
+
webmState
|
|
18108
18108
|
});
|
|
18109
18109
|
});
|
|
18110
18110
|
if (!hasAudioTrackHandlers && !hasVideoTrackHandlers && Object.values(state.fields).every((v) => !v) && mode === "query") {
|
|
@@ -18208,7 +18208,7 @@ var downloadAndParseMedia = async (options) => {
|
|
|
18208
18208
|
return returnValue;
|
|
18209
18209
|
};
|
|
18210
18210
|
// src/version.ts
|
|
18211
|
-
var VERSION = "4.0.
|
|
18211
|
+
var VERSION = "4.0.535";
|
|
18212
18212
|
|
|
18213
18213
|
// src/index.ts
|
|
18214
18214
|
var MediaParserInternals = {
|
|
@@ -18228,17 +18228,17 @@ var MediaParserInternals = {
|
|
|
18228
18228
|
fieldsNeedSamplesMap
|
|
18229
18229
|
};
|
|
18230
18230
|
export {
|
|
18231
|
-
|
|
18232
|
-
mediaParserController,
|
|
18233
|
-
hasBeenAborted,
|
|
18234
|
-
downloadAndParseMedia,
|
|
18235
|
-
defaultSelectM3uStreamFn,
|
|
18236
|
-
defaultSelectM3uAssociatedPlaylists,
|
|
18237
|
-
WEBCODECS_TIMESCALE,
|
|
18238
|
-
VERSION,
|
|
18239
|
-
MediaParserInternals,
|
|
18240
|
-
MediaParserAbortError,
|
|
18241
|
-
IsAnUnsupportedFileTypeError,
|
|
18231
|
+
IsAPdfError,
|
|
18242
18232
|
IsAnImageError,
|
|
18243
|
-
|
|
18233
|
+
IsAnUnsupportedFileTypeError,
|
|
18234
|
+
MediaParserAbortError,
|
|
18235
|
+
MediaParserInternals,
|
|
18236
|
+
VERSION,
|
|
18237
|
+
WEBCODECS_TIMESCALE,
|
|
18238
|
+
defaultSelectM3uAssociatedPlaylists,
|
|
18239
|
+
defaultSelectM3uStreamFn,
|
|
18240
|
+
downloadAndParseMedia,
|
|
18241
|
+
hasBeenAborted,
|
|
18242
|
+
mediaParserController,
|
|
18243
|
+
parseMedia
|
|
18244
18244
|
};
|