@remotion/media-utils 4.0.45 → 4.0.47

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.
@@ -4,27 +4,34 @@
4
4
  */
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.audioBufferToWav = void 0;
7
- function audioBufferToWav(buffer, opt) {
8
- const numChannels = buffer.numberOfChannels;
9
- const { sampleRate } = buffer;
10
- const format = opt.float32 ? 3 : 1;
11
- const bitDepth = format === 3 ? 32 : 16;
12
- let result;
13
- if (numChannels === 2) {
14
- result = interleave(buffer.getChannelData(0), buffer.getChannelData(1));
7
+ function interleave(inputL, inputR) {
8
+ const length = inputL.length + inputR.length;
9
+ const result = new Float32Array(length);
10
+ let index = 0;
11
+ let inputIndex = 0;
12
+ while (index < length) {
13
+ result[index++] = inputL[inputIndex];
14
+ result[index++] = inputR[inputIndex];
15
+ inputIndex++;
15
16
  }
16
- else {
17
- result = buffer.getChannelData(0);
17
+ return result;
18
+ }
19
+ function writeFloat32(output, offset, input) {
20
+ for (let i = 0; i < input.length; i++, offset += 4) {
21
+ output.setFloat32(offset, input[i], true);
22
+ }
23
+ }
24
+ function floatTo16BitPCM(output, offset, input) {
25
+ for (let i = 0; i < input.length; i++, offset += 2) {
26
+ const s = Math.max(-1, Math.min(1, input[i]));
27
+ output.setInt16(offset, s < 0 ? s * 0x8000 : s * 0x7fff, true);
28
+ }
29
+ }
30
+ function writeString(view, offset, string) {
31
+ for (let i = 0; i < string.length; i++) {
32
+ view.setUint8(offset + i, string.charCodeAt(i));
18
33
  }
19
- return encodeWAV({
20
- samples: result,
21
- format,
22
- sampleRate,
23
- numChannels,
24
- bitDepth,
25
- });
26
34
  }
27
- exports.audioBufferToWav = audioBufferToWav;
28
35
  function encodeWAV({ samples, format, sampleRate, numChannels, bitDepth, }) {
29
36
  const bytesPerSample = bitDepth / 8;
30
37
  const blockAlign = numChannels * bytesPerSample;
@@ -65,31 +72,24 @@ function encodeWAV({ samples, format, sampleRate, numChannels, bitDepth, }) {
65
72
  }
66
73
  return buffer;
67
74
  }
68
- function interleave(inputL, inputR) {
69
- const length = inputL.length + inputR.length;
70
- const result = new Float32Array(length);
71
- let index = 0;
72
- let inputIndex = 0;
73
- while (index < length) {
74
- result[index++] = inputL[inputIndex];
75
- result[index++] = inputR[inputIndex];
76
- inputIndex++;
77
- }
78
- return result;
79
- }
80
- function writeFloat32(output, offset, input) {
81
- for (let i = 0; i < input.length; i++, offset += 4) {
82
- output.setFloat32(offset, input[i], true);
83
- }
84
- }
85
- function floatTo16BitPCM(output, offset, input) {
86
- for (let i = 0; i < input.length; i++, offset += 2) {
87
- const s = Math.max(-1, Math.min(1, input[i]));
88
- output.setInt16(offset, s < 0 ? s * 0x8000 : s * 0x7fff, true);
75
+ function audioBufferToWav(buffer, opt) {
76
+ const numChannels = buffer.numberOfChannels;
77
+ const { sampleRate } = buffer;
78
+ const format = opt.float32 ? 3 : 1;
79
+ const bitDepth = format === 3 ? 32 : 16;
80
+ let result;
81
+ if (numChannels === 2) {
82
+ result = interleave(buffer.getChannelData(0), buffer.getChannelData(1));
89
83
  }
90
- }
91
- function writeString(view, offset, string) {
92
- for (let i = 0; i < string.length; i++) {
93
- view.setUint8(offset + i, string.charCodeAt(i));
84
+ else {
85
+ result = buffer.getChannelData(0);
94
86
  }
87
+ return encodeWAV({
88
+ samples: result,
89
+ format,
90
+ sampleRate,
91
+ numChannels,
92
+ bitDepth,
93
+ });
95
94
  }
95
+ exports.audioBufferToWav = audioBufferToWav;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getAudioDuration = exports.getAudioDurationInSeconds = void 0;
4
+ /* eslint-disable @typescript-eslint/no-use-before-define */
4
5
  const p_limit_1 = require("./p-limit");
5
6
  const limit = (0, p_limit_1.pLimit)(3);
6
7
  const metadataCache = {};
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getVideoMetadata = void 0;
4
+ /* eslint-disable @typescript-eslint/no-use-before-define */
4
5
  const is_remote_asset_1 = require("./is-remote-asset");
5
6
  const p_limit_1 = require("./p-limit");
6
7
  const cache = {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remotion/media-utils",
3
- "version": "4.0.45",
3
+ "version": "4.0.47",
4
4
  "description": "Utility functions for audio and video",
5
5
  "main": "dist/index.js",
6
6
  "sideEffects": false,
@@ -13,14 +13,14 @@
13
13
  "url": "https://github.com/remotion-dev/remotion/issues"
14
14
  },
15
15
  "dependencies": {
16
- "remotion": "4.0.45"
16
+ "remotion": "4.0.47"
17
17
  },
18
18
  "peerDependencies": {
19
19
  "react": ">=16.8.0",
20
20
  "react-dom": ">=16.8.0"
21
21
  },
22
22
  "devDependencies": {
23
- "@jonny/eslint-config": "3.0.266",
23
+ "@jonny/eslint-config": "3.0.276",
24
24
  "@types/node": "18.14.6",
25
25
  "@types/react": "18.0.26",
26
26
  "eslint": "8.42.0",