@remotion/media 4.0.445 → 4.0.446

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.
@@ -9,6 +9,14 @@ export type FallbackHtml5AudioProps = {
9
9
  };
10
10
  export type AudioProps = {
11
11
  src: string;
12
+ /**
13
+ * When set, `<Audio>` applies timing via an inner `<Sequence layout="none">` that is hidden from the timeline (`showInTimeline={false}`) so the clip still appears once as media.
14
+ */
15
+ from?: number;
16
+ /**
17
+ * When set with `from`, bounds the clip in frames. Defaults to `Infinity` like `<Sequence>`.
18
+ */
19
+ durationInFrames?: number;
12
20
  trimBefore?: number;
13
21
  trimAfter?: number;
14
22
  volume?: VolumeProp;
@@ -0,0 +1,14 @@
1
+ export type ObjectFitValue = 'fill' | 'contain' | 'cover' | 'none' | 'scale-down';
2
+ /**
3
+ * Draws a source image onto a canvas context with the specified object-fit behavior.
4
+ * This implements object-fit at the canvas drawing level, which is more reliable
5
+ * than CSS object-fit on canvas elements.
6
+ */
7
+ export declare const drawWithObjectFit: (ctx: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D, source: CanvasImageSource, options: {
8
+ sourceWidth: number;
9
+ sourceHeight: number;
10
+ destWidth: number;
11
+ destHeight: number;
12
+ fit: ObjectFitValue;
13
+ }) => void;
14
+ export declare const parseObjectFit: (value: string | undefined) => ObjectFitValue | null;
@@ -37,7 +37,7 @@ var __callDispose = (stack, error, hasError) => {
37
37
  };
38
38
 
39
39
  // src/audio/audio.tsx
40
- import { Internals as Internals19, useRemotionEnvironment as useRemotionEnvironment2 } from "remotion";
40
+ import { Internals as Internals19, Sequence, useRemotionEnvironment as useRemotionEnvironment2 } from "remotion";
41
41
 
42
42
  // src/audio/audio-for-preview.tsx
43
43
  import { useContext as useContext3, useEffect as useEffect2, useMemo as useMemo2, useRef, useState as useState2 } from "react";
@@ -4469,29 +4469,40 @@ var audioSchema = {
4469
4469
  loop: { type: "boolean", default: false, description: "Loop" }
4470
4470
  };
4471
4471
  var AudioInner = (props) => {
4472
- const { name, stack, showInTimeline, controls, ...otherProps } = props;
4472
+ const {
4473
+ name,
4474
+ stack,
4475
+ showInTimeline,
4476
+ controls,
4477
+ from,
4478
+ durationInFrames,
4479
+ ...otherProps
4480
+ } = props;
4473
4481
  const environment = useRemotionEnvironment2();
4474
4482
  if (typeof props.src !== "string") {
4475
4483
  throw new TypeError(`The \`<Audio>\` tag requires a string for \`src\`, but got ${JSON.stringify(props.src)} instead.`);
4476
4484
  }
4477
4485
  validateMediaProps({ playbackRate: props.playbackRate, volume: props.volume }, "Audio");
4478
- if (environment.isRendering) {
4479
- return /* @__PURE__ */ jsx3(AudioForRendering, {
4486
+ return /* @__PURE__ */ jsx3(Sequence, {
4487
+ layout: "none",
4488
+ from: from ?? 0,
4489
+ durationInFrames: durationInFrames ?? Infinity,
4490
+ showInTimeline: false,
4491
+ children: environment.isRendering ? /* @__PURE__ */ jsx3(AudioForRendering, {
4480
4492
  ...otherProps
4481
- });
4482
- }
4483
- return /* @__PURE__ */ jsx3(AudioForPreview, {
4484
- name,
4485
- ...otherProps,
4486
- stack: stack ?? null,
4487
- controls
4493
+ }) : /* @__PURE__ */ jsx3(AudioForPreview, {
4494
+ name,
4495
+ ...otherProps,
4496
+ stack: stack ?? null,
4497
+ controls
4498
+ })
4488
4499
  });
4489
4500
  };
4490
4501
  var Audio = Internals19.wrapInSchema(AudioInner, audioSchema);
4491
4502
  Internals19.addSequenceStackTraces(Audio);
4492
4503
 
4493
4504
  // src/video/video.tsx
4494
- import { Internals as Internals23, useRemotionEnvironment as useRemotionEnvironment4 } from "remotion";
4505
+ import { Internals as Internals23, Sequence as Sequence2, useRemotionEnvironment as useRemotionEnvironment4 } from "remotion";
4495
4506
 
4496
4507
  // src/video/video-for-preview.tsx
4497
4508
  import {
@@ -5375,38 +5386,46 @@ var VideoInner = ({
5375
5386
  onError,
5376
5387
  credentials,
5377
5388
  controls,
5378
- objectFit
5389
+ objectFit,
5390
+ from,
5391
+ durationInFrames
5379
5392
  }) => {
5380
5393
  const fallbackLogLevel = Internals23.useLogLevel();
5381
- return /* @__PURE__ */ jsx6(InnerVideo, {
5382
- audioStreamIndex: audioStreamIndex ?? 0,
5383
- className,
5384
- delayRenderRetries: delayRenderRetries ?? null,
5385
- delayRenderTimeoutInMilliseconds: delayRenderTimeoutInMilliseconds ?? null,
5386
- disallowFallbackToOffthreadVideo: disallowFallbackToOffthreadVideo ?? false,
5387
- fallbackOffthreadVideoProps: fallbackOffthreadVideoProps ?? {},
5388
- logLevel: logLevel ?? fallbackLogLevel,
5389
- loop: loop ?? false,
5390
- loopVolumeCurveBehavior: loopVolumeCurveBehavior ?? "repeat",
5391
- muted: muted ?? false,
5392
- name,
5393
- onVideoFrame,
5394
- playbackRate: playbackRate ?? 1,
5395
- showInTimeline: showInTimeline ?? true,
5396
- src,
5397
- style: style ?? {},
5398
- trimAfter,
5399
- trimBefore,
5400
- volume: volume ?? 1,
5401
- toneFrequency: toneFrequency ?? 1,
5402
- stack,
5403
- debugOverlay: debugOverlay ?? false,
5404
- debugAudioScheduling: debugAudioScheduling ?? false,
5405
- headless: headless ?? false,
5406
- onError,
5407
- credentials,
5408
- controls,
5409
- objectFit: objectFit ?? "contain"
5394
+ return /* @__PURE__ */ jsx6(Sequence2, {
5395
+ layout: "none",
5396
+ from: from ?? 0,
5397
+ durationInFrames: durationInFrames ?? Infinity,
5398
+ showInTimeline: false,
5399
+ children: /* @__PURE__ */ jsx6(InnerVideo, {
5400
+ audioStreamIndex: audioStreamIndex ?? 0,
5401
+ className,
5402
+ delayRenderRetries: delayRenderRetries ?? null,
5403
+ delayRenderTimeoutInMilliseconds: delayRenderTimeoutInMilliseconds ?? null,
5404
+ disallowFallbackToOffthreadVideo: disallowFallbackToOffthreadVideo ?? false,
5405
+ fallbackOffthreadVideoProps: fallbackOffthreadVideoProps ?? {},
5406
+ logLevel: logLevel ?? fallbackLogLevel,
5407
+ loop: loop ?? false,
5408
+ loopVolumeCurveBehavior: loopVolumeCurveBehavior ?? "repeat",
5409
+ muted: muted ?? false,
5410
+ name,
5411
+ onVideoFrame,
5412
+ playbackRate: playbackRate ?? 1,
5413
+ showInTimeline: showInTimeline ?? true,
5414
+ src,
5415
+ style: style ?? {},
5416
+ trimAfter,
5417
+ trimBefore,
5418
+ volume: volume ?? 1,
5419
+ toneFrequency: toneFrequency ?? 1,
5420
+ stack,
5421
+ debugOverlay: debugOverlay ?? false,
5422
+ debugAudioScheduling: debugAudioScheduling ?? false,
5423
+ headless: headless ?? false,
5424
+ onError,
5425
+ credentials,
5426
+ controls,
5427
+ objectFit: objectFit ?? "contain"
5428
+ })
5410
5429
  });
5411
5430
  };
5412
5431
  var Video = Internals23.wrapInSchema(VideoInner, videoSchema);
package/dist/index.d.ts CHANGED
@@ -39,7 +39,10 @@ export declare const experimental_Video: import("react").ComponentType<{
39
39
  onError: import("./on-error").MediaOnError | undefined;
40
40
  credentials: RequestCredentials | undefined;
41
41
  objectFit: import(".").VideoObjectFit;
42
- }>>;
42
+ }> & {
43
+ from?: number | undefined;
44
+ durationInFrames?: number | undefined;
45
+ }>;
43
46
  export { AudioForPreview } from './audio/audio-for-preview';
44
47
  export { AudioProps, FallbackHtml5AudioProps } from './audio/props';
45
48
  export { MediaErrorAction } from './on-error';
@@ -53,5 +53,14 @@ type OptionalVideoProps = {
53
53
  objectFit: VideoObjectFit;
54
54
  };
55
55
  export type InnerVideoProps = MandatoryVideoProps & OuterVideoProps & OptionalVideoProps;
56
- export type VideoProps = MandatoryVideoProps & Partial<OuterVideoProps> & Partial<OptionalVideoProps>;
56
+ export type VideoProps = MandatoryVideoProps & Partial<OuterVideoProps> & Partial<OptionalVideoProps> & {
57
+ /**
58
+ * When set, `<Video>` applies timing via an inner `<Sequence layout="none">` that is hidden from the timeline (`showInTimeline={false}`) so the clip still appears once as media.
59
+ */
60
+ from?: number;
61
+ /**
62
+ * Bounds the clip in frames together with `from`. Defaults to `Infinity` like `<Sequence>`.
63
+ */
64
+ durationInFrames?: number;
65
+ };
57
66
  export {};
@@ -31,4 +31,7 @@ export declare const Video: React.ComponentType<{
31
31
  onError: import("../on-error").MediaOnError | undefined;
32
32
  credentials: RequestCredentials | undefined;
33
33
  objectFit: import("./props").VideoObjectFit;
34
- }>>;
34
+ }> & {
35
+ from?: number | undefined;
36
+ durationInFrames?: number | undefined;
37
+ }>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remotion/media",
3
- "version": "4.0.445",
3
+ "version": "4.0.446",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "module": "dist/esm/index.mjs",
@@ -23,7 +23,7 @@
23
23
  },
24
24
  "dependencies": {
25
25
  "mediabunny": "1.39.2",
26
- "remotion": "4.0.445",
26
+ "remotion": "4.0.446",
27
27
  "zod": "4.3.6"
28
28
  },
29
29
  "peerDependencies": {
@@ -31,7 +31,7 @@
31
31
  "react-dom": ">=16.8.0"
32
32
  },
33
33
  "devDependencies": {
34
- "@remotion/eslint-config-internal": "4.0.445",
34
+ "@remotion/eslint-config-internal": "4.0.446",
35
35
  "@vitest/browser-webdriverio": "4.0.9",
36
36
  "eslint": "9.19.0",
37
37
  "react": "19.2.3",
@@ -1,5 +0,0 @@
1
- export declare const calculatePlaybackTime: ({ audioSyncAnchor, currentTime, playbackRate, }: {
2
- audioSyncAnchor: number;
3
- currentTime: number;
4
- playbackRate: number;
5
- }) => number;