@remotion/media-utils 4.0.267 → 4.0.269
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.
|
@@ -11,6 +11,7 @@ export type GetWaveformPortion = {
|
|
|
11
11
|
numberOfSamples: number;
|
|
12
12
|
channel?: number;
|
|
13
13
|
outputRange?: SampleOutputRange;
|
|
14
|
+
dataOffsetInSeconds?: number;
|
|
14
15
|
};
|
|
15
|
-
export declare const getWaveformPortion: ({ audioData, startTimeInSeconds, durationInSeconds, numberOfSamples, channel, outputRange, }: GetWaveformPortion) => Bar[];
|
|
16
|
+
export declare const getWaveformPortion: ({ audioData, startTimeInSeconds, durationInSeconds, numberOfSamples, channel, outputRange, dataOffsetInSeconds, }: GetWaveformPortion) => Bar[];
|
|
16
17
|
export { Bar };
|
|
@@ -21,12 +21,12 @@ const concatArrays = (arrays) => {
|
|
|
21
21
|
* @description Takes bulky waveform data (for example fetched by getAudioData()) and returns a trimmed and simplified version of it, for simpler visualization
|
|
22
22
|
* @see [Documentation](https://remotion.dev/docs/get-waveform-portion)
|
|
23
23
|
*/
|
|
24
|
-
const getWaveformPortion = ({ audioData, startTimeInSeconds, durationInSeconds, numberOfSamples, channel = 0, outputRange = 'zero-to-one', }) => {
|
|
24
|
+
const getWaveformPortion = ({ audioData, startTimeInSeconds, durationInSeconds, numberOfSamples, channel = 0, outputRange = 'zero-to-one', dataOffsetInSeconds, }) => {
|
|
25
25
|
(0, validate_channel_1.validateChannel)(channel, audioData.numberOfChannels);
|
|
26
26
|
const waveform = audioData.channelWaveforms[channel];
|
|
27
|
-
const startSample = Math.floor((startTimeInSeconds
|
|
28
|
-
const endSample = Math.floor((
|
|
29
|
-
|
|
27
|
+
const startSample = Math.floor((startTimeInSeconds - (dataOffsetInSeconds !== null && dataOffsetInSeconds !== void 0 ? dataOffsetInSeconds : 0)) * audioData.sampleRate);
|
|
28
|
+
const endSample = Math.floor((startTimeInSeconds - (dataOffsetInSeconds !== null && dataOffsetInSeconds !== void 0 ? dataOffsetInSeconds : 0) + durationInSeconds) *
|
|
29
|
+
audioData.sampleRate);
|
|
30
30
|
const samplesBeforeStart = 0 - startSample;
|
|
31
31
|
const samplesAfterEnd = endSample - waveform.length;
|
|
32
32
|
const clampedStart = Math.max(startSample, 0);
|
|
@@ -6,5 +6,6 @@ export type VisualizeAudioWaveformOptions = {
|
|
|
6
6
|
windowInSeconds: number;
|
|
7
7
|
numberOfSamples: number;
|
|
8
8
|
channel?: number;
|
|
9
|
+
dataOffsetInSeconds?: number;
|
|
9
10
|
};
|
|
10
|
-
export declare const visualizeAudioWaveform: (
|
|
11
|
+
export declare const visualizeAudioWaveform: (parameters: VisualizeAudioWaveformOptions) => number[];
|
|
@@ -3,14 +3,19 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.visualizeAudioWaveform = void 0;
|
|
4
4
|
const get_waveform_portion_1 = require("./get-waveform-portion");
|
|
5
5
|
const cache = {};
|
|
6
|
-
const visualizeAudioWaveformFrame = ({ audioData, frame, fps, numberOfSamples, windowInSeconds, channel, }) => {
|
|
6
|
+
const visualizeAudioWaveformFrame = ({ audioData, frame, fps, numberOfSamples, windowInSeconds, channel, dataOffsetInSeconds, }) => {
|
|
7
7
|
if (windowInSeconds * audioData.sampleRate < numberOfSamples) {
|
|
8
8
|
throw new TypeError(windowInSeconds +
|
|
9
9
|
's audiodata does not have ' +
|
|
10
10
|
numberOfSamples +
|
|
11
11
|
' bars. Increase windowInSeconds or decrease numberOfSamples');
|
|
12
12
|
}
|
|
13
|
-
const cacheKey = audioData.resultId +
|
|
13
|
+
const cacheKey = audioData.resultId +
|
|
14
|
+
frame +
|
|
15
|
+
fps +
|
|
16
|
+
numberOfSamples +
|
|
17
|
+
'waveform' +
|
|
18
|
+
dataOffsetInSeconds;
|
|
14
19
|
if (cache[cacheKey]) {
|
|
15
20
|
return cache[cacheKey];
|
|
16
21
|
}
|
|
@@ -23,9 +28,10 @@ const visualizeAudioWaveformFrame = ({ audioData, frame, fps, numberOfSamples, w
|
|
|
23
28
|
numberOfSamples,
|
|
24
29
|
outputRange: 'minus-one-to-one',
|
|
25
30
|
channel,
|
|
31
|
+
dataOffsetInSeconds,
|
|
26
32
|
});
|
|
27
33
|
};
|
|
28
|
-
const visualizeAudioWaveform = (
|
|
34
|
+
const visualizeAudioWaveform = (parameters) => {
|
|
29
35
|
const data = visualizeAudioWaveformFrame(parameters);
|
|
30
36
|
return data.map((value) => value.amplitude);
|
|
31
37
|
};
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"url": "https://github.com/remotion-dev/remotion/tree/main/packages/media-utils"
|
|
4
4
|
},
|
|
5
5
|
"name": "@remotion/media-utils",
|
|
6
|
-
"version": "4.0.
|
|
6
|
+
"version": "4.0.269",
|
|
7
7
|
"description": "Utilities for working with media files",
|
|
8
8
|
"main": "dist/index.js",
|
|
9
9
|
"sideEffects": false,
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"url": "https://github.com/remotion-dev/remotion/issues"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"remotion": "4.0.
|
|
16
|
+
"remotion": "4.0.269"
|
|
17
17
|
},
|
|
18
18
|
"peerDependencies": {
|
|
19
19
|
"react": ">=16.8.0",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
23
|
"eslint": "9.19.0",
|
|
24
|
-
"@remotion/eslint-config-internal": "4.0.
|
|
24
|
+
"@remotion/eslint-config-internal": "4.0.269"
|
|
25
25
|
},
|
|
26
26
|
"keywords": [
|
|
27
27
|
"remotion",
|