@remotion/media-utils 4.0.142 → 4.0.144

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,4 +1 @@
1
- export declare const fftAccurate: (vector: Int16Array) => [
2
- number,
3
- number
4
- ][];
1
+ export declare const fftAccurate: (vector: Int16Array) => [number, number][];
@@ -1,4 +1 @@
1
- export declare const fftFast: (vector: Int16Array) => [
2
- number,
3
- number
4
- ][];
1
+ export declare const fftFast: (vector: Int16Array) => [number, number][];
@@ -1,4 +1 @@
1
- export declare const fftFreq: (fftBins: [
2
- number,
3
- number
4
- ][], sampleRate: number) => number[];
1
+ export declare const fftFreq: (fftBins: [number, number][], sampleRate: number) => number[];
package/dist/fft/mag.d.ts CHANGED
@@ -1,4 +1 @@
1
- export declare const fftMag: (fftBins: [
2
- number,
3
- number
4
- ][]) => number[];
1
+ export declare const fftMag: (fftBins: [number, number][]) => number[];
@@ -0,0 +1,6 @@
1
+ import type { ImageDimensions } from './types';
2
+ /**
3
+ * @description Takes an image src, retrieves the dimensions of an image.
4
+ * @see [Documentation](https://www.remotion.dev/docs/get-image-dimensions)
5
+ */
6
+ export declare function getImageDimensions(src: string): Promise<ImageDimensions>;
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getImageDimensions = void 0;
4
+ const p_limit_1 = require("./p-limit");
5
+ const imageDimensionsCache = {};
6
+ const limit = (0, p_limit_1.pLimit)(3);
7
+ const fn = async (src) => {
8
+ if (imageDimensionsCache[src]) {
9
+ return imageDimensionsCache[src];
10
+ }
11
+ if (typeof document === 'undefined') {
12
+ throw new Error('getImageDimensions() is only available in the browser.');
13
+ }
14
+ const imageDimensions = await new Promise((resolved, reject) => {
15
+ const image = new Image();
16
+ image.onload = () => {
17
+ const { width, height } = image;
18
+ resolved({ width, height });
19
+ };
20
+ image.onerror = reject;
21
+ image.src = src;
22
+ });
23
+ imageDimensionsCache[src] = imageDimensions;
24
+ return imageDimensions;
25
+ };
26
+ /**
27
+ * @description Takes an image src, retrieves the dimensions of an image.
28
+ * @see [Documentation](https://www.remotion.dev/docs/get-image-dimensions)
29
+ */
30
+ function getImageDimensions(src) {
31
+ return limit(fn, src);
32
+ }
33
+ exports.getImageDimensions = getImageDimensions;
@@ -23,7 +23,7 @@ const fn = (src) => {
23
23
  const onLoadedMetadata = () => {
24
24
  const pixels = video.videoHeight * video.videoWidth;
25
25
  if (pixels === 0) {
26
- reject(new Error('Unable to determine video metadata'));
26
+ reject(new Error(`Unable to determine video metadata for ${src}`));
27
27
  return;
28
28
  }
29
29
  const metadata = {
package/dist/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  export { audioBufferToDataUrl } from './audio-buffer/audio-url-helpers';
2
2
  export { getAudioData } from './get-audio-data';
3
3
  export { getAudioDuration, getAudioDurationInSeconds, } from './get-audio-duration-in-seconds';
4
+ export { getImageDimensions } from './get-image-dimensions';
4
5
  export { getVideoMetadata } from './get-video-metadata';
5
6
  export { getWaveformPortion } from './get-waveform-portion';
6
7
  export * from './types';
package/dist/index.js CHANGED
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.visualizeAudio = exports.useAudioData = exports.getWaveformPortion = exports.getVideoMetadata = exports.getAudioDurationInSeconds = exports.getAudioDuration = exports.getAudioData = exports.audioBufferToDataUrl = void 0;
17
+ exports.visualizeAudio = exports.useAudioData = exports.getWaveformPortion = exports.getVideoMetadata = exports.getImageDimensions = exports.getAudioDurationInSeconds = exports.getAudioDuration = exports.getAudioData = exports.audioBufferToDataUrl = void 0;
18
18
  var audio_url_helpers_1 = require("./audio-buffer/audio-url-helpers");
19
19
  Object.defineProperty(exports, "audioBufferToDataUrl", { enumerable: true, get: function () { return audio_url_helpers_1.audioBufferToDataUrl; } });
20
20
  var get_audio_data_1 = require("./get-audio-data");
@@ -22,6 +22,8 @@ Object.defineProperty(exports, "getAudioData", { enumerable: true, get: function
22
22
  var get_audio_duration_in_seconds_1 = require("./get-audio-duration-in-seconds");
23
23
  Object.defineProperty(exports, "getAudioDuration", { enumerable: true, get: function () { return get_audio_duration_in_seconds_1.getAudioDuration; } });
24
24
  Object.defineProperty(exports, "getAudioDurationInSeconds", { enumerable: true, get: function () { return get_audio_duration_in_seconds_1.getAudioDurationInSeconds; } });
25
+ var get_image_dimensions_1 = require("./get-image-dimensions");
26
+ Object.defineProperty(exports, "getImageDimensions", { enumerable: true, get: function () { return get_image_dimensions_1.getImageDimensions; } });
25
27
  var get_video_metadata_1 = require("./get-video-metadata");
26
28
  Object.defineProperty(exports, "getVideoMetadata", { enumerable: true, get: function () { return get_video_metadata_1.getVideoMetadata; } });
27
29
  var get_waveform_portion_1 = require("./get-waveform-portion");
package/dist/types.d.ts CHANGED
@@ -13,3 +13,7 @@ export type VideoMetadata = {
13
13
  aspectRatio: number;
14
14
  isRemote: boolean;
15
15
  };
16
+ export type ImageDimensions = {
17
+ width: number;
18
+ height: number;
19
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remotion/media-utils",
3
- "version": "4.0.142",
3
+ "version": "4.0.144",
4
4
  "description": "Utility functions for audio and video",
5
5
  "main": "dist/index.js",
6
6
  "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.142"
16
+ "remotion": "4.0.144"
17
17
  },
18
18
  "peerDependencies": {
19
19
  "react": ">=16.8.0",