@remotion/media-parser 4.0.266 → 4.0.268

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 (79) 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/containers/mp3/get-duration.js +4 -3
  10. package/dist/containers/mp3/parse-mpeg-header.js +57 -40
  11. package/dist/containers/webm/get-ready-tracks.d.ts +9 -2
  12. package/dist/containers/webm/get-ready-tracks.js +43 -8
  13. package/dist/containers/webm/get-sample-from-block.js +19 -0
  14. package/dist/containers/webm/make-track.d.ts +1 -0
  15. package/dist/containers/webm/make-track.js +9 -8
  16. package/dist/esm/{from-fetch.mjs → fetch.mjs} +33 -129
  17. package/dist/esm/index.mjs +896 -740
  18. package/dist/esm/node-writer.mjs +113 -0
  19. package/dist/esm/node.mjs +37 -106
  20. package/dist/fetch.d.ts +1 -0
  21. package/dist/fetch.js +17 -0
  22. package/dist/get-tracks.js +7 -14
  23. package/dist/has-all-info.js +7 -3
  24. package/dist/index.d.ts +4 -0
  25. package/dist/internal-parse-media.js +1 -1
  26. package/dist/make-hvc1-codec-strings.js +3 -3
  27. package/dist/node-writer.d.ts +1 -0
  28. package/dist/node-writer.js +17 -0
  29. package/dist/node.d.ts +1 -0
  30. package/dist/node.js +17 -0
  31. package/dist/readers/fetch/get-body-and-reader.d.ts +6 -1
  32. package/dist/readers/fetch/get-body-and-reader.js +9 -7
  33. package/dist/readers/from-fetch.js +16 -5
  34. package/dist/state/mp3.d.ts +5 -1
  35. package/dist/state/mp3.js +6 -0
  36. package/dist/state/parser-state.d.ts +6 -2
  37. package/dist/state/webm.d.ts +4 -0
  38. package/dist/state/webm.js +10 -0
  39. package/dist/version.d.ts +1 -1
  40. package/dist/version.js +1 -1
  41. package/dist/web-file.d.ts +1 -0
  42. package/dist/web-file.js +17 -0
  43. package/package.json +32 -32
  44. package/dist/containers/flac/m3u/after-manifest-fetch.d.ts +0 -14
  45. package/dist/containers/flac/m3u/after-manifest-fetch.js +0 -53
  46. package/dist/containers/flac/m3u/fetch-m3u8-stream.d.ts +0 -3
  47. package/dist/containers/flac/m3u/fetch-m3u8-stream.js +0 -15
  48. package/dist/containers/flac/m3u/get-chunks.d.ts +0 -6
  49. package/dist/containers/flac/m3u/get-chunks.js +0 -20
  50. package/dist/containers/flac/m3u/get-duration-from-m3u.d.ts +0 -2
  51. package/dist/containers/flac/m3u/get-duration-from-m3u.js +0 -9
  52. package/dist/containers/flac/m3u/get-playlist.d.ts +0 -3
  53. package/dist/containers/flac/m3u/get-playlist.js +0 -19
  54. package/dist/containers/flac/m3u/get-streams.d.ts +0 -13
  55. package/dist/containers/flac/m3u/get-streams.js +0 -41
  56. package/dist/containers/flac/m3u/parse-directive.d.ts +0 -2
  57. package/dist/containers/flac/m3u/parse-directive.js +0 -64
  58. package/dist/containers/flac/m3u/parse-m3u-manifest.d.ts +0 -8
  59. package/dist/containers/flac/m3u/parse-m3u-manifest.js +0 -18
  60. package/dist/containers/flac/m3u/parse-m3u.d.ts +0 -4
  61. package/dist/containers/flac/m3u/parse-m3u.js +0 -35
  62. package/dist/containers/flac/m3u/parse-m3u8-text.d.ts +0 -2
  63. package/dist/containers/flac/m3u/parse-m3u8-text.js +0 -23
  64. package/dist/containers/flac/m3u/parse-stream-inf.d.ts +0 -3
  65. package/dist/containers/flac/m3u/parse-stream-inf.js +0 -61
  66. package/dist/containers/flac/m3u/return-packets.d.ts +0 -14
  67. package/dist/containers/flac/m3u/return-packets.js +0 -63
  68. package/dist/containers/flac/m3u/select-stream.d.ts +0 -10
  69. package/dist/containers/flac/m3u/select-stream.js +0 -15
  70. package/dist/containers/flac/m3u/types.d.ts +0 -48
  71. package/dist/containers/flac/m3u/types.js +0 -2
  72. package/dist/containers/mp3/get-tracks-from-mp3.d.ts +0 -4
  73. package/dist/containers/mp3/get-tracks-from-mp3.js +0 -25
  74. package/dist/does-need-contentlength-contentrange.d.ts +0 -2
  75. package/dist/does-need-contentlength-contentrange.js +0 -10
  76. package/dist/esm/from-node.mjs +0 -44
  77. package/dist/readers/from-uintarray.d.ts +0 -2
  78. package/dist/readers/from-uintarray.js +0 -27
  79. /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[];
@@ -5,15 +5,16 @@ const get_frame_length_1 = require("./get-frame-length");
5
5
  const samples_per_mpeg_file_1 = require("./samples-per-mpeg-file");
6
6
  const getDurationFromMp3 = (state) => {
7
7
  const mp3Info = state.mp3Info.getMp3Info();
8
- if (!mp3Info) {
9
- throw new Error('No mp3 info');
8
+ const mp3CbrInfo = state.mp3Info.getCbrMp3Info();
9
+ if (!mp3Info || !mp3CbrInfo) {
10
+ return null;
10
11
  }
11
12
  const samplesPerFrame = (0, samples_per_mpeg_file_1.getSamplesPerMpegFrame)({
12
13
  layer: mp3Info.layer,
13
14
  mpegVersion: mp3Info.mpegVersion,
14
15
  });
15
16
  const frameLengthInBytes = (0, get_frame_length_1.getMpegFrameLength)({
16
- bitrateKbit: mp3Info.bitrateKbit,
17
+ bitrateKbit: mp3CbrInfo.bitrateKbit,
17
18
  padding: false,
18
19
  samplesPerFrame,
19
20
  samplingFrequency: mp3Info.sampleRate,
@@ -2,6 +2,7 @@
2
2
  // spec: http://www.mp3-tech.org/programmer/frame_header.html
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.parseMpegHeader = void 0;
5
+ const log_1 = require("../../log");
5
6
  const register_track_1 = require("../../register-track");
6
7
  const get_frame_length_1 = require("./get-frame-length");
7
8
  const samples_per_mpeg_file_1 = require("./samples-per-mpeg-file");
@@ -219,35 +220,45 @@ const parseMpegHeader = async ({ state, }) => {
219
220
  const offsetNow = iterator.counter.getOffset();
220
221
  iterator.counter.decrement(offsetNow - initialOffset);
221
222
  const data = iterator.getSlice(frameLength);
223
+ let isInfoTag = false;
222
224
  if (state.callbacks.tracks.getTracks().length === 0) {
223
- state.mp3Info.setMp3Info({
225
+ const info = {
224
226
  layer,
225
227
  mpegVersion,
226
228
  sampleRate,
227
- bitrateKbit,
228
229
  startOfMpegStream: initialOffset,
229
- });
230
- await (0, register_track_1.registerAudioTrack)({
231
- container: 'mp3',
232
- state,
233
- track: {
234
- type: 'audio',
235
- codec: 'mp3',
236
- codecPrivate: null,
237
- codecWithoutConfig: 'mp3',
238
- description: undefined,
239
- numberOfChannels,
240
- sampleRate,
241
- timescale: 1000000,
242
- trackId: 0,
243
- trakBox: null,
244
- },
245
- });
246
- state.callbacks.tracks.setIsDone(state.logLevel);
247
- }
248
- const mp3Info = state.mp3Info.getMp3Info();
249
- if (!mp3Info) {
250
- throw new Error('No MP3 info by now');
230
+ };
231
+ const asText = new TextDecoder().decode(data);
232
+ const isVbr = asText.includes('Xing') || asText.includes('VBRI');
233
+ isInfoTag = isVbr || asText.includes('Info');
234
+ if (isVbr) {
235
+ log_1.Log.verbose(state.logLevel, 'MP3 has variable bit rate. Requiring whole file to be read');
236
+ }
237
+ else {
238
+ state.mp3Info.setCbrMp3Info({
239
+ bitrateKbit,
240
+ });
241
+ }
242
+ if (!isInfoTag) {
243
+ state.mp3Info.setMp3Info(info);
244
+ await (0, register_track_1.registerAudioTrack)({
245
+ container: 'mp3',
246
+ state,
247
+ track: {
248
+ type: 'audio',
249
+ codec: 'mp3',
250
+ codecPrivate: null,
251
+ codecWithoutConfig: 'mp3',
252
+ description: undefined,
253
+ numberOfChannels,
254
+ sampleRate,
255
+ timescale: 1000000,
256
+ trackId: 0,
257
+ trakBox: null,
258
+ },
259
+ });
260
+ state.callbacks.tracks.setIsDone(state.logLevel);
261
+ }
251
262
  }
252
263
  const avgLength = (0, get_frame_length_1.getAverageMpegFrameLength)({
253
264
  bitrateKbit,
@@ -255,21 +266,27 @@ const parseMpegHeader = async ({ state, }) => {
255
266
  samplesPerFrame,
256
267
  samplingFrequency: sampleRate,
257
268
  });
258
- const nthFrame = Math.round((initialOffset - mp3Info.startOfMpegStream) / avgLength);
259
- const durationInSeconds = samplesPerFrame / sampleRate;
260
- const timeInSeconds = (nthFrame * samplesPerFrame) / sampleRate;
261
- const timestamp = Math.round(timeInSeconds * 1000000);
262
- const duration = Math.round(durationInSeconds * 1000000);
263
- await state.callbacks.onAudioSample(0, {
264
- data,
265
- cts: timestamp,
266
- dts: timestamp,
267
- duration,
268
- offset: initialOffset,
269
- timescale: 1000000,
270
- timestamp,
271
- trackId: 0,
272
- type: 'key',
273
- });
269
+ if (!isInfoTag) {
270
+ const mp3Info = state.mp3Info.getMp3Info();
271
+ if (!mp3Info) {
272
+ throw new Error('No MP3 info');
273
+ }
274
+ const nthFrame = Math.round((initialOffset - mp3Info.startOfMpegStream) / avgLength);
275
+ const durationInSeconds = samplesPerFrame / sampleRate;
276
+ const timeInSeconds = (nthFrame * samplesPerFrame) / sampleRate;
277
+ const timestamp = Math.round(timeInSeconds * 1000000);
278
+ const duration = Math.round(durationInSeconds * 1000000);
279
+ await state.callbacks.onAudioSample(0, {
280
+ data,
281
+ cts: timestamp,
282
+ dts: timestamp,
283
+ duration,
284
+ offset: initialOffset,
285
+ timescale: 1000000,
286
+ timestamp,
287
+ trackId: 0,
288
+ type: 'key',
289
+ });
290
+ }
274
291
  };
275
292
  exports.parseMpegHeader = parseMpegHeader;
@@ -1,3 +1,10 @@
1
1
  import type { Track } from '../../get-tracks';
2
- import type { MainSegment } from './segments/all-segments';
3
- export declare const getTracksFromMatroska: (segment: MainSegment, timescale: number) => Track[];
2
+ import type { ParserState } from '../../state/parser-state';
3
+ export type ResolvedAndUnresolvedTracks = {
4
+ resolved: Track[];
5
+ missingInfo: Track[];
6
+ };
7
+ export declare const getTracksFromMatroska: ({ state, }: {
8
+ state: ParserState;
9
+ }) => ResolvedAndUnresolvedTracks;
10
+ export declare const matroskaHasTracks: (state: ParserState) => boolean;
@@ -1,14 +1,22 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getTracksFromMatroska = void 0;
3
+ exports.matroskaHasTracks = exports.getTracksFromMatroska = void 0;
4
+ const codec_string_1 = require("../avc/codec-string");
4
5
  const make_track_1 = require("./make-track");
5
6
  const traversal_1 = require("./traversal");
6
- const getTracksFromMatroska = (segment, timescale) => {
7
- const tracksSegment = (0, traversal_1.getTracksSegment)(segment);
7
+ const getTracksFromMatroska = ({ state, }) => {
8
+ const webmState = state.webm;
9
+ const structure = state.getMatroskaStructure();
10
+ const mainSegment = (0, traversal_1.getMainSegment)(structure.boxes);
11
+ if (!mainSegment) {
12
+ throw new Error('No main segment');
13
+ }
14
+ const tracksSegment = (0, traversal_1.getTracksSegment)(mainSegment);
8
15
  if (!tracksSegment) {
9
16
  throw new Error('No tracks segment');
10
17
  }
11
- const tracks = [];
18
+ const resolvedTracks = [];
19
+ const missingInfo = [];
12
20
  for (const trackEntrySegment of tracksSegment.value) {
13
21
  if (trackEntrySegment.type === 'Crc32') {
14
22
  continue;
@@ -18,12 +26,39 @@ const getTracksFromMatroska = (segment, timescale) => {
18
26
  }
19
27
  const track = (0, make_track_1.getTrack)({
20
28
  track: trackEntrySegment,
21
- timescale,
29
+ timescale: webmState.getTimescale(),
22
30
  });
23
- if (track) {
24
- tracks.push(track);
31
+ if (!track) {
32
+ continue;
33
+ }
34
+ if (track.codec === make_track_1.NO_CODEC_PRIVATE_SHOULD_BE_DERIVED_FROM_SPS) {
35
+ const avc = webmState.getAvcProfileForTrackNumber(track.trackId);
36
+ if (avc) {
37
+ resolvedTracks.push({
38
+ ...track,
39
+ codec: (0, codec_string_1.getCodecStringFromSpsAndPps)(avc),
40
+ });
41
+ }
42
+ else {
43
+ missingInfo.push(track);
44
+ }
45
+ }
46
+ else {
47
+ resolvedTracks.push(track);
25
48
  }
26
49
  }
27
- return tracks;
50
+ return { missingInfo, resolved: resolvedTracks };
28
51
  };
29
52
  exports.getTracksFromMatroska = getTracksFromMatroska;
53
+ const matroskaHasTracks = (state) => {
54
+ const structure = state.getMatroskaStructure();
55
+ const mainSegment = (0, traversal_1.getMainSegment)(structure.boxes);
56
+ if (!mainSegment) {
57
+ return false;
58
+ }
59
+ return ((0, traversal_1.getTracksSegment)(mainSegment) !== null &&
60
+ (0, exports.getTracksFromMatroska)({
61
+ state,
62
+ }).missingInfo.length === 0);
63
+ };
64
+ exports.matroskaHasTracks = matroskaHasTracks;
@@ -2,8 +2,21 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getSampleFromBlock = void 0;
4
4
  const buffer_iterator_1 = require("../../buffer-iterator");
5
+ const parse_avc_1 = require("../avc/parse-avc");
6
+ const get_ready_tracks_1 = require("./get-ready-tracks");
5
7
  const all_segments_1 = require("./segments/all-segments");
6
8
  const block_simple_block_flags_1 = require("./segments/block-simple-block-flags");
9
+ const addAvcToTrackIfNecessary = ({ partialVideoSample, codec, state, trackNumber, }) => {
10
+ if (codec === 'V_MPEG4/ISO/AVC' &&
11
+ (0, get_ready_tracks_1.getTracksFromMatroska)({ state }).missingInfo.length > 0) {
12
+ const parsed = (0, parse_avc_1.parseAvc)(partialVideoSample.data);
13
+ for (const parse of parsed) {
14
+ if (parse.type === 'avc-profile') {
15
+ state.webm.setAvcProfileForTrackNumber(trackNumber, parse);
16
+ }
17
+ }
18
+ }
19
+ };
7
20
  const getSampleFromBlock = (ebml, state, offset) => {
8
21
  const iterator = (0, buffer_iterator_1.getArrayBufferIterator)(ebml.value, ebml.value.length);
9
22
  const trackNumber = iterator.getVint();
@@ -49,6 +62,12 @@ const getSampleFromBlock = (ebml, state, offset) => {
49
62
  partialVideoSample,
50
63
  };
51
64
  }
65
+ addAvcToTrackIfNecessary({
66
+ codec,
67
+ partialVideoSample,
68
+ state,
69
+ trackNumber,
70
+ });
52
71
  const sample = {
53
72
  ...partialVideoSample,
54
73
  type: keyframe ? 'key' : 'delta',
@@ -1,5 +1,6 @@
1
1
  import type { AudioTrack, MediaParserAudioCodec, VideoTrack } from '../../get-tracks';
2
2
  import type { TrackEntry } from './segments/all-segments';
3
+ export declare const NO_CODEC_PRIVATE_SHOULD_BE_DERIVED_FROM_SPS = "no-codec-private-should-be-derived-from-sps";
3
4
  export declare const getMatroskaAudioCodecWithoutConfigString: ({ track, }: {
4
5
  track: TrackEntry;
5
6
  }) => MediaParserAudioCodec;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getTrack = exports.getMatroskaAudioCodecWithoutConfigString = void 0;
3
+ exports.getTrack = exports.getMatroskaAudioCodecWithoutConfigString = exports.NO_CODEC_PRIVATE_SHOULD_BE_DERIVED_FROM_SPS = void 0;
4
4
  const buffer_iterator_1 = require("../../buffer-iterator");
5
5
  const make_hvc1_codec_strings_1 = require("../../make-hvc1-codec-strings");
6
6
  const av1_codec_private_1 = require("./av1-codec-private");
@@ -8,6 +8,7 @@ const color_1 = require("./color");
8
8
  const description_1 = require("./description");
9
9
  const track_entry_1 = require("./segments/track-entry");
10
10
  const traversal_1 = require("./traversal");
11
+ exports.NO_CODEC_PRIVATE_SHOULD_BE_DERIVED_FROM_SPS = 'no-codec-private-should-be-derived-from-sps';
11
12
  const getDescription = (track) => {
12
13
  const codec = (0, traversal_1.getCodecSegment)(track);
13
14
  if (!codec) {
@@ -46,7 +47,7 @@ const getMatroskaVideoCodecString = ({ track, codecSegment: codec, }) => {
46
47
  if (codec.value === 'V_VP9') {
47
48
  const priv = (0, traversal_1.getPrivateData)(track);
48
49
  if (priv) {
49
- throw new Error('@remotion/media-parser cannot handle the private data for VP9. Do you have an example file you could send so we can implement it?');
50
+ throw new Error('@remotion/media-parser cannot handle the private data for VP9. Do you have an example file you could send so we can implement it? https://remotion.dev/report');
50
51
  }
51
52
  return 'vp09.00.10.08';
52
53
  }
@@ -55,7 +56,12 @@ const getMatroskaVideoCodecString = ({ track, codecSegment: codec, }) => {
55
56
  if (priv) {
56
57
  return `avc1.${priv[1].toString(16).padStart(2, '0')}${priv[2].toString(16).padStart(2, '0')}${priv[3].toString(16).padStart(2, '0')}`;
57
58
  }
58
- throw new Error('Could not find a CodecPrivate field in TrackEntry');
59
+ return exports.NO_CODEC_PRIVATE_SHOULD_BE_DERIVED_FROM_SPS;
60
+ }
61
+ if (codec.value === 'V_MPEGH/ISO/HEVC') {
62
+ const priv = (0, traversal_1.getPrivateData)(track);
63
+ const iterator = (0, buffer_iterator_1.getArrayBufferIterator)(priv, priv.length);
64
+ return 'hvc1.' + (0, make_hvc1_codec_strings_1.getHvc1CodecString)(iterator);
59
65
  }
60
66
  if (codec.value === 'V_AV1') {
61
67
  const priv = (0, traversal_1.getPrivateData)(track);
@@ -64,11 +70,6 @@ const getMatroskaVideoCodecString = ({ track, codecSegment: codec, }) => {
64
70
  }
65
71
  return (0, av1_codec_private_1.parseAv1PrivateData)(priv, null);
66
72
  }
67
- if (codec.value === 'V_MPEGH/ISO/HEVC') {
68
- const priv = (0, traversal_1.getPrivateData)(track);
69
- const iterator = (0, buffer_iterator_1.getArrayBufferIterator)(priv, priv.length);
70
- return 'hvc1.' + (0, make_hvc1_codec_strings_1.getHvc1CodecString)(iterator);
71
- }
72
73
  throw new Error(`Unknown codec: ${codec.value}`);
73
74
  };
74
75
  const getMatroskaAudioCodecWithoutConfigString = ({ track, }) => {