@remotion/media-utils 4.0.0-imgloading.2 → 4.0.0-jshmr.0
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.
- package/dist/audio-buffer/audio-buffer-to-wav.d.ts +0 -0
- package/dist/audio-buffer/audio-buffer-to-wav.js +0 -0
- package/dist/audio-buffer/audio-url-helpers.d.ts +4 -0
- package/dist/audio-buffer/audio-url-helpers.js +4 -0
- package/dist/fft/complex.d.ts +0 -0
- package/dist/fft/complex.js +0 -0
- package/dist/fft/exponent.d.ts +0 -0
- package/dist/fft/exponent.js +0 -0
- package/dist/fft/fft-freq.d.ts +1 -4
- package/dist/fft/fft-freq.js +0 -0
- package/dist/fft/fft.d.ts +1 -4
- package/dist/fft/fft.js +0 -0
- package/dist/fft/get-visualization.d.ts +0 -0
- package/dist/fft/get-visualization.js +0 -0
- package/dist/fft/mag.d.ts +1 -4
- package/dist/fft/mag.js +0 -0
- package/dist/fft/max-value-cached.d.ts +1 -1
- package/dist/fft/max-value-cached.js +0 -0
- package/dist/fft/smoothing.d.ts +0 -0
- package/dist/fft/smoothing.js +0 -0
- package/dist/fft/to-int-16.d.ts +0 -0
- package/dist/fft/to-int-16.js +0 -0
- package/dist/get-audio-data.d.ts +5 -1
- package/dist/get-audio-data.js +11 -1
- package/dist/{get-audio-duration.d.ts → get-audio-duration-in-seconds.d.ts} +2 -1
- package/dist/{get-audio-duration.js → get-audio-duration-in-seconds.js} +5 -1
- package/dist/get-video-metadata.d.ts +5 -1
- package/dist/get-video-metadata.js +12 -0
- package/dist/get-wave-form-samples.d.ts +0 -0
- package/dist/get-wave-form-samples.js +0 -0
- package/dist/get-waveform-portion.d.ts +5 -1
- package/dist/get-waveform-portion.js +4 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +8 -4
- package/dist/is-remote-asset.d.ts +0 -0
- package/dist/is-remote-asset.js +0 -0
- package/dist/p-limit.d.ts +0 -0
- package/dist/p-limit.js +0 -0
- package/dist/types.d.ts +0 -0
- package/dist/types.js +0 -0
- package/dist/use-audio-data.d.ts +8 -1
- package/dist/use-audio-data.js +7 -0
- package/dist/visualize-audio.d.ts +1 -1
- package/dist/visualize-audio.js +6 -1
- package/package.json +8 -9
- package/.prettierrc.js +0 -14
- package/tsconfig.json +0 -10
|
File without changes
|
|
File without changes
|
|
@@ -1 +1,5 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description This API takes an AudioBuffer instance and converts it to a Base 64 Data URL so it can be passed to an <Audio /> tag.
|
|
3
|
+
* @see [Documentation](https://www.remotion.dev/docs/audio-buffer-to-data-url)
|
|
4
|
+
*/
|
|
1
5
|
export declare const audioBufferToDataUrl: (buffer: AudioBuffer) => string;
|
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.audioBufferToDataUrl = void 0;
|
|
4
4
|
const audio_buffer_to_wav_1 = require("./audio-buffer-to-wav");
|
|
5
|
+
/**
|
|
6
|
+
* @description This API takes an AudioBuffer instance and converts it to a Base 64 Data URL so it can be passed to an <Audio /> tag.
|
|
7
|
+
* @see [Documentation](https://www.remotion.dev/docs/audio-buffer-to-data-url)
|
|
8
|
+
*/
|
|
5
9
|
const audioBufferToDataUrl = (buffer) => {
|
|
6
10
|
const wavAsArrayBuffer = (0, audio_buffer_to_wav_1.audioBufferToWav)(buffer, {
|
|
7
11
|
float32: true,
|
package/dist/fft/complex.d.ts
CHANGED
|
File without changes
|
package/dist/fft/complex.js
CHANGED
|
File without changes
|
package/dist/fft/exponent.d.ts
CHANGED
|
File without changes
|
package/dist/fft/exponent.js
CHANGED
|
File without changes
|
package/dist/fft/fft-freq.d.ts
CHANGED
package/dist/fft/fft-freq.js
CHANGED
|
File without changes
|
package/dist/fft/fft.d.ts
CHANGED
package/dist/fft/fft.js
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/dist/fft/mag.d.ts
CHANGED
package/dist/fft/mag.js
CHANGED
|
File without changes
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { AudioData } from '
|
|
1
|
+
import type { AudioData } from '../types';
|
|
2
2
|
export declare const getMaxPossibleMagnitude: (metadata: AudioData) => number;
|
|
File without changes
|
package/dist/fft/smoothing.d.ts
CHANGED
|
File without changes
|
package/dist/fft/smoothing.js
CHANGED
|
File without changes
|
package/dist/fft/to-int-16.d.ts
CHANGED
|
File without changes
|
package/dist/fft/to-int-16.js
CHANGED
|
File without changes
|
package/dist/get-audio-data.d.ts
CHANGED
|
@@ -1,2 +1,6 @@
|
|
|
1
|
-
import { AudioData } from './types';
|
|
1
|
+
import type { AudioData } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* @description Takes an audio src, loads it and returns data and metadata for the specified source.
|
|
4
|
+
* @see [Documentation](https://www.remotion.dev/docs/get-audio-data)
|
|
5
|
+
*/
|
|
2
6
|
export declare const getAudioData: (src: string) => Promise<AudioData>;
|
package/dist/get-audio-data.js
CHANGED
|
@@ -7,7 +7,10 @@ const metadataCache = {};
|
|
|
7
7
|
const limit = (0, p_limit_1.pLimit)(3);
|
|
8
8
|
const fetchWithCorsCatch = async (src) => {
|
|
9
9
|
try {
|
|
10
|
-
const response = await fetch(src
|
|
10
|
+
const response = await fetch(src, {
|
|
11
|
+
mode: 'cors',
|
|
12
|
+
referrerPolicy: 'no-referrer-when-downgrade',
|
|
13
|
+
});
|
|
11
14
|
return response;
|
|
12
15
|
}
|
|
13
16
|
catch (err) {
|
|
@@ -28,6 +31,9 @@ const fn = async (src) => {
|
|
|
28
31
|
if (metadataCache[src]) {
|
|
29
32
|
return metadataCache[src];
|
|
30
33
|
}
|
|
34
|
+
if (typeof document === 'undefined') {
|
|
35
|
+
throw new Error('getAudioData() is only available in the browser.');
|
|
36
|
+
}
|
|
31
37
|
const audioContext = new AudioContext();
|
|
32
38
|
const response = await fetchWithCorsCatch(src);
|
|
33
39
|
const arrayBuffer = await response.arrayBuffer();
|
|
@@ -48,6 +54,10 @@ const fn = async (src) => {
|
|
|
48
54
|
metadataCache[src] = metadata;
|
|
49
55
|
return metadata;
|
|
50
56
|
};
|
|
57
|
+
/**
|
|
58
|
+
* @description Takes an audio src, loads it and returns data and metadata for the specified source.
|
|
59
|
+
* @see [Documentation](https://www.remotion.dev/docs/get-audio-data)
|
|
60
|
+
*/
|
|
51
61
|
const getAudioData = (src) => {
|
|
52
62
|
return limit(fn, src);
|
|
53
63
|
};
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Get the audio file passed in parameter duration in seconds
|
|
2
|
+
* @default Get the audio file passed in parameter duration in seconds
|
|
3
3
|
* @async
|
|
4
4
|
* @param src path to the audio file
|
|
5
5
|
* @return {number} duration of the audio file in seconds
|
|
6
|
+
* @see [Documentation](https://www.remotion.dev/docs/get-audio-duration-in-seconds)
|
|
6
7
|
*/
|
|
7
8
|
export declare const getAudioDurationInSeconds: (src: string) => Promise<number>;
|
|
8
9
|
/**
|
|
@@ -8,6 +8,9 @@ const fn = (src) => {
|
|
|
8
8
|
if (metadataCache[src]) {
|
|
9
9
|
return Promise.resolve(metadataCache[src]);
|
|
10
10
|
}
|
|
11
|
+
if (typeof document === 'undefined') {
|
|
12
|
+
throw new Error('getAudioDuration() is only available in the browser.');
|
|
13
|
+
}
|
|
11
14
|
const audio = document.createElement('audio');
|
|
12
15
|
audio.src = src;
|
|
13
16
|
return new Promise((resolve, reject) => {
|
|
@@ -30,10 +33,11 @@ const fn = (src) => {
|
|
|
30
33
|
});
|
|
31
34
|
};
|
|
32
35
|
/**
|
|
33
|
-
* Get the audio file passed in parameter duration in seconds
|
|
36
|
+
* @default Get the audio file passed in parameter duration in seconds
|
|
34
37
|
* @async
|
|
35
38
|
* @param src path to the audio file
|
|
36
39
|
* @return {number} duration of the audio file in seconds
|
|
40
|
+
* @see [Documentation](https://www.remotion.dev/docs/get-audio-duration-in-seconds)
|
|
37
41
|
*/
|
|
38
42
|
const getAudioDurationInSeconds = (src) => {
|
|
39
43
|
return limit(fn, src);
|
|
@@ -1,2 +1,6 @@
|
|
|
1
|
-
import { VideoMetadata } from './types';
|
|
1
|
+
import type { VideoMetadata } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* @description Takes a src to a video, loads it and returns metadata for the specified source.
|
|
4
|
+
* @see [Documentation](https://www.remotion.dev/docs/get-video-metadata)
|
|
5
|
+
*/
|
|
2
6
|
export declare const getVideoMetadata: (src: string) => Promise<VideoMetadata>;
|
|
@@ -9,6 +9,9 @@ const fn = (src) => {
|
|
|
9
9
|
if (cache[src]) {
|
|
10
10
|
return Promise.resolve(cache[src]);
|
|
11
11
|
}
|
|
12
|
+
if (typeof document === 'undefined') {
|
|
13
|
+
throw new Error('getVideoMetadata() is only available in the browser.');
|
|
14
|
+
}
|
|
12
15
|
const video = document.createElement('video');
|
|
13
16
|
video.src = src;
|
|
14
17
|
return new Promise((resolve, reject) => {
|
|
@@ -17,6 +20,11 @@ const fn = (src) => {
|
|
|
17
20
|
cleanup();
|
|
18
21
|
};
|
|
19
22
|
const onLoadedMetadata = () => {
|
|
23
|
+
const pixels = video.videoHeight * video.videoWidth;
|
|
24
|
+
if (pixels === 0) {
|
|
25
|
+
reject(new Error('Unable to determine video metadata'));
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
20
28
|
const metadata = {
|
|
21
29
|
durationInSeconds: video.duration,
|
|
22
30
|
width: video.videoWidth,
|
|
@@ -37,6 +45,10 @@ const fn = (src) => {
|
|
|
37
45
|
video.addEventListener('error', onError, { once: true });
|
|
38
46
|
});
|
|
39
47
|
};
|
|
48
|
+
/**
|
|
49
|
+
* @description Takes a src to a video, loads it and returns metadata for the specified source.
|
|
50
|
+
* @see [Documentation](https://www.remotion.dev/docs/get-video-metadata)
|
|
51
|
+
*/
|
|
40
52
|
const getVideoMetadata = (src) => {
|
|
41
53
|
return limit(fn, src);
|
|
42
54
|
};
|
|
File without changes
|
|
File without changes
|
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
import { AudioData } from './types';
|
|
1
|
+
import type { AudioData } from './types';
|
|
2
2
|
declare type Bar = {
|
|
3
3
|
index: number;
|
|
4
4
|
amplitude: number;
|
|
5
5
|
};
|
|
6
|
+
/**
|
|
7
|
+
* @description Takes bulky waveform data (for example fetched by getAudioData()) and returns a trimmed and simplified version of it, for simpler visualization
|
|
8
|
+
* @see [Documentation](https://www.remotion.dev/docs/get-waveform-portion)
|
|
9
|
+
*/
|
|
6
10
|
export declare const getWaveformPortion: ({ audioData, startTimeInSeconds, durationInSeconds, numberOfSamples, }: {
|
|
7
11
|
audioData: AudioData;
|
|
8
12
|
startTimeInSeconds: number;
|
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getWaveformPortion = void 0;
|
|
4
4
|
const get_wave_form_samples_1 = require("./get-wave-form-samples");
|
|
5
|
+
/**
|
|
6
|
+
* @description Takes bulky waveform data (for example fetched by getAudioData()) and returns a trimmed and simplified version of it, for simpler visualization
|
|
7
|
+
* @see [Documentation](https://www.remotion.dev/docs/get-waveform-portion)
|
|
8
|
+
*/
|
|
5
9
|
const getWaveformPortion = ({ audioData, startTimeInSeconds, durationInSeconds, numberOfSamples, }) => {
|
|
6
10
|
const startSample = Math.floor((startTimeInSeconds / audioData.durationInSeconds) *
|
|
7
11
|
audioData.channelWaveforms[0].length);
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { audioBufferToDataUrl } from './audio-buffer/audio-url-helpers';
|
|
2
2
|
export { getAudioData } from './get-audio-data';
|
|
3
|
-
export { getAudioDuration, getAudioDurationInSeconds, } from './get-audio-duration';
|
|
3
|
+
export { getAudioDuration, getAudioDurationInSeconds, } from './get-audio-duration-in-seconds';
|
|
4
4
|
export { getVideoMetadata } from './get-video-metadata';
|
|
5
5
|
export { getWaveformPortion } from './get-waveform-portion';
|
|
6
6
|
export * from './types';
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -15,9 +19,9 @@ var audio_url_helpers_1 = require("./audio-buffer/audio-url-helpers");
|
|
|
15
19
|
Object.defineProperty(exports, "audioBufferToDataUrl", { enumerable: true, get: function () { return audio_url_helpers_1.audioBufferToDataUrl; } });
|
|
16
20
|
var get_audio_data_1 = require("./get-audio-data");
|
|
17
21
|
Object.defineProperty(exports, "getAudioData", { enumerable: true, get: function () { return get_audio_data_1.getAudioData; } });
|
|
18
|
-
var
|
|
19
|
-
Object.defineProperty(exports, "getAudioDuration", { enumerable: true, get: function () { return
|
|
20
|
-
Object.defineProperty(exports, "getAudioDurationInSeconds", { enumerable: true, get: function () { return
|
|
22
|
+
var get_audio_duration_in_seconds_1 = require("./get-audio-duration-in-seconds");
|
|
23
|
+
Object.defineProperty(exports, "getAudioDuration", { enumerable: true, get: function () { return get_audio_duration_in_seconds_1.getAudioDuration; } });
|
|
24
|
+
Object.defineProperty(exports, "getAudioDurationInSeconds", { enumerable: true, get: function () { return get_audio_duration_in_seconds_1.getAudioDurationInSeconds; } });
|
|
21
25
|
var get_video_metadata_1 = require("./get-video-metadata");
|
|
22
26
|
Object.defineProperty(exports, "getVideoMetadata", { enumerable: true, get: function () { return get_video_metadata_1.getVideoMetadata; } });
|
|
23
27
|
var get_waveform_portion_1 = require("./get-waveform-portion");
|
|
File without changes
|
package/dist/is-remote-asset.js
CHANGED
|
File without changes
|
package/dist/p-limit.d.ts
CHANGED
|
File without changes
|
package/dist/p-limit.js
CHANGED
|
File without changes
|
package/dist/types.d.ts
CHANGED
|
File without changes
|
package/dist/types.js
CHANGED
|
File without changes
|
package/dist/use-audio-data.d.ts
CHANGED
|
@@ -1,2 +1,9 @@
|
|
|
1
|
-
import { AudioData } from './types';
|
|
1
|
+
import type { AudioData } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* @description Wraps the getAudioData() function into a hook and does 3 things:
|
|
4
|
+
* @description Keeps the audio data in a state
|
|
5
|
+
* @description Wraps the function in a delayRender() / continueRender() pattern.
|
|
6
|
+
* @description Handles the case where the component gets unmounted while the fetching is in progress and a React error is thrown.
|
|
7
|
+
* @see [Documentation](https://www.remotion.dev/docs/use-audio-data)
|
|
8
|
+
*/
|
|
2
9
|
export declare const useAudioData: (src: string) => AudioData | null;
|
package/dist/use-audio-data.js
CHANGED
|
@@ -4,6 +4,13 @@ exports.useAudioData = void 0;
|
|
|
4
4
|
const react_1 = require("react");
|
|
5
5
|
const remotion_1 = require("remotion");
|
|
6
6
|
const get_audio_data_1 = require("./get-audio-data");
|
|
7
|
+
/**
|
|
8
|
+
* @description Wraps the getAudioData() function into a hook and does 3 things:
|
|
9
|
+
* @description Keeps the audio data in a state
|
|
10
|
+
* @description Wraps the function in a delayRender() / continueRender() pattern.
|
|
11
|
+
* @description Handles the case where the component gets unmounted while the fetching is in progress and a React error is thrown.
|
|
12
|
+
* @see [Documentation](https://www.remotion.dev/docs/use-audio-data)
|
|
13
|
+
*/
|
|
7
14
|
const useAudioData = (src) => {
|
|
8
15
|
if (!src) {
|
|
9
16
|
throw new TypeError("useAudioData requires a 'src' parameter");
|
package/dist/visualize-audio.js
CHANGED
|
@@ -4,6 +4,11 @@ exports.visualizeAudio = void 0;
|
|
|
4
4
|
const get_visualization_1 = require("./fft/get-visualization");
|
|
5
5
|
const max_value_cached_1 = require("./fft/max-value-cached");
|
|
6
6
|
const cache = {};
|
|
7
|
+
/**
|
|
8
|
+
* @description Takes in AudioData (preferably fetched by the useAudioData() hook) and processes it in a way that makes visualizing the audio that is playing at the current frame easy.
|
|
9
|
+
* @description part of @remotion/media-utils
|
|
10
|
+
* @see [Documentation](https://www.remotion.dev/docs/visualize-audio)
|
|
11
|
+
*/
|
|
7
12
|
const visualizeAudioFrame = ({ audioData: metadata, frame, fps, numberOfSamples, }) => {
|
|
8
13
|
const cacheKey = metadata.resultId + frame + fps + numberOfSamples;
|
|
9
14
|
if (cache[cacheKey]) {
|
|
@@ -31,7 +36,7 @@ const visualizeAudio = ({ smoothing = true, ...parameters }) => {
|
|
|
31
36
|
const all = toSmooth.map((s) => {
|
|
32
37
|
return visualizeAudioFrame({ ...parameters, frame: s });
|
|
33
38
|
});
|
|
34
|
-
return new Array(parameters.numberOfSamples).fill(true).map((
|
|
39
|
+
return new Array(parameters.numberOfSamples).fill(true).map((_x, i) => {
|
|
35
40
|
return (new Array(toSmooth.length)
|
|
36
41
|
.fill(true)
|
|
37
42
|
.map((_, j) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@remotion/media-utils",
|
|
3
|
-
"version": "4.0.0-
|
|
3
|
+
"version": "4.0.0-jshmr.0+ea5ee8bd0",
|
|
4
4
|
"description": "Utility functions for audio and video",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -18,31 +18,30 @@
|
|
|
18
18
|
"url": "https://github.com/remotion-dev/remotion/issues"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"remotion": "4.0.0-
|
|
21
|
+
"remotion": "4.0.0-jshmr.0+ea5ee8bd0"
|
|
22
22
|
},
|
|
23
23
|
"peerDependencies": {
|
|
24
24
|
"react": ">=16.8.0",
|
|
25
25
|
"react-dom": ">=16.8.0"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"@jonny/eslint-config": "3.0.
|
|
28
|
+
"@jonny/eslint-config": "3.0.266",
|
|
29
29
|
"@types/node": "^16.7.5",
|
|
30
|
-
"@types/react": "18.0.
|
|
31
|
-
"eslint": "8.
|
|
32
|
-
"prettier": "^2.
|
|
30
|
+
"@types/react": "18.0.26",
|
|
31
|
+
"eslint": "8.25.0",
|
|
32
|
+
"prettier": "^2.7.1",
|
|
33
33
|
"prettier-plugin-organize-imports": "^2.3.4",
|
|
34
|
-
"typescript": "^4.
|
|
34
|
+
"typescript": "^4.7.0"
|
|
35
35
|
},
|
|
36
36
|
"keywords": [
|
|
37
37
|
"remotion",
|
|
38
38
|
"ffmpeg",
|
|
39
39
|
"video",
|
|
40
40
|
"react",
|
|
41
|
-
"puppeteer",
|
|
42
41
|
"player"
|
|
43
42
|
],
|
|
44
43
|
"publishConfig": {
|
|
45
44
|
"access": "public"
|
|
46
45
|
},
|
|
47
|
-
"gitHead": "
|
|
46
|
+
"gitHead": "ea5ee8bd0ff58192af7a14847a996e0366600fd5"
|
|
48
47
|
}
|
package/.prettierrc.js
DELETED