@remotion/media-utils 4.0.0-fastlambda.8 → 4.0.0-lambda.1
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/get-audio-data.js +3 -0
- package/dist/get-audio-duration-in-seconds.d.ts +11 -0
- package/dist/get-audio-duration-in-seconds.js +49 -0
- package/dist/get-audio-duration.js +3 -0
- package/dist/get-video-metadata.js +8 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +8 -4
- package/dist/visualize-audio.js +1 -1
- package/package.json +4 -4
package/dist/get-audio-data.js
CHANGED
|
@@ -28,6 +28,9 @@ const fn = async (src) => {
|
|
|
28
28
|
if (metadataCache[src]) {
|
|
29
29
|
return metadataCache[src];
|
|
30
30
|
}
|
|
31
|
+
if (typeof document === 'undefined') {
|
|
32
|
+
throw new Error('getAudioData() is only available in the browser.');
|
|
33
|
+
}
|
|
31
34
|
const audioContext = new AudioContext();
|
|
32
35
|
const response = await fetchWithCorsCatch(src);
|
|
33
36
|
const arrayBuffer = await response.arrayBuffer();
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Get the audio file passed in parameter duration in seconds
|
|
3
|
+
* @async
|
|
4
|
+
* @param src path to the audio file
|
|
5
|
+
* @return {number} duration of the audio file in seconds
|
|
6
|
+
*/
|
|
7
|
+
export declare const getAudioDurationInSeconds: (src: string) => Promise<number>;
|
|
8
|
+
/**
|
|
9
|
+
* @deprecated Renamed to `getAudioDurationInSeconds`
|
|
10
|
+
*/
|
|
11
|
+
export declare const getAudioDuration: (src: string) => Promise<number>;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getAudioDuration = exports.getAudioDurationInSeconds = void 0;
|
|
4
|
+
const p_limit_1 = require("./p-limit");
|
|
5
|
+
const limit = (0, p_limit_1.pLimit)(3);
|
|
6
|
+
const metadataCache = {};
|
|
7
|
+
const fn = (src) => {
|
|
8
|
+
if (metadataCache[src]) {
|
|
9
|
+
return Promise.resolve(metadataCache[src]);
|
|
10
|
+
}
|
|
11
|
+
if (typeof document === 'undefined') {
|
|
12
|
+
throw new Error('getAudioDuration() is only available in the browser.');
|
|
13
|
+
}
|
|
14
|
+
const audio = document.createElement('audio');
|
|
15
|
+
audio.src = src;
|
|
16
|
+
return new Promise((resolve, reject) => {
|
|
17
|
+
const onError = () => {
|
|
18
|
+
reject(audio.error);
|
|
19
|
+
cleanup();
|
|
20
|
+
};
|
|
21
|
+
const onLoadedMetadata = () => {
|
|
22
|
+
metadataCache[src] = audio.duration;
|
|
23
|
+
resolve(audio.duration);
|
|
24
|
+
cleanup();
|
|
25
|
+
};
|
|
26
|
+
const cleanup = () => {
|
|
27
|
+
audio.removeEventListener('loadedmetadata', onLoadedMetadata);
|
|
28
|
+
audio.removeEventListener('error', onError);
|
|
29
|
+
audio.remove();
|
|
30
|
+
};
|
|
31
|
+
audio.addEventListener('loadedmetadata', onLoadedMetadata, { once: true });
|
|
32
|
+
audio.addEventListener('error', onError, { once: true });
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Get the audio file passed in parameter duration in seconds
|
|
37
|
+
* @async
|
|
38
|
+
* @param src path to the audio file
|
|
39
|
+
* @return {number} duration of the audio file in seconds
|
|
40
|
+
*/
|
|
41
|
+
const getAudioDurationInSeconds = (src) => {
|
|
42
|
+
return limit(fn, src);
|
|
43
|
+
};
|
|
44
|
+
exports.getAudioDurationInSeconds = getAudioDurationInSeconds;
|
|
45
|
+
/**
|
|
46
|
+
* @deprecated Renamed to `getAudioDurationInSeconds`
|
|
47
|
+
*/
|
|
48
|
+
const getAudioDuration = (src) => (0, exports.getAudioDurationInSeconds)(src);
|
|
49
|
+
exports.getAudioDuration = getAudioDuration;
|
|
@@ -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) => {
|
|
@@ -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,
|
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");
|
package/dist/visualize-audio.js
CHANGED
|
@@ -31,7 +31,7 @@ const visualizeAudio = ({ smoothing = true, ...parameters }) => {
|
|
|
31
31
|
const all = toSmooth.map((s) => {
|
|
32
32
|
return visualizeAudioFrame({ ...parameters, frame: s });
|
|
33
33
|
});
|
|
34
|
-
return new Array(parameters.numberOfSamples).fill(true).map((
|
|
34
|
+
return new Array(parameters.numberOfSamples).fill(true).map((_x, i) => {
|
|
35
35
|
return (new Array(toSmooth.length)
|
|
36
36
|
.fill(true)
|
|
37
37
|
.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-lambda.1+5a0913230",
|
|
4
4
|
"description": "Utility functions for audio and video",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -18,7 +18,7 @@
|
|
|
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-lambda.1+5a0913230"
|
|
22
22
|
},
|
|
23
23
|
"peerDependencies": {
|
|
24
24
|
"react": ">=16.8.0",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"eslint": "8.13.0",
|
|
32
32
|
"prettier": "^2.0.5",
|
|
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",
|
|
@@ -44,5 +44,5 @@
|
|
|
44
44
|
"publishConfig": {
|
|
45
45
|
"access": "public"
|
|
46
46
|
},
|
|
47
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "5a091323018b016b7c05adcd4d3d2a5c9df292a8"
|
|
48
48
|
}
|