@remotion/media-parser 4.0.266 → 4.0.267

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.
Files changed (62) hide show
  1. package/dist/containers/flac/get-channel-count.d.ts +1 -1
  2. package/dist/containers/m3u/get-streams.d.ts +10 -0
  3. package/dist/containers/m3u/get-streams.js +20 -0
  4. package/dist/containers/m3u/parse-directive.js +8 -0
  5. package/dist/containers/m3u/parse-m3u-media-directive.d.ts +2 -0
  6. package/dist/containers/m3u/parse-m3u-media-directive.js +31 -0
  7. package/dist/containers/m3u/parse-stream-inf.js +1 -0
  8. package/dist/containers/m3u/types.d.ts +15 -1
  9. package/dist/esm/{from-fetch.mjs → fetch.mjs} +3 -119
  10. package/dist/esm/index.mjs +322 -269
  11. package/dist/esm/node-writer.mjs +113 -0
  12. package/dist/esm/node.mjs +37 -106
  13. package/dist/fetch.d.ts +1 -0
  14. package/dist/fetch.js +17 -0
  15. package/dist/make-hvc1-codec-strings.js +3 -3
  16. package/dist/node-writer.d.ts +1 -0
  17. package/dist/node-writer.js +17 -0
  18. package/dist/node.d.ts +1 -0
  19. package/dist/node.js +17 -0
  20. package/dist/readers/fetch/get-body-and-reader.js +3 -2
  21. package/dist/state/parser-state.d.ts +2 -2
  22. package/dist/version.d.ts +1 -1
  23. package/dist/version.js +1 -1
  24. package/dist/web-file.d.ts +1 -0
  25. package/dist/web-file.js +17 -0
  26. package/package.json +32 -32
  27. package/dist/containers/flac/m3u/after-manifest-fetch.d.ts +0 -14
  28. package/dist/containers/flac/m3u/after-manifest-fetch.js +0 -53
  29. package/dist/containers/flac/m3u/fetch-m3u8-stream.d.ts +0 -3
  30. package/dist/containers/flac/m3u/fetch-m3u8-stream.js +0 -15
  31. package/dist/containers/flac/m3u/get-chunks.d.ts +0 -6
  32. package/dist/containers/flac/m3u/get-chunks.js +0 -20
  33. package/dist/containers/flac/m3u/get-duration-from-m3u.d.ts +0 -2
  34. package/dist/containers/flac/m3u/get-duration-from-m3u.js +0 -9
  35. package/dist/containers/flac/m3u/get-playlist.d.ts +0 -3
  36. package/dist/containers/flac/m3u/get-playlist.js +0 -19
  37. package/dist/containers/flac/m3u/get-streams.d.ts +0 -13
  38. package/dist/containers/flac/m3u/get-streams.js +0 -41
  39. package/dist/containers/flac/m3u/parse-directive.d.ts +0 -2
  40. package/dist/containers/flac/m3u/parse-directive.js +0 -64
  41. package/dist/containers/flac/m3u/parse-m3u-manifest.d.ts +0 -8
  42. package/dist/containers/flac/m3u/parse-m3u-manifest.js +0 -18
  43. package/dist/containers/flac/m3u/parse-m3u.d.ts +0 -4
  44. package/dist/containers/flac/m3u/parse-m3u.js +0 -35
  45. package/dist/containers/flac/m3u/parse-m3u8-text.d.ts +0 -2
  46. package/dist/containers/flac/m3u/parse-m3u8-text.js +0 -23
  47. package/dist/containers/flac/m3u/parse-stream-inf.d.ts +0 -3
  48. package/dist/containers/flac/m3u/parse-stream-inf.js +0 -61
  49. package/dist/containers/flac/m3u/return-packets.d.ts +0 -14
  50. package/dist/containers/flac/m3u/return-packets.js +0 -63
  51. package/dist/containers/flac/m3u/select-stream.d.ts +0 -10
  52. package/dist/containers/flac/m3u/select-stream.js +0 -15
  53. package/dist/containers/flac/m3u/types.d.ts +0 -48
  54. package/dist/containers/flac/m3u/types.js +0 -2
  55. package/dist/containers/mp3/get-tracks-from-mp3.d.ts +0 -4
  56. package/dist/containers/mp3/get-tracks-from-mp3.js +0 -25
  57. package/dist/does-need-contentlength-contentrange.d.ts +0 -2
  58. package/dist/does-need-contentlength-contentrange.js +0 -10
  59. package/dist/esm/from-node.mjs +0 -44
  60. package/dist/readers/from-uintarray.d.ts +0 -2
  61. package/dist/readers/from-uintarray.js +0 -27
  62. /package/dist/esm/{from-web-file.mjs → web-file.mjs} +0 -0
@@ -1,2 +1,2 @@
1
1
  import type { BufferIterator } from '../../buffer-iterator';
2
- export declare const getChannelCount: (iterator: BufferIterator) => 2 | 1 | 8 | 7 | 3 | 6 | 5 | 4;
2
+ export declare const getChannelCount: (iterator: BufferIterator) => 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8;
@@ -1,6 +1,15 @@
1
1
  import type { Dimensions } from '../../get-dimensions';
2
2
  import type { Structure } from '../../parse-result';
3
3
  import type { ParserState } from '../../state/parser-state';
4
+ export type M3uStreamAudioTrack = {
5
+ groupId: string;
6
+ language: string | null;
7
+ name: string | null;
8
+ autoselect: boolean;
9
+ default: boolean;
10
+ channels: number | null;
11
+ url: string;
12
+ };
4
13
  export type M3uStream = {
5
14
  url: string;
6
15
  bandwidth: number | null;
@@ -8,6 +17,7 @@ export type M3uStream = {
8
17
  resolution: Dimensions | null;
9
18
  codecs: string[] | null;
10
19
  id: number;
20
+ dedicatedAudioTracks: M3uStreamAudioTrack[];
11
21
  };
12
22
  export declare const isIndependentSegments: (structure: Structure | null) => boolean;
13
23
  export declare const getM3uStreams: (structure: Structure | null, originalSrc: string | null) => M3uStream[] | null;
@@ -20,6 +20,25 @@ const getM3uStreams = (structure, originalSrc) => {
20
20
  if (next.type !== 'm3u-text-value') {
21
21
  throw new Error('Expected m3u-text-value');
22
22
  }
23
+ const dedicatedAudioTracks = [];
24
+ if (str.audio) {
25
+ const match = structure.boxes.filter((box) => {
26
+ return box.type === 'm3u-media-info' && box.groupId === str.audio;
27
+ });
28
+ for (const audioTrack of match) {
29
+ dedicatedAudioTracks.push({
30
+ autoselect: audioTrack.autoselect,
31
+ channels: audioTrack.channels,
32
+ default: audioTrack.default,
33
+ groupId: audioTrack.groupId,
34
+ language: audioTrack.language,
35
+ name: audioTrack.name,
36
+ url: originalSrc && originalSrc.startsWith('http')
37
+ ? new URL(audioTrack.uri, originalSrc).href
38
+ : audioTrack.uri,
39
+ });
40
+ }
41
+ }
23
42
  boxes.push({
24
43
  url: originalSrc && originalSrc.startsWith('http')
25
44
  ? new URL(next.value, originalSrc).href
@@ -28,6 +47,7 @@ const getM3uStreams = (structure, originalSrc) => {
28
47
  bandwidth: str.bandwidth,
29
48
  codecs: str.codecs,
30
49
  resolution: str.resolution,
50
+ dedicatedAudioTracks,
31
51
  });
32
52
  }
33
53
  }
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.parseM3uDirective = void 0;
4
+ const parse_m3u_media_directive_1 = require("./parse-m3u-media-directive");
4
5
  const parse_stream_inf_1 = require("./parse-stream-inf");
5
6
  const parseM3uDirective = (str) => {
6
7
  const firstColon = str.indexOf(':');
@@ -20,6 +21,13 @@ const parseM3uDirective = (str) => {
20
21
  type: 'm3u-independent-segments',
21
22
  };
22
23
  }
24
+ if (directive === '#EXT-X-MEDIA') {
25
+ if (!value) {
26
+ throw new Error('EXT-X-MEDIA directive must have a value');
27
+ }
28
+ const parsed = (0, parse_m3u_media_directive_1.parseM3uMediaDirective)(value);
29
+ return parsed;
30
+ }
23
31
  if (directive === '#EXT-X-TARGETDURATION') {
24
32
  if (!value) {
25
33
  throw new Error('EXT-X-TARGETDURATION directive must have a value');
@@ -0,0 +1,2 @@
1
+ import type { M3uMediaInfo } from './types';
2
+ export declare const parseM3uMediaDirective: (str: string) => M3uMediaInfo;
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseM3uMediaDirective = void 0;
4
+ const parse_stream_inf_1 = require("./parse-stream-inf");
5
+ const parseM3uMediaDirective = (str) => {
6
+ const quotes = (0, parse_stream_inf_1.splitRespectingQuotes)(str);
7
+ const map = {};
8
+ for (const quote of quotes) {
9
+ const firstColon = quote.indexOf('=');
10
+ const key = firstColon === -1 ? quote : quote.slice(0, firstColon);
11
+ const value = firstColon === -1 ? null : quote.slice(firstColon + 1);
12
+ if (value === null) {
13
+ throw new Error('Value is null');
14
+ }
15
+ const actualValue = (value === null || value === void 0 ? void 0 : value.startsWith('"')) && (value === null || value === void 0 ? void 0 : value.endsWith('"'))
16
+ ? value.slice(1, -1)
17
+ : value;
18
+ map[key] = actualValue;
19
+ }
20
+ return {
21
+ type: 'm3u-media-info',
22
+ autoselect: map.AUTOSELECT === 'YES',
23
+ channels: map.CHANNELS ? parseInt(map.CHANNELS, 10) : null,
24
+ default: map.DEFAULT === 'YES',
25
+ groupId: map['GROUP-ID'],
26
+ language: map.LANGUAGE || null,
27
+ name: map.NAME || null,
28
+ uri: map.URI,
29
+ };
30
+ };
31
+ exports.parseM3uMediaDirective = parseM3uMediaDirective;
@@ -56,6 +56,7 @@ const parseStreamInf = (str) => {
56
56
  height: parseInt(map.RESOLUTION.split('x')[1], 10),
57
57
  }
58
58
  : null,
59
+ audio: map.AUDIO || null,
59
60
  };
60
61
  };
61
62
  exports.parseStreamInf = parseStreamInf;
@@ -8,6 +8,9 @@ export type M3uVersion = {
8
8
  export type M3uIndependentSegments = {
9
9
  type: 'm3u-independent-segments';
10
10
  };
11
+ export type M3uMedia = {
12
+ type: 'm3u-media';
13
+ };
11
14
  export type M3uTargetDuration = {
12
15
  type: 'm3u-target-duration';
13
16
  duration: number;
@@ -36,12 +39,23 @@ export type M3uStreamInfo = {
36
39
  width: number;
37
40
  height: number;
38
41
  } | null;
42
+ audio: string | null;
43
+ };
44
+ export type M3uMediaInfo = {
45
+ type: 'm3u-media-info';
46
+ groupId: string;
47
+ language: string | null;
48
+ name: string | null;
49
+ autoselect: boolean;
50
+ default: boolean;
51
+ channels: number | null;
52
+ uri: string;
39
53
  };
40
54
  export type M3uTextValue = {
41
55
  type: 'm3u-text-value';
42
56
  value: string;
43
57
  };
44
- export type M3uBox = M3uHeader | M3uPlaylist | M3uVersion | M3uIndependentSegments | M3uStreamInfo | M3uTargetDuration | M3uPlaylistType | M3uExtInf | M3uEndList | M3uTextValue;
58
+ export type M3uBox = M3uHeader | M3uPlaylist | M3uVersion | M3uIndependentSegments | M3uStreamInfo | M3uTargetDuration | M3uPlaylistType | M3uExtInf | M3uMedia | M3uMediaInfo | M3uEndList | M3uTextValue;
45
59
  export type M3uStructure = {
46
60
  type: 'm3u';
47
61
  boxes: M3uBox[];
@@ -1,118 +1,4 @@
1
1
  // src/errors.ts
2
- class IsAGifError extends Error {
3
- mimeType;
4
- sizeInBytes;
5
- fileName;
6
- constructor({
7
- message,
8
- mimeType,
9
- sizeInBytes,
10
- fileName
11
- }) {
12
- super(message);
13
- this.fileName = "IsAGifError";
14
- this.mimeType = mimeType;
15
- this.sizeInBytes = sizeInBytes;
16
- this.fileName = fileName;
17
- if (Error.captureStackTrace) {
18
- Error.captureStackTrace(this, IsAGifError);
19
- }
20
- }
21
- }
22
-
23
- class IsAnImageError extends Error {
24
- imageType;
25
- dimensions;
26
- mimeType;
27
- sizeInBytes;
28
- fileName;
29
- constructor({
30
- dimensions,
31
- imageType,
32
- message,
33
- mimeType,
34
- sizeInBytes,
35
- fileName
36
- }) {
37
- super(message);
38
- this.name = "IsAnImageError";
39
- this.imageType = imageType;
40
- this.dimensions = dimensions;
41
- this.mimeType = mimeType;
42
- this.sizeInBytes = sizeInBytes;
43
- this.fileName = fileName;
44
- if (Error.captureStackTrace) {
45
- Error.captureStackTrace(this, IsAnImageError);
46
- }
47
- }
48
- }
49
-
50
- class IsAPdfError extends Error {
51
- mimeType;
52
- sizeInBytes;
53
- fileName;
54
- constructor({
55
- message,
56
- mimeType,
57
- sizeInBytes,
58
- fileName
59
- }) {
60
- super(message);
61
- this.name = "IsAPdfError";
62
- this.mimeType = mimeType;
63
- this.sizeInBytes = sizeInBytes;
64
- this.fileName = fileName;
65
- if (Error.captureStackTrace) {
66
- Error.captureStackTrace(this, IsAPdfError);
67
- }
68
- }
69
- }
70
-
71
- class IsAnUnsupportedFileTypeError extends Error {
72
- mimeType;
73
- sizeInBytes;
74
- fileName;
75
- constructor({
76
- message,
77
- mimeType,
78
- sizeInBytes,
79
- fileName
80
- }) {
81
- super(message);
82
- this.name = "IsAnUnsupportedFileTypeError";
83
- this.mimeType = mimeType;
84
- this.sizeInBytes = sizeInBytes;
85
- this.fileName = fileName;
86
- if (Error.captureStackTrace) {
87
- Error.captureStackTrace(this, IsAnUnsupportedFileTypeError);
88
- }
89
- }
90
- }
91
-
92
- class IsAnUnsupportedAudioTypeError extends Error {
93
- mimeType;
94
- sizeInBytes;
95
- fileName;
96
- audioType;
97
- constructor({
98
- message,
99
- mimeType,
100
- sizeInBytes,
101
- fileName,
102
- audioType
103
- }) {
104
- super(message);
105
- this.name = "IsAnUnsupportedAudioTypeError";
106
- this.mimeType = mimeType;
107
- this.sizeInBytes = sizeInBytes;
108
- this.fileName = fileName;
109
- this.audioType = audioType;
110
- if (Error.captureStackTrace) {
111
- Error.captureStackTrace(this, IsAnUnsupportedAudioTypeError);
112
- }
113
- }
114
- }
115
-
116
2
  class MediaParserAbortError extends Error {
117
3
  constructor(message) {
118
4
  super(message);
@@ -120,22 +6,20 @@ class MediaParserAbortError extends Error {
120
6
  this.cause = undefined;
121
7
  }
122
8
  }
123
- var hasBeenAborted = (error) => {
124
- return error instanceof MediaParserAbortError;
125
- };
126
9
 
127
10
  // src/readers/fetch/get-body-and-reader.ts
128
11
  var getLengthAndReader = async (endsWithM3u8, res, ownController) => {
129
12
  if (endsWithM3u8) {
130
13
  const text = await res.text();
14
+ const encoded = new TextEncoder().encode(text);
131
15
  const stream = new ReadableStream({
132
16
  start(controller) {
133
- controller.enqueue(new TextEncoder().encode(text));
17
+ controller.enqueue(encoded);
134
18
  controller.close();
135
19
  }
136
20
  });
137
21
  return {
138
- contentLength: text.length,
22
+ contentLength: encoded.byteLength,
139
23
  reader: {
140
24
  reader: stream.getReader(),
141
25
  abort() {