@remotion/media-utils 4.0.250 → 4.0.252

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,2 +1,7 @@
1
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://remotion.dev/docs/get-video-metadata)
5
+ * @deprecated Use `parseMedia()` instead: https://www.remotion.dev/docs/miscellaneous/parse-media-vs-get-video-metadata
6
+ */
2
7
  export declare const getVideoMetadata: (src: string) => Promise<VideoMetadata>;
@@ -56,9 +56,10 @@ const fn = (src) => {
56
56
  video.addEventListener('error', onError, { once: true });
57
57
  });
58
58
  };
59
- /*
59
+ /**
60
60
  * @description Takes a src to a video, loads it and returns metadata for the specified source.
61
61
  * @see [Documentation](https://remotion.dev/docs/get-video-metadata)
62
+ * @deprecated Use `parseMedia()` instead: https://www.remotion.dev/docs/miscellaneous/parse-media-vs-get-video-metadata
62
63
  */
63
64
  const getVideoMetadata = (src) => {
64
65
  return limit(fn, src);
@@ -52,7 +52,7 @@ const onMediaError = ({ error, src, reject, cleanup, api, }) => {
52
52
  'Correct the URL of the file.',
53
53
  ].join(' '))
54
54
  : new Error([
55
- `Failed to execute ${api}, Received a MediaError loading "${src}".`,
55
+ `Failed to execute ${api}, Received a MediaError loading "${src}". Consider using parseMedia() instead which supports more codecs: https://www.remotion.dev/docs/miscellaneous/parse-media-vs-get-video-metadata`,
56
56
  status === null
57
57
  ? null
58
58
  : `HTTP Status code of the file: ${status}.`,
@@ -22,8 +22,12 @@ const useWindowedAudioData = ({ src, frame, fps, windowInSeconds, channelIndex =
22
22
  isMounted.current = false;
23
23
  };
24
24
  }, []);
25
- const fetchMetadata = (0, react_1.useCallback)(async () => {
25
+ const fetchMetadata = (0, react_1.useCallback)(async (signal) => {
26
26
  const handle = (0, remotion_1.delayRender)(`Waiting for audio metadata with src="${src}" to be loaded`);
27
+ const cont = () => {
28
+ (0, remotion_1.continueRender)(handle);
29
+ };
30
+ signal.addEventListener('abort', cont, { once: true });
27
31
  try {
28
32
  const data = await (0, probe_wave_file_1.probeWaveFile)(src);
29
33
  if (isMounted.current) {
@@ -34,9 +38,16 @@ const useWindowedAudioData = ({ src, frame, fps, windowInSeconds, channelIndex =
34
38
  catch (err) {
35
39
  (0, remotion_1.cancelRender)(err);
36
40
  }
41
+ finally {
42
+ signal.removeEventListener('abort', cont);
43
+ }
37
44
  }, [src]);
38
45
  (0, react_1.useLayoutEffect)(() => {
39
- fetchMetadata();
46
+ const controller = new AbortController();
47
+ fetchMetadata(controller.signal);
48
+ return () => {
49
+ controller.abort();
50
+ };
40
51
  }, [fetchMetadata]);
41
52
  const currentTime = frame / fps;
42
53
  const currentWindowIndex = Math.floor(currentTime / windowInSeconds);
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.250",
6
+ "version": "4.0.252",
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.250"
16
+ "remotion": "4.0.252"
17
17
  },
18
18
  "peerDependencies": {
19
19
  "react": ">=16.8.0",
@@ -21,7 +21,7 @@
21
21
  },
22
22
  "devDependencies": {
23
23
  "eslint": "9.14.0",
24
- "@remotion/eslint-config-internal": "4.0.250"
24
+ "@remotion/eslint-config-internal": "4.0.252"
25
25
  },
26
26
  "keywords": [
27
27
  "remotion",