@remotion/studio 4.0.365 → 4.0.366

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.
@@ -189,7 +189,7 @@ var renderContent = (Root) => {
189
189
  renderToDOM(/* @__PURE__ */ jsx("div", {
190
190
  children: /* @__PURE__ */ jsx(DelayedSpinner, {})
191
191
  }));
192
- import("./chunk-ha1wm1xf.js").then(({ StudioInternals }) => {
192
+ import("./chunk-knnc4kgj.js").then(({ StudioInternals }) => {
193
193
  window.remotion_isStudio = true;
194
194
  window.remotion_isReadOnlyStudio = true;
195
195
  Internals.enableSequenceStackTraces();
@@ -0,0 +1,17 @@
1
+ type Options = {
2
+ track: {
3
+ width: number;
4
+ height: number;
5
+ };
6
+ container: string;
7
+ durationInSeconds: number | null;
8
+ };
9
+ export type ExtractFramesTimestampsInSecondsFn = (options: Options) => Promise<number[]> | number[];
10
+ export type ExtractFramesProps = {
11
+ src: string;
12
+ timestampsInSeconds: number[] | ExtractFramesTimestampsInSecondsFn;
13
+ onFrame: (frame: VideoFrame) => void;
14
+ signal?: AbortSignal;
15
+ };
16
+ export declare function extractFrames({ src, timestampsInSeconds, onFrame, signal, }: ExtractFramesProps): Promise<void>;
17
+ export {};
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.extractFrames = extractFrames;
4
+ const mediabunny_1 = require("mediabunny");
5
+ async function extractFrames({ src, timestampsInSeconds, onFrame, signal, }) {
6
+ const input = new mediabunny_1.Input({
7
+ formats: mediabunny_1.ALL_FORMATS,
8
+ source: new mediabunny_1.UrlSource(src),
9
+ });
10
+ const dispose = () => {
11
+ input.dispose();
12
+ };
13
+ if (signal) {
14
+ signal.addEventListener('abort', dispose, { once: true });
15
+ }
16
+ try {
17
+ const [durationInSeconds, format, videoTrack] = await Promise.all([
18
+ input.computeDuration(),
19
+ input.getFormat(),
20
+ input.getPrimaryVideoTrack(),
21
+ ]);
22
+ if (!videoTrack) {
23
+ throw new Error('No video track found in the input');
24
+ }
25
+ const timestamps = typeof timestampsInSeconds === 'function'
26
+ ? await timestampsInSeconds({
27
+ track: {
28
+ width: videoTrack.displayWidth,
29
+ height: videoTrack.displayHeight,
30
+ },
31
+ container: format.name,
32
+ durationInSeconds,
33
+ })
34
+ : timestampsInSeconds;
35
+ if (timestamps.length === 0) {
36
+ return;
37
+ }
38
+ const sink = new mediabunny_1.VideoSampleSink(videoTrack);
39
+ for await (const videoSample of sink.samplesAtTimestamps(timestamps)) {
40
+ if (signal === null || signal === void 0 ? void 0 : signal.aborted) {
41
+ break;
42
+ }
43
+ if (!videoSample) {
44
+ continue;
45
+ }
46
+ const videoFrame = videoSample.toVideoFrame();
47
+ onFrame(videoFrame);
48
+ }
49
+ }
50
+ catch (error) {
51
+ if (error instanceof mediabunny_1.InputDisposedError) {
52
+ return;
53
+ }
54
+ throw error;
55
+ }
56
+ finally {
57
+ dispose();
58
+ if (signal) {
59
+ signal.removeEventListener('abort', dispose);
60
+ }
61
+ }
62
+ }
@@ -0,0 +1,4 @@
1
+ export declare const resizeVideoFrame: ({ frame, scale, }: {
2
+ frame: VideoFrame;
3
+ scale: number;
4
+ }) => VideoFrame;
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.resizeVideoFrame = void 0;
4
+ const calculateNewDimensionsFromScale = ({ width, height, scale, }) => {
5
+ const scaledWidth = Math.round(width * scale);
6
+ const scaledHeight = Math.round(height * scale);
7
+ return {
8
+ width: scaledWidth,
9
+ height: scaledHeight,
10
+ };
11
+ };
12
+ const resizeVideoFrame = ({ frame, scale, }) => {
13
+ var _a;
14
+ // No resize, no rotation
15
+ if (scale === 1) {
16
+ return frame;
17
+ }
18
+ const { width, height } = calculateNewDimensionsFromScale({
19
+ height: frame.displayHeight,
20
+ width: frame.displayWidth,
21
+ scale,
22
+ });
23
+ const canvas = new OffscreenCanvas(width, height);
24
+ const ctx = canvas.getContext('2d');
25
+ if (!ctx) {
26
+ throw new Error('Could not get 2d context');
27
+ }
28
+ canvas.width = width;
29
+ canvas.height = height;
30
+ ctx.scale(scale, scale);
31
+ ctx.drawImage(frame, 0, 0);
32
+ return new VideoFrame(canvas, {
33
+ displayHeight: height,
34
+ displayWidth: width,
35
+ duration: (_a = frame.duration) !== null && _a !== void 0 ? _a : undefined,
36
+ timestamp: frame.timestamp,
37
+ });
38
+ };
39
+ exports.resizeVideoFrame = resizeVideoFrame;
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useMaxMediaDuration = void 0;
4
- const media_parser_1 = require("@remotion/media-parser");
5
4
  const media_utils_1 = require("@remotion/media-utils");
5
+ const mediabunny_1 = require("mediabunny");
6
6
  const react_1 = require("react");
7
7
  const cache = new Map();
8
8
  const getSrc = (s) => {
@@ -22,18 +22,18 @@ const useMaxMediaDuration = (s, fps) => {
22
22
  if (!src) {
23
23
  return;
24
24
  }
25
- const controller = (0, media_parser_1.mediaParserController)();
26
- (0, media_parser_1.parseMedia)({
27
- src,
28
- controller,
29
- acknowledgeRemotionLicense: true,
30
- onDurationInSeconds: (duration) => {
31
- const durationOrInfinity = duration !== null && duration !== void 0 ? duration : Infinity;
32
- cache.set(src, Math.floor(durationOrInfinity * fps));
33
- setMaxMediaDuration(Math.floor(durationOrInfinity * fps));
34
- },
35
- }).catch((e) => {
36
- if ((0, media_parser_1.hasBeenAborted)(e)) {
25
+ const input = new mediabunny_1.Input({
26
+ formats: mediabunny_1.ALL_FORMATS,
27
+ source: new mediabunny_1.UrlSource(src),
28
+ });
29
+ input
30
+ .computeDuration()
31
+ .then((duration) => {
32
+ cache.set(src, Math.floor(duration * fps));
33
+ setMaxMediaDuration(Math.floor(duration * fps));
34
+ })
35
+ .catch((e) => {
36
+ if (e instanceof mediabunny_1.InputDisposedError) {
37
37
  return;
38
38
  }
39
39
  // In case of CORS errors, fall back to getVideoMetadata
@@ -49,10 +49,7 @@ const useMaxMediaDuration = (s, fps) => {
49
49
  });
50
50
  });
51
51
  return () => {
52
- try {
53
- controller.abort();
54
- }
55
- catch (_a) { }
52
+ input.dispose();
56
53
  };
57
54
  }, [src, fps]);
58
55
  return maxMediaDuration;
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "url": "https://github.com/remotion-dev/remotion/tree/main/packages/studio"
4
4
  },
5
5
  "name": "@remotion/studio",
6
- "version": "4.0.365",
6
+ "version": "4.0.366",
7
7
  "description": "APIs for interacting with the Remotion Studio",
8
8
  "main": "dist",
9
9
  "sideEffects": false,
@@ -25,15 +25,14 @@
25
25
  },
26
26
  "dependencies": {
27
27
  "semver": "7.5.3",
28
- "remotion": "4.0.365",
29
- "@remotion/player": "4.0.365",
30
- "@remotion/media-utils": "4.0.365",
31
- "@remotion/media-parser": "4.0.365",
32
- "@remotion/renderer": "4.0.365",
33
- "@remotion/web-renderer": "4.0.365",
34
- "@remotion/studio-shared": "4.0.365",
35
- "@remotion/webcodecs": "4.0.365",
36
- "@remotion/zod-types": "4.0.365",
28
+ "remotion": "4.0.366",
29
+ "@remotion/player": "4.0.366",
30
+ "@remotion/media-utils": "4.0.366",
31
+ "@remotion/renderer": "4.0.366",
32
+ "@remotion/web-renderer": "4.0.366",
33
+ "@remotion/studio-shared": "4.0.366",
34
+ "@remotion/zod-types": "4.0.366",
35
+ "mediabunny": "1.24.2",
37
36
  "memfs": "3.4.3",
38
37
  "source-map": "0.7.3",
39
38
  "open": "^8.4.2",
@@ -43,7 +42,7 @@
43
42
  "react": "19.0.0",
44
43
  "react-dom": "19.0.0",
45
44
  "@types/semver": "^7.3.4",
46
- "@remotion/eslint-config-internal": "4.0.365",
45
+ "@remotion/eslint-config-internal": "4.0.366",
47
46
  "eslint": "9.19.0"
48
47
  },
49
48
  "publishConfig": {