@remotion/media-parser 4.0.382 → 4.0.384

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.
@@ -1,2 +1,2 @@
1
1
  import type { BufferIterator } from '../../iterator/buffer-iterator';
2
- export declare const getBlockSize: (iterator: BufferIterator) => number | "uncommon-u16" | "uncommon-u8";
2
+ export declare const getBlockSize: (iterator: BufferIterator) => number | "uncommon-u16" | "uncommon-u8" | null;
@@ -4,7 +4,10 @@ exports.getBlockSize = void 0;
4
4
  const getBlockSize = (iterator) => {
5
5
  const bits = iterator.getBits(4);
6
6
  if (bits === 0b0000) {
7
- throw new Error('Reserved block size');
7
+ // Probably we are in the wrong spot overall, and just landed on a spot that incidentially hit the syncword.
8
+ // Don't throw an error, in the parent function just keep reading.
9
+ // Internal message with repro: https://discord.com/channels/@me/1314232261008162876/1410312296709881988
10
+ return null;
8
11
  }
9
12
  if (bits === 0b0001) {
10
13
  return 192;
@@ -31,6 +31,12 @@ const getChannelCount = (iterator) => {
31
31
  if (bits === 0b1000 || bits === 0b1001 || bits === 0b1010) {
32
32
  return 2;
33
33
  }
34
+ // 0b1011..0b1111 are reserved per RFC 9639 §9.1.3 (Channels Bits).
35
+ // Some encoders/files in the wild may nonetheless use these values.
36
+ // Be lenient and treat them as stereo (2 channels) to keep parsing robust.
37
+ if (bits >= 0b1011 && bits <= 0b1111) {
38
+ return 2;
39
+ }
34
40
  throw new Error(`Invalid channel count: ${bits.toString(2)}`);
35
41
  };
36
42
  exports.getChannelCount = getChannelCount;
@@ -5,7 +5,7 @@ exports.getSampleRate = void 0;
5
5
  const getSampleRate = (iterator, state) => {
6
6
  var _a, _b;
7
7
  const mode = iterator.getBits(4);
8
- if (mode === 0b0000) {
8
+ if (mode === 0b0000 || mode === 0b1111) {
9
9
  const structure = state.structure.getFlacStructure();
10
10
  const sampleRate = (_b = (_a = structure.boxes.find((box) => box.type === 'flac-streaminfo')) === null || _a === void 0 ? void 0 : _a.sampleRate) !== null && _b !== void 0 ? _b : null;
11
11
  if (sampleRate === null) {
@@ -34,6 +34,9 @@ const parseFrameHeader = ({ iterator, state, }) => {
34
34
  iterator.discard(2); // sync code
35
35
  iterator.startReadingBits();
36
36
  const blockSizeBits = (0, get_block_size_1.getBlockSize)(iterator);
37
+ if (blockSizeBits === null) {
38
+ return null;
39
+ }
37
40
  const sampleRateBits = (0, get_sample_rate_1.getSampleRate)(iterator, state);
38
41
  (0, get_channel_count_1.getChannelCount)(iterator); // channel count
39
42
  iterator.getBits(3); // bit depth
@@ -10964,7 +10964,7 @@ var parseAac = async (state) => {
10964
10964
  var getBlockSize = (iterator) => {
10965
10965
  const bits = iterator.getBits(4);
10966
10966
  if (bits === 0) {
10967
- throw new Error("Reserved block size");
10967
+ return null;
10968
10968
  }
10969
10969
  if (bits === 1) {
10970
10970
  return 192;
@@ -11014,13 +11014,16 @@ var getChannelCount = (iterator) => {
11014
11014
  if (bits === 8 || bits === 9 || bits === 10) {
11015
11015
  return 2;
11016
11016
  }
11017
+ if (bits >= 11 && bits <= 15) {
11018
+ return 2;
11019
+ }
11017
11020
  throw new Error(`Invalid channel count: ${bits.toString(2)}`);
11018
11021
  };
11019
11022
 
11020
11023
  // src/containers/flac/get-sample-rate.ts
11021
11024
  var getSampleRate4 = (iterator, state) => {
11022
11025
  const mode = iterator.getBits(4);
11023
- if (mode === 0) {
11026
+ if (mode === 0 || mode === 15) {
11024
11027
  const structure = state.structure.getFlacStructure();
11025
11028
  const sampleRate = structure.boxes.find((box) => box.type === "flac-streaminfo")?.sampleRate ?? null;
11026
11029
  if (sampleRate === null) {
@@ -11101,6 +11104,9 @@ var parseFrameHeader = ({
11101
11104
  iterator.discard(2);
11102
11105
  iterator.startReadingBits();
11103
11106
  const blockSizeBits = getBlockSize(iterator);
11107
+ if (blockSizeBits === null) {
11108
+ return null;
11109
+ }
11104
11110
  const sampleRateBits = getSampleRate4(iterator, state);
11105
11111
  getChannelCount(iterator);
11106
11112
  iterator.getBits(3);
@@ -18187,7 +18193,7 @@ var downloadAndParseMedia = async (options) => {
18187
18193
  return returnValue;
18188
18194
  };
18189
18195
  // src/version.ts
18190
- var VERSION = "4.0.382";
18196
+ var VERSION = "4.0.384";
18191
18197
 
18192
18198
  // src/index.ts
18193
18199
  var MediaParserInternals = {
@@ -8973,7 +8973,7 @@ var makeFetchMoreData = (bytesNeeded) => ({
8973
8973
  var getBlockSize = (iterator) => {
8974
8974
  const bits = iterator.getBits(4);
8975
8975
  if (bits === 0) {
8976
- throw new Error("Reserved block size");
8976
+ return null;
8977
8977
  }
8978
8978
  if (bits === 1) {
8979
8979
  return 192;
@@ -9023,13 +9023,16 @@ var getChannelCount = (iterator) => {
9023
9023
  if (bits === 8 || bits === 9 || bits === 10) {
9024
9024
  return 2;
9025
9025
  }
9026
+ if (bits >= 11 && bits <= 15) {
9027
+ return 2;
9028
+ }
9026
9029
  throw new Error(`Invalid channel count: ${bits.toString(2)}`);
9027
9030
  };
9028
9031
 
9029
9032
  // src/containers/flac/get-sample-rate.ts
9030
9033
  var getSampleRate4 = (iterator, state) => {
9031
9034
  const mode = iterator.getBits(4);
9032
- if (mode === 0) {
9035
+ if (mode === 0 || mode === 15) {
9033
9036
  const structure = state.structure.getFlacStructure();
9034
9037
  const sampleRate = structure.boxes.find((box) => box.type === "flac-streaminfo")?.sampleRate ?? null;
9035
9038
  if (sampleRate === null) {
@@ -9110,6 +9113,9 @@ var parseFrameHeader = ({
9110
9113
  iterator.discard(2);
9111
9114
  iterator.startReadingBits();
9112
9115
  const blockSizeBits = getBlockSize(iterator);
9116
+ if (blockSizeBits === null) {
9117
+ return null;
9118
+ }
9113
9119
  const sampleRateBits = getSampleRate4(iterator, state);
9114
9120
  getChannelCount(iterator);
9115
9121
  iterator.getBits(3);
@@ -8870,7 +8870,7 @@ var makeFetchMoreData = (bytesNeeded) => ({
8870
8870
  var getBlockSize = (iterator) => {
8871
8871
  const bits = iterator.getBits(4);
8872
8872
  if (bits === 0) {
8873
- throw new Error("Reserved block size");
8873
+ return null;
8874
8874
  }
8875
8875
  if (bits === 1) {
8876
8876
  return 192;
@@ -8920,13 +8920,16 @@ var getChannelCount = (iterator) => {
8920
8920
  if (bits === 8 || bits === 9 || bits === 10) {
8921
8921
  return 2;
8922
8922
  }
8923
+ if (bits >= 11 && bits <= 15) {
8924
+ return 2;
8925
+ }
8923
8926
  throw new Error(`Invalid channel count: ${bits.toString(2)}`);
8924
8927
  };
8925
8928
 
8926
8929
  // src/containers/flac/get-sample-rate.ts
8927
8930
  var getSampleRate4 = (iterator, state) => {
8928
8931
  const mode = iterator.getBits(4);
8929
- if (mode === 0) {
8932
+ if (mode === 0 || mode === 15) {
8930
8933
  const structure = state.structure.getFlacStructure();
8931
8934
  const sampleRate = structure.boxes.find((box) => box.type === "flac-streaminfo")?.sampleRate ?? null;
8932
8935
  if (sampleRate === null) {
@@ -9007,6 +9010,9 @@ var parseFrameHeader = ({
9007
9010
  iterator.discard(2);
9008
9011
  iterator.startReadingBits();
9009
9012
  const blockSizeBits = getBlockSize(iterator);
9013
+ if (blockSizeBits === null) {
9014
+ return null;
9015
+ }
9010
9016
  const sampleRateBits = getSampleRate4(iterator, state);
9011
9017
  getChannelCount(iterator);
9012
9018
  iterator.getBits(3);
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const VERSION = "4.0.382";
1
+ export declare const VERSION = "4.0.384";
package/dist/version.js CHANGED
@@ -2,4 +2,4 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VERSION = void 0;
4
4
  // Automatically generated on publish
5
- exports.VERSION = '4.0.382';
5
+ exports.VERSION = '4.0.384';
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "url": "https://github.com/remotion-dev/remotion/tree/main/packages/media-parser"
4
4
  },
5
5
  "name": "@remotion/media-parser",
6
- "version": "4.0.382",
6
+ "version": "4.0.384",
7
7
  "main": "dist/index.js",
8
8
  "sideEffects": false,
9
9
  "scripts": {
@@ -14,11 +14,11 @@
14
14
  "prepublishOnly": "bun ensure-correct-version.ts"
15
15
  },
16
16
  "devDependencies": {
17
- "@remotion/example-videos": "4.0.382",
17
+ "@remotion/example-videos": "4.0.384",
18
18
  "@types/wicg-file-system-access": "2023.10.5",
19
- "@remotion/eslint-config-internal": "4.0.382",
19
+ "@remotion/eslint-config-internal": "4.0.384",
20
20
  "eslint": "9.19.0",
21
- "mediabunny": "1.25.3",
21
+ "mediabunny": "1.25.8",
22
22
  "@types/bun": "1.3.3"
23
23
  },
24
24
  "publishConfig": {