remotion 4.0.339 → 4.0.340

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.
@@ -56,6 +56,7 @@ export type TSequence = {
56
56
  loopDisplay: LoopDisplay | undefined;
57
57
  stack: string | null;
58
58
  premountDisplay: number | null;
59
+ postmountDisplay: number | null;
59
60
  } & EnhancedTSequenceData;
60
61
  export type AudioOrVideoAsset = {
61
62
  type: 'audio' | 'video';
@@ -67,6 +68,7 @@ export type AudioOrVideoAsset = {
67
68
  playbackRate: number;
68
69
  toneFrequency: number | null;
69
70
  audioStartFrame: number;
71
+ audioStreamIndex: number;
70
72
  };
71
73
  type DiscriminatedArtifact = {
72
74
  contentType: 'binary';
package/dist/cjs/Img.js CHANGED
@@ -71,6 +71,7 @@ const ImgRefForwarding = ({ onError, maxRetries = 2, src, pauseWhenLoading, dela
71
71
  }, [maxRetries, onError, retryIn]);
72
72
  if (typeof window !== 'undefined') {
73
73
  const isPremounting = Boolean(sequenceContext === null || sequenceContext === void 0 ? void 0 : sequenceContext.premounting);
74
+ const isPostmounting = Boolean(sequenceContext === null || sequenceContext === void 0 ? void 0 : sequenceContext.postmounting);
74
75
  // eslint-disable-next-line react-hooks/rules-of-hooks
75
76
  (0, react_1.useLayoutEffect)(() => {
76
77
  var _a, _b;
@@ -88,7 +89,7 @@ const ImgRefForwarding = ({ onError, maxRetries = 2, src, pauseWhenLoading, dela
88
89
  retries: delayRenderRetries !== null && delayRenderRetries !== void 0 ? delayRenderRetries : undefined,
89
90
  timeoutInMilliseconds: delayRenderTimeoutInMilliseconds !== null && delayRenderTimeoutInMilliseconds !== void 0 ? delayRenderTimeoutInMilliseconds : undefined,
90
91
  });
91
- const unblock = pauseWhenLoading && !isPremounting
92
+ const unblock = pauseWhenLoading && !isPremounting && !isPostmounting
92
93
  ? delayPlayback().unblock
93
94
  : () => undefined;
94
95
  let unmounted = false;
@@ -148,6 +149,7 @@ const ImgRefForwarding = ({ onError, maxRetries = 2, src, pauseWhenLoading, dela
148
149
  delayRenderTimeoutInMilliseconds,
149
150
  pauseWhenLoading,
150
151
  isPremounting,
152
+ isPostmounting,
151
153
  onImageFrame,
152
154
  ]);
153
155
  }
@@ -3,8 +3,10 @@ import type { LoopDisplay } from './CompositionManager.js';
3
3
  export type AbsoluteFillLayout = {
4
4
  layout?: 'absolute-fill';
5
5
  premountFor?: number;
6
+ postmountFor?: number;
6
7
  style?: React.CSSProperties;
7
8
  styleWhilePremounted?: React.CSSProperties;
9
+ styleWhilePostmounted?: React.CSSProperties;
8
10
  className?: string;
9
11
  };
10
12
  export type LayoutAndStyle = AbsoluteFillLayout | {
@@ -25,6 +27,10 @@ export type SequencePropsWithoutDuration = {
25
27
  * @deprecated For internal use only.
26
28
  */
27
29
  readonly _remotionInternalPremountDisplay?: number | null;
30
+ /**
31
+ * @deprecated For internal use only.
32
+ */
33
+ readonly _remotionInternalPostmountDisplay?: number | null;
28
34
  /**
29
35
  * @deprecated For internal use only.
30
36
  */
@@ -33,6 +39,10 @@ export type SequencePropsWithoutDuration = {
33
39
  * @deprecated For internal use only.
34
40
  */
35
41
  readonly _remotionInternalIsPremounting?: boolean;
42
+ /**
43
+ * @deprecated For internal use only.
44
+ */
45
+ readonly _remotionInternalIsPostmounting?: boolean;
36
46
  } & LayoutAndStyle;
37
47
  export type SequenceProps = {
38
48
  readonly durationInFrames?: number;
@@ -13,7 +13,7 @@ const timeline_position_state_js_1 = require("./timeline-position-state.js");
13
13
  const use_video_config_js_1 = require("./use-video-config.js");
14
14
  const freeze_js_1 = require("./freeze.js");
15
15
  const use_current_frame_1 = require("./use-current-frame");
16
- const RegularSequenceRefForwardingFunction = ({ from = 0, durationInFrames = Infinity, children, name, height, width, showInTimeline = true, _remotionInternalLoopDisplay: loopDisplay, _remotionInternalStack: stack, _remotionInternalPremountDisplay: premountDisplay, ...other }, ref) => {
16
+ const RegularSequenceRefForwardingFunction = ({ from = 0, durationInFrames = Infinity, children, name, height, width, showInTimeline = true, _remotionInternalLoopDisplay: loopDisplay, _remotionInternalStack: stack, _remotionInternalPremountDisplay: premountDisplay, _remotionInternalPostmountDisplay: postmountDisplay, ...other }, ref) => {
17
17
  var _a;
18
18
  const { layout = 'absolute-fill' } = other;
19
19
  const [id] = (0, react_1.useState)(() => String(Math.random()));
@@ -55,6 +55,11 @@ const RegularSequenceRefForwardingFunction = ({ from = 0, durationInFrames = Inf
55
55
  return ((parentSequence === null || parentSequence === void 0 ? void 0 : parentSequence.premounting) ||
56
56
  Boolean(other._remotionInternalIsPremounting));
57
57
  }, [other._remotionInternalIsPremounting, parentSequence === null || parentSequence === void 0 ? void 0 : parentSequence.premounting]);
58
+ const postmounting = (0, react_1.useMemo)(() => {
59
+ // || is intentional, ?? would not trigger on `false`
60
+ return ((parentSequence === null || parentSequence === void 0 ? void 0 : parentSequence.postmounting) ||
61
+ Boolean(other._remotionInternalIsPostmounting));
62
+ }, [other._remotionInternalIsPostmounting, parentSequence === null || parentSequence === void 0 ? void 0 : parentSequence.postmounting]);
58
63
  const contextValue = (0, react_1.useMemo)(() => {
59
64
  var _a, _b, _c;
60
65
  return {
@@ -66,6 +71,7 @@ const RegularSequenceRefForwardingFunction = ({ from = 0, durationInFrames = Inf
66
71
  height: (_b = height !== null && height !== void 0 ? height : parentSequence === null || parentSequence === void 0 ? void 0 : parentSequence.height) !== null && _b !== void 0 ? _b : null,
67
72
  width: (_c = width !== null && width !== void 0 ? width : parentSequence === null || parentSequence === void 0 ? void 0 : parentSequence.width) !== null && _c !== void 0 ? _c : null,
68
73
  premounting,
74
+ postmounting,
69
75
  };
70
76
  }, [
71
77
  cumulatedFrom,
@@ -76,6 +82,7 @@ const RegularSequenceRefForwardingFunction = ({ from = 0, durationInFrames = Inf
76
82
  height,
77
83
  width,
78
84
  premounting,
85
+ postmounting,
79
86
  ]);
80
87
  const timelineClipName = (0, react_1.useMemo)(() => {
81
88
  return name !== null && name !== void 0 ? name : '';
@@ -98,6 +105,7 @@ const RegularSequenceRefForwardingFunction = ({ from = 0, durationInFrames = Inf
98
105
  loopDisplay,
99
106
  stack: stack !== null && stack !== void 0 ? stack : null,
100
107
  premountDisplay: premountDisplay !== null && premountDisplay !== void 0 ? premountDisplay : null,
108
+ postmountDisplay: postmountDisplay !== null && postmountDisplay !== void 0 ? postmountDisplay : null,
101
109
  });
102
110
  return () => {
103
111
  unregisterSequence(id);
@@ -118,6 +126,7 @@ const RegularSequenceRefForwardingFunction = ({ from = 0, durationInFrames = Inf
118
126
  loopDisplay,
119
127
  stack,
120
128
  premountDisplay,
129
+ postmountDisplay,
121
130
  ]);
122
131
  // Ceil to support floats
123
132
  // https://github.com/remotion-dev/remotion/issues/2958
@@ -146,32 +155,48 @@ const RegularSequenceRefForwardingFunction = ({ from = 0, durationInFrames = Inf
146
155
  return ((0, jsx_runtime_1.jsx)(SequenceContext_js_1.SequenceContext.Provider, { value: contextValue, children: content === null ? null : other.layout === 'none' ? (content) : ((0, jsx_runtime_1.jsx)(AbsoluteFill_js_1.AbsoluteFill, { ref: ref, style: defaultStyle, className: other.className, children: content })) }));
147
156
  };
148
157
  const RegularSequence = (0, react_1.forwardRef)(RegularSequenceRefForwardingFunction);
149
- const PremountedSequenceRefForwardingFunction = (props, ref) => {
158
+ const PremountedPostmountedSequenceRefForwardingFunction = (props, ref) => {
150
159
  const frame = (0, use_current_frame_1.useCurrentFrame)();
151
160
  if (props.layout === 'none') {
152
- throw new Error('`<Sequence>` with `premountFor` prop does not support layout="none"');
161
+ throw new Error('`<Sequence>` with `premountFor` and `postmountFor` props does not support layout="none"');
153
162
  }
154
- const { style: passedStyle, from = 0, premountFor = 0, styleWhilePremounted, ...otherProps } = props;
163
+ const { style: passedStyle, from = 0, durationInFrames = Infinity, premountFor = 0, postmountFor = 0, styleWhilePremounted, styleWhilePostmounted, ...otherProps } = props;
164
+ const endThreshold = Math.ceil(from + durationInFrames - 1);
155
165
  const premountingActive = frame < from && frame >= from - premountFor;
166
+ const postmountingActive = frame > endThreshold && frame <= endThreshold + postmountFor;
167
+ // Determine which freeze frame to use
168
+ const freezeFrame = premountingActive
169
+ ? from
170
+ : postmountingActive
171
+ ? from + durationInFrames - 1
172
+ : 0;
173
+ const isFreezingActive = premountingActive || postmountingActive;
156
174
  const style = (0, react_1.useMemo)(() => {
157
175
  var _a;
158
176
  return {
159
177
  ...passedStyle,
160
- opacity: premountingActive ? 0 : 1,
161
- pointerEvents: premountingActive
178
+ opacity: premountingActive || postmountingActive ? 0 : 1,
179
+ pointerEvents: premountingActive || postmountingActive
162
180
  ? 'none'
163
181
  : ((_a = passedStyle === null || passedStyle === void 0 ? void 0 : passedStyle.pointerEvents) !== null && _a !== void 0 ? _a : undefined),
164
182
  ...(premountingActive ? styleWhilePremounted : {}),
183
+ ...(postmountingActive ? styleWhilePostmounted : {}),
165
184
  };
166
- }, [passedStyle, premountingActive, styleWhilePremounted]);
167
- return ((0, jsx_runtime_1.jsx)(freeze_js_1.Freeze, { frame: from, active: premountingActive, children: (0, jsx_runtime_1.jsx)(exports.Sequence, { ref: ref, from: from, style: style, _remotionInternalPremountDisplay: premountFor, _remotionInternalIsPremounting: premountingActive, ...otherProps }) }));
185
+ }, [
186
+ passedStyle,
187
+ premountingActive,
188
+ postmountingActive,
189
+ styleWhilePremounted,
190
+ styleWhilePostmounted,
191
+ ]);
192
+ return ((0, jsx_runtime_1.jsx)(freeze_js_1.Freeze, { frame: freezeFrame, active: isFreezingActive, children: (0, jsx_runtime_1.jsx)(exports.Sequence, { ref: ref, from: from, durationInFrames: durationInFrames, style: style, _remotionInternalPremountDisplay: premountFor, _remotionInternalPostmountDisplay: postmountFor, _remotionInternalIsPremounting: premountingActive, _remotionInternalIsPostmounting: postmountingActive, ...otherProps }) }));
168
193
  };
169
- const PremountedSequence = (0, react_1.forwardRef)(PremountedSequenceRefForwardingFunction);
194
+ const PremountedPostmountedSequence = (0, react_1.forwardRef)(PremountedPostmountedSequenceRefForwardingFunction);
170
195
  const SequenceRefForwardingFunction = (props, ref) => {
171
- if (props.layout !== 'none' &&
172
- props.premountFor &&
173
- !(0, get_remotion_environment_js_1.getRemotionEnvironment)().isRendering) {
174
- return (0, jsx_runtime_1.jsx)(PremountedSequence, { ...props, ref: ref });
196
+ if (props.layout !== 'none' && !(0, get_remotion_environment_js_1.getRemotionEnvironment)().isRendering) {
197
+ if (props.premountFor || props.postmountFor) {
198
+ return (0, jsx_runtime_1.jsx)(PremountedPostmountedSequence, { ...props, ref: ref });
199
+ }
175
200
  }
176
201
  return (0, jsx_runtime_1.jsx)(RegularSequence, { ...props, ref: ref });
177
202
  };
@@ -8,4 +8,5 @@ export type SequenceContextType = {
8
8
  width: number | null;
9
9
  height: number | null;
10
10
  premounting: boolean;
11
+ postmounting: boolean;
11
12
  };
@@ -16,6 +16,7 @@ export declare const Audio: React.ForwardRefExoticComponent<Omit<import("./props
16
16
  delayRenderRetries?: number;
17
17
  loopVolumeCurveBehavior?: import("./use-audio-frame.js").LoopVolumeCurveBehavior;
18
18
  onError?: (err: Error) => void;
19
+ audioStreamIndex?: number;
19
20
  } & RemotionMainAudioProps & {
20
21
  /**
21
22
  * @deprecated For internal use only
@@ -23,7 +23,7 @@ const AudioForDevelopmentForwardRefFunction = (props, ref) => {
23
23
  throw new Error('Cannot change the behavior for pre-mounting audio tags dynamically.');
24
24
  }
25
25
  const logLevel = (0, log_level_context_js_1.useLogLevel)();
26
- const { volume, muted, playbackRate, shouldPreMountAudioTags, src, onDuration, acceptableTimeShiftInSeconds, _remotionInternalNeedsDurationCalculation, _remotionInternalNativeLoopPassed, _remotionInternalStack, allowAmplificationDuringRender, name, pauseWhenBuffering, showInTimeline, loopVolumeCurveBehavior, stack, crossOrigin, delayRenderRetries, delayRenderTimeoutInMilliseconds, toneFrequency, useWebAudioApi, onError, onNativeError, ...nativeProps } = props;
26
+ const { volume, muted, playbackRate, shouldPreMountAudioTags, src, onDuration, acceptableTimeShiftInSeconds, _remotionInternalNeedsDurationCalculation, _remotionInternalNativeLoopPassed, _remotionInternalStack, allowAmplificationDuringRender, name, pauseWhenBuffering, showInTimeline, loopVolumeCurveBehavior, stack, crossOrigin, delayRenderRetries, delayRenderTimeoutInMilliseconds, toneFrequency, useWebAudioApi, onError, onNativeError, audioStreamIndex, ...nativeProps } = props;
27
27
  // Typecheck that we are not accidentially passing unrecognized props
28
28
  // to the DOM
29
29
  const _propsValid = true;
@@ -99,8 +99,10 @@ const AudioForDevelopmentForwardRefFunction = (props, ref) => {
99
99
  stack: _remotionInternalStack,
100
100
  showInTimeline,
101
101
  premountDisplay: null,
102
+ postmountDisplay: null,
102
103
  onAutoPlayError: null,
103
104
  isPremounting: Boolean(sequenceContext === null || sequenceContext === void 0 ? void 0 : sequenceContext.premounting),
105
+ isPostmounting: Boolean(sequenceContext === null || sequenceContext === void 0 ? void 0 : sequenceContext.postmounting),
104
106
  });
105
107
  // putting playback before useVolume
106
108
  // because volume looks at playbackrate
@@ -112,6 +114,7 @@ const AudioForDevelopmentForwardRefFunction = (props, ref) => {
112
114
  onlyWarnForMediaSeekingError: false,
113
115
  acceptableTimeshift: acceptableTimeShiftInSeconds !== null && acceptableTimeShiftInSeconds !== void 0 ? acceptableTimeShiftInSeconds : null,
114
116
  isPremounting: Boolean(sequenceContext === null || sequenceContext === void 0 ? void 0 : sequenceContext.premounting),
117
+ isPostmounting: Boolean(sequenceContext === null || sequenceContext === void 0 ? void 0 : sequenceContext.postmounting),
115
118
  pauseWhenBuffering,
116
119
  onAutoPlayError: null,
117
120
  });
@@ -14,7 +14,7 @@ const volume_prop_js_1 = require("../volume-prop.js");
14
14
  const use_audio_frame_js_1 = require("./use-audio-frame.js");
15
15
  const AudioForRenderingRefForwardingFunction = (props, ref) => {
16
16
  const audioRef = (0, react_1.useRef)(null);
17
- const { volume: volumeProp, playbackRate, allowAmplificationDuringRender, onDuration, toneFrequency, _remotionInternalNeedsDurationCalculation, _remotionInternalNativeLoopPassed, acceptableTimeShiftInSeconds, name, onNativeError, delayRenderRetries, delayRenderTimeoutInMilliseconds, loopVolumeCurveBehavior, pauseWhenBuffering, ...nativeProps } = props;
17
+ const { volume: volumeProp, playbackRate, allowAmplificationDuringRender, onDuration, toneFrequency, _remotionInternalNeedsDurationCalculation, _remotionInternalNativeLoopPassed, acceptableTimeShiftInSeconds, name, onNativeError, delayRenderRetries, delayRenderTimeoutInMilliseconds, loopVolumeCurveBehavior, pauseWhenBuffering, audioStreamIndex, ...nativeProps } = props;
18
18
  const absoluteFrame = (0, timeline_position_state_js_1.useTimelinePosition)();
19
19
  const volumePropFrame = (0, use_audio_frame_js_1.useFrameForVolumeProp)(loopVolumeCurveBehavior !== null && loopVolumeCurveBehavior !== void 0 ? loopVolumeCurveBehavior : 'repeat');
20
20
  const frame = (0, use_current_frame_js_1.useCurrentFrame)();
@@ -63,6 +63,7 @@ const AudioForRenderingRefForwardingFunction = (props, ref) => {
63
63
  playbackRate: (_a = props.playbackRate) !== null && _a !== void 0 ? _a : 1,
64
64
  toneFrequency: toneFrequency !== null && toneFrequency !== void 0 ? toneFrequency : null,
65
65
  audioStartFrame: Math.max(0, -((_b = sequenceContext === null || sequenceContext === void 0 ? void 0 : sequenceContext.relativeFrom) !== null && _b !== void 0 ? _b : 0)),
66
+ audioStreamIndex: audioStreamIndex !== null && audioStreamIndex !== void 0 ? audioStreamIndex : 0,
66
67
  });
67
68
  return () => unregisterRenderAsset(id);
68
69
  }, [
@@ -79,6 +80,7 @@ const AudioForRenderingRefForwardingFunction = (props, ref) => {
79
80
  props.playbackRate,
80
81
  toneFrequency,
81
82
  sequenceContext === null || sequenceContext === void 0 ? void 0 : sequenceContext.relativeFrom,
83
+ audioStreamIndex,
82
84
  ]);
83
85
  const { src } = props;
84
86
  // The <audio> tag is only rendered if the duration needs to be calculated for the `loop`
@@ -38,6 +38,7 @@ export type RemotionAudioProps = NativeAudioProps & {
38
38
  delayRenderRetries?: number;
39
39
  loopVolumeCurveBehavior?: LoopVolumeCurveBehavior;
40
40
  onError?: (err: Error) => void;
41
+ audioStreamIndex?: number;
41
42
  };
42
43
  type IsNever<T> = [T] extends [never] ? true : false;
43
44
  export type IsExact<T, U> = (<G>() => G extends T ? 1 : 2) extends <G>() => G extends U ? 1 : 2 ? IsNever<Exclude<keyof T, keyof U>> extends true ? IsNever<Exclude<keyof U, keyof T>> extends true ? true : false : false : false;
@@ -53,6 +53,7 @@ export declare const Internals: {
53
53
  delayRenderRetries?: number;
54
54
  onError?: (err: Error) => void;
55
55
  onAutoPlayError?: null | (() => void);
56
+ audioStreamIndex?: number;
56
57
  } & {
57
58
  readonly onlyWarnForMediaSeekingError: boolean;
58
59
  readonly onDuration: (src: string, durationInSeconds: number) => void;
@@ -1,9 +1,10 @@
1
1
  import type React from 'react';
2
2
  import type { LogLevel } from './log';
3
- export declare const useMediaBuffering: ({ element, shouldBuffer, isPremounting, logLevel, mountTime, src, }: {
3
+ export declare const useMediaBuffering: ({ element, shouldBuffer, isPremounting, isPostmounting, logLevel, mountTime, src, }: {
4
4
  element: React.RefObject<HTMLVideoElement | HTMLAudioElement | null>;
5
5
  shouldBuffer: boolean;
6
6
  isPremounting: boolean;
7
+ isPostmounting: boolean;
7
8
  logLevel: LogLevel;
8
9
  mountTime: number;
9
10
  src: string | null;
@@ -4,7 +4,7 @@ exports.useMediaBuffering = void 0;
4
4
  const react_1 = require("react");
5
5
  const playback_logging_1 = require("./playback-logging");
6
6
  const use_buffer_state_1 = require("./use-buffer-state");
7
- const useMediaBuffering = ({ element, shouldBuffer, isPremounting, logLevel, mountTime, src, }) => {
7
+ const useMediaBuffering = ({ element, shouldBuffer, isPremounting, isPostmounting, logLevel, mountTime, src, }) => {
8
8
  const buffer = (0, use_buffer_state_1.useBufferState)();
9
9
  const [isBuffering, setIsBuffering] = (0, react_1.useState)(false);
10
10
  // Buffer state based on `waiting` and `canplay`
@@ -17,7 +17,7 @@ const useMediaBuffering = ({ element, shouldBuffer, isPremounting, logLevel, mou
17
17
  if (!shouldBuffer) {
18
18
  return;
19
19
  }
20
- if (isPremounting) {
20
+ if (isPremounting || isPostmounting) {
21
21
  // Needed by iOS Safari which will not load by default
22
22
  // and therefore not fire the canplay event.
23
23
  // Be cautious about using `current.load()` as it will
@@ -25,7 +25,8 @@ const useMediaBuffering = ({ element, shouldBuffer, isPremounting, logLevel, mou
25
25
  // Therefore only calling it after checking if the video
26
26
  // has no future data.
27
27
  // Breaks on Firefox though: https://github.com/remotion-dev/remotion/issues/3915
28
- if (current.readyState < current.HAVE_FUTURE_DATA) {
28
+ if ((isPremounting || isPostmounting) &&
29
+ current.readyState < current.HAVE_FUTURE_DATA) {
29
30
  if (!navigator.userAgent.includes('Firefox/')) {
30
31
  (0, playback_logging_1.playbackLogging)({
31
32
  logLevel,
@@ -38,6 +39,7 @@ const useMediaBuffering = ({ element, shouldBuffer, isPremounting, logLevel, mou
38
39
  current.playbackRate = previousPlaybackRate;
39
40
  }
40
41
  }
42
+ // Don't trigger buffering during premount or postmount
41
43
  return;
42
44
  }
43
45
  const cleanup = (reason) => {
@@ -143,7 +145,16 @@ const useMediaBuffering = ({ element, shouldBuffer, isPremounting, logLevel, mou
143
145
  // `src` should be in it, because if changing the source and pausing at the same time,
144
146
  // it gives the chance to load the new source.
145
147
  // https://github.com/remotion-dev/remotion/issues/5218
146
- }, [buffer, src, element, isPremounting, logLevel, shouldBuffer, mountTime]);
148
+ }, [
149
+ buffer,
150
+ src,
151
+ element,
152
+ isPremounting,
153
+ isPostmounting,
154
+ logLevel,
155
+ shouldBuffer,
156
+ mountTime,
157
+ ]);
147
158
  return isBuffering;
148
159
  };
149
160
  exports.useMediaBuffering = useMediaBuffering;
@@ -1,6 +1,6 @@
1
1
  import type { RefObject } from 'react';
2
2
  import type { VolumeProp } from './volume-prop.js';
3
- export declare const useMediaInTimeline: ({ volume, mediaVolume, mediaRef, src, mediaType, playbackRate, displayName, id, stack, showInTimeline, premountDisplay, onAutoPlayError, isPremounting, }: {
3
+ export declare const useMediaInTimeline: ({ volume, mediaVolume, mediaRef, src, mediaType, playbackRate, displayName, id, stack, showInTimeline, premountDisplay, postmountDisplay, onAutoPlayError, isPremounting, isPostmounting, }: {
4
4
  volume: VolumeProp | undefined;
5
5
  mediaVolume: number;
6
6
  mediaRef: RefObject<HTMLAudioElement | HTMLVideoElement | null>;
@@ -12,6 +12,8 @@ export declare const useMediaInTimeline: ({ volume, mediaVolume, mediaRef, src,
12
12
  stack: string | null;
13
13
  showInTimeline: boolean;
14
14
  premountDisplay: number | null;
15
+ postmountDisplay: number | null;
15
16
  onAutoPlayError: null | (() => void);
16
17
  isPremounting: boolean;
18
+ isPostmounting: boolean;
17
19
  }) => void;
@@ -22,7 +22,7 @@ const warnOnce = (message) => {
22
22
  console.warn(message);
23
23
  didWarn[message] = true;
24
24
  };
25
- const useMediaInTimeline = ({ volume, mediaVolume, mediaRef, src, mediaType, playbackRate, displayName, id, stack, showInTimeline, premountDisplay, onAutoPlayError, isPremounting, }) => {
25
+ const useMediaInTimeline = ({ volume, mediaVolume, mediaRef, src, mediaType, playbackRate, displayName, id, stack, showInTimeline, premountDisplay, postmountDisplay, onAutoPlayError, isPremounting, isPostmounting, }) => {
26
26
  const videoConfig = (0, use_video_config_js_1.useVideoConfig)();
27
27
  const { rootId, audioAndVideoTags } = (0, react_1.useContext)(timeline_position_state_js_1.TimelineContext);
28
28
  const parentSequence = (0, react_1.useContext)(SequenceContext_js_1.SequenceContext);
@@ -93,6 +93,7 @@ const useMediaInTimeline = ({ volume, mediaVolume, mediaRef, src, mediaType, pla
93
93
  playbackRate,
94
94
  stack,
95
95
  premountDisplay,
96
+ postmountDisplay,
96
97
  });
97
98
  return () => {
98
99
  unregisterSequence(id);
@@ -118,6 +119,7 @@ const useMediaInTimeline = ({ volume, mediaVolume, mediaRef, src, mediaType, pla
118
119
  stack,
119
120
  showInTimeline,
120
121
  premountDisplay,
122
+ postmountDisplay,
121
123
  ]);
122
124
  (0, react_1.useEffect)(() => {
123
125
  const tag = {
@@ -127,7 +129,7 @@ const useMediaInTimeline = ({ volume, mediaVolume, mediaRef, src, mediaType, pla
127
129
  // Don't play if for example in a <Freeze> state.
128
130
  return;
129
131
  }
130
- if (isPremounting) {
132
+ if (isPremounting || isPostmounting) {
131
133
  return;
132
134
  }
133
135
  return (0, play_and_handle_not_allowed_error_js_1.playAndHandleNotAllowedError)({
@@ -152,6 +154,7 @@ const useMediaInTimeline = ({ volume, mediaVolume, mediaRef, src, mediaType, pla
152
154
  onAutoPlayError,
153
155
  imperativePlaying,
154
156
  isPremounting,
157
+ isPostmounting,
155
158
  logLevel,
156
159
  mountTime,
157
160
  ]);
@@ -1,5 +1,5 @@
1
1
  import type { RefObject } from 'react';
2
- export declare const useMediaPlayback: ({ mediaRef, src, mediaType, playbackRate: localPlaybackRate, onlyWarnForMediaSeekingError, acceptableTimeshift, pauseWhenBuffering, isPremounting, onAutoPlayError, }: {
2
+ export declare const useMediaPlayback: ({ mediaRef, src, mediaType, playbackRate: localPlaybackRate, onlyWarnForMediaSeekingError, acceptableTimeshift, pauseWhenBuffering, isPremounting, isPostmounting, onAutoPlayError, }: {
3
3
  mediaRef: RefObject<HTMLVideoElement | HTMLAudioElement | null>;
4
4
  src: string | undefined;
5
5
  mediaType: "audio" | "video";
@@ -8,5 +8,6 @@ export declare const useMediaPlayback: ({ mediaRef, src, mediaType, playbackRate
8
8
  acceptableTimeshift: number | null;
9
9
  pauseWhenBuffering: boolean;
10
10
  isPremounting: boolean;
11
+ isPostmounting: boolean;
11
12
  onAutoPlayError: null | (() => void);
12
13
  }) => void;
@@ -18,7 +18,7 @@ const use_request_video_callback_time_js_1 = require("./use-request-video-callba
18
18
  const use_video_config_js_1 = require("./use-video-config.js");
19
19
  const get_current_time_js_1 = require("./video/get-current-time.js");
20
20
  const warn_about_non_seekable_media_js_1 = require("./warn-about-non-seekable-media.js");
21
- const useMediaPlayback = ({ mediaRef, src, mediaType, playbackRate: localPlaybackRate, onlyWarnForMediaSeekingError, acceptableTimeshift, pauseWhenBuffering, isPremounting, onAutoPlayError, }) => {
21
+ const useMediaPlayback = ({ mediaRef, src, mediaType, playbackRate: localPlaybackRate, onlyWarnForMediaSeekingError, acceptableTimeshift, pauseWhenBuffering, isPremounting, isPostmounting, onAutoPlayError, }) => {
22
22
  const { playbackRate: globalPlaybackRate } = (0, react_1.useContext)(timeline_position_state_js_1.TimelineContext);
23
23
  const frame = (0, use_current_frame_js_1.useCurrentFrame)();
24
24
  const absoluteFrame = (0, timeline_position_state_js_1.useTimelinePosition)();
@@ -61,6 +61,7 @@ const useMediaPlayback = ({ mediaRef, src, mediaType, playbackRate: localPlaybac
61
61
  element: mediaRef,
62
62
  shouldBuffer: pauseWhenBuffering,
63
63
  isPremounting,
64
+ isPostmounting,
64
65
  logLevel,
65
66
  mountTime,
66
67
  src: src !== null && src !== void 0 ? src : null,
@@ -97,7 +98,7 @@ const useMediaPlayback = ({ mediaRef, src, mediaType, playbackRate: localPlaybac
97
98
  (0, playback_logging_js_1.playbackLogging)({
98
99
  logLevel,
99
100
  tag: 'pause',
100
- message: `Pausing ${(_b = mediaRef.current) === null || _b === void 0 ? void 0 : _b.src} because ${isPremounting ? 'media is premounting' : 'Player is not playing'}`,
101
+ message: `Pausing ${(_b = mediaRef.current) === null || _b === void 0 ? void 0 : _b.src} because ${isPremounting ? 'media is premounting' : isPostmounting ? 'media is postmounting' : 'Player is not playing'}`,
101
102
  mountTime,
102
103
  });
103
104
  (_c = mediaRef.current) === null || _c === void 0 ? void 0 : _c.pause();
@@ -125,6 +126,7 @@ const useMediaPlayback = ({ mediaRef, src, mediaType, playbackRate: localPlaybac
125
126
  mediaType,
126
127
  mountTime,
127
128
  playing,
129
+ isPostmounting,
128
130
  ]);
129
131
  // This must be a useLayoutEffect, because afterwards, useVolume() looks at the playbackRate
130
132
  // and it is also in a useLayoutEffect.
@@ -168,7 +170,7 @@ const useMediaPlayback = ({ mediaRef, src, mediaType, playbackRate: localPlaybac
168
170
  mediaRef: mediaRef.current,
169
171
  time: shouldBeTime,
170
172
  logLevel,
171
- why: `because time shift is too big. shouldBeTime = ${shouldBeTime}, isTime = ${mediaTagTime}, requestVideoCallbackTime = ${rvcTime}, timeShift = ${timeShift}${isVariableFpsVideo ? ', isVariableFpsVideo = true' : ''}, isPremounting = ${isPremounting}, pauseWhenBuffering = ${pauseWhenBuffering}`,
173
+ why: `because time shift is too big. shouldBeTime = ${shouldBeTime}, isTime = ${mediaTagTime}, requestVideoCallbackTime = ${rvcTime}, timeShift = ${timeShift}${isVariableFpsVideo ? ', isVariableFpsVideo = true' : ''}, isPremounting = ${isPremounting}, isPostmounting = ${isPostmounting}, pauseWhenBuffering = ${pauseWhenBuffering}`,
172
174
  mountTime,
173
175
  });
174
176
  lastSeekDueToShift.current = lastSeek.current;
@@ -262,6 +264,7 @@ const useMediaPlayback = ({ mediaRef, src, mediaType, playbackRate: localPlaybac
262
264
  src,
263
265
  onAutoPlayError,
264
266
  isPremounting,
267
+ isPostmounting,
265
268
  pauseWhenBuffering,
266
269
  mountTime,
267
270
  mediaTagCurrentTime,
@@ -3,4 +3,4 @@
3
3
  * @see [Documentation](https://remotion.dev/docs/version)
4
4
  * @returns {string} The current version of the remotion package
5
5
  */
6
- export declare const VERSION = "4.0.339";
6
+ export declare const VERSION = "4.0.340";
@@ -7,4 +7,4 @@ exports.VERSION = void 0;
7
7
  * @see [Documentation](https://remotion.dev/docs/version)
8
8
  * @returns {string} The current version of the remotion package
9
9
  */
10
- exports.VERSION = '4.0.339';
10
+ exports.VERSION = '4.0.340';
@@ -22,7 +22,7 @@ const offthread_video_source_js_1 = require("./offthread-video-source.js");
22
22
  const OffthreadVideoForRendering = ({ onError, volume: volumeProp, playbackRate, src, muted, allowAmplificationDuringRender, transparent = false, toneMapped = true, toneFrequency, name, loopVolumeCurveBehavior, delayRenderRetries, delayRenderTimeoutInMilliseconds, onVideoFrame,
23
23
  // Remove crossOrigin prop during rendering
24
24
  // https://discord.com/channels/809501355504959528/844143007183667220/1311639632496033813
25
- crossOrigin, ...props }) => {
25
+ crossOrigin, audioStreamIndex, ...props }) => {
26
26
  const absoluteFrame = (0, timeline_position_state_js_1.useTimelinePosition)();
27
27
  const frame = (0, use_current_frame_js_1.useCurrentFrame)();
28
28
  const volumePropsFrame = (0, use_audio_frame_js_1.useFrameForVolumeProp)(loopVolumeCurveBehavior !== null && loopVolumeCurveBehavior !== void 0 ? loopVolumeCurveBehavior : 'repeat');
@@ -73,6 +73,7 @@ crossOrigin, ...props }) => {
73
73
  playbackRate: playbackRate !== null && playbackRate !== void 0 ? playbackRate : 1,
74
74
  toneFrequency: toneFrequency !== null && toneFrequency !== void 0 ? toneFrequency : null,
75
75
  audioStartFrame: Math.max(0, -((_a = sequenceContext === null || sequenceContext === void 0 ? void 0 : sequenceContext.relativeFrom) !== null && _a !== void 0 ? _a : 0)),
76
+ audioStreamIndex: audioStreamIndex !== null && audioStreamIndex !== void 0 ? audioStreamIndex : 0,
76
77
  });
77
78
  return () => unregisterRenderAsset(id);
78
79
  }, [
@@ -87,6 +88,7 @@ crossOrigin, ...props }) => {
87
88
  playbackRate,
88
89
  toneFrequency,
89
90
  sequenceContext === null || sequenceContext === void 0 ? void 0 : sequenceContext.relativeFrom,
91
+ audioStreamIndex,
90
92
  ]);
91
93
  const currentTime = (0, react_1.useMemo)(() => {
92
94
  return ((0, get_current_time_js_1.getExpectedMediaFrameUncorrected)({
@@ -15,6 +15,7 @@ export declare const Video: React.ForwardRefExoticComponent<Omit<import("./props
15
15
  delayRenderRetries?: number;
16
16
  onError?: (err: Error) => void;
17
17
  onAutoPlayError?: null | (() => void);
18
+ audioStreamIndex?: number;
18
19
  } & RemotionMainVideoProps & {
19
20
  /**
20
21
  * @deprecated For internal use only
@@ -39,7 +39,7 @@ const VideoForDevelopmentRefForwardingFunction = (props, ref) => {
39
39
  }, [context.audioContext]);
40
40
  const { volume, muted, playbackRate, onlyWarnForMediaSeekingError, src, onDuration,
41
41
  // @ts-expect-error
42
- acceptableTimeShift, acceptableTimeShiftInSeconds, toneFrequency, name, _remotionInternalNativeLoopPassed, _remotionInternalStack, style, pauseWhenBuffering, showInTimeline, loopVolumeCurveBehavior, onError, onAutoPlayError, onVideoFrame, crossOrigin, delayRenderRetries, delayRenderTimeoutInMilliseconds, allowAmplificationDuringRender, useWebAudioApi, ...nativeProps } = props;
42
+ acceptableTimeShift, acceptableTimeShiftInSeconds, toneFrequency, name, _remotionInternalNativeLoopPassed, _remotionInternalStack, style, pauseWhenBuffering, showInTimeline, loopVolumeCurveBehavior, onError, onAutoPlayError, onVideoFrame, crossOrigin, delayRenderRetries, delayRenderTimeoutInMilliseconds, allowAmplificationDuringRender, useWebAudioApi, audioStreamIndex, ...nativeProps } = props;
43
43
  const _propsValid = true;
44
44
  if (!_propsValid) {
45
45
  throw new Error('typecheck error');
@@ -74,8 +74,10 @@ const VideoForDevelopmentRefForwardingFunction = (props, ref) => {
74
74
  stack: _remotionInternalStack,
75
75
  showInTimeline,
76
76
  premountDisplay: null,
77
+ postmountDisplay: null,
77
78
  onAutoPlayError: onAutoPlayError !== null && onAutoPlayError !== void 0 ? onAutoPlayError : null,
78
79
  isPremounting: Boolean(parentSequence === null || parentSequence === void 0 ? void 0 : parentSequence.premounting),
80
+ isPostmounting: Boolean(parentSequence === null || parentSequence === void 0 ? void 0 : parentSequence.postmounting),
79
81
  });
80
82
  // putting playback before useVolume
81
83
  // because volume looks at playbackrate
@@ -87,6 +89,7 @@ const VideoForDevelopmentRefForwardingFunction = (props, ref) => {
87
89
  onlyWarnForMediaSeekingError,
88
90
  acceptableTimeshift: acceptableTimeShiftInSeconds !== null && acceptableTimeShiftInSeconds !== void 0 ? acceptableTimeShiftInSeconds : null,
89
91
  isPremounting: Boolean(parentSequence === null || parentSequence === void 0 ? void 0 : parentSequence.premounting),
92
+ isPostmounting: Boolean(parentSequence === null || parentSequence === void 0 ? void 0 : parentSequence.postmounting),
90
93
  pauseWhenBuffering,
91
94
  onAutoPlayError: onAutoPlayError !== null && onAutoPlayError !== void 0 ? onAutoPlayError : null,
92
95
  });
@@ -18,7 +18,7 @@ const use_unsafe_video_config_js_1 = require("../use-unsafe-video-config.js");
18
18
  const volume_prop_js_1 = require("../volume-prop.js");
19
19
  const get_current_time_js_1 = require("./get-current-time.js");
20
20
  const seek_until_right_js_1 = require("./seek-until-right.js");
21
- const VideoForRenderingForwardFunction = ({ onError, volume: volumeProp, allowAmplificationDuringRender, playbackRate, onDuration, toneFrequency, name, acceptableTimeShiftInSeconds, delayRenderRetries, delayRenderTimeoutInMilliseconds, loopVolumeCurveBehavior, ...props }, ref) => {
21
+ const VideoForRenderingForwardFunction = ({ onError, volume: volumeProp, allowAmplificationDuringRender, playbackRate, onDuration, toneFrequency, name, acceptableTimeShiftInSeconds, delayRenderRetries, delayRenderTimeoutInMilliseconds, loopVolumeCurveBehavior, audioStreamIndex, ...props }, ref) => {
22
22
  const absoluteFrame = (0, timeline_position_state_js_1.useTimelinePosition)();
23
23
  const frame = (0, use_current_frame_js_1.useCurrentFrame)();
24
24
  const volumePropsFrame = (0, use_audio_frame_js_1.useFrameForVolumeProp)(loopVolumeCurveBehavior !== null && loopVolumeCurveBehavior !== void 0 ? loopVolumeCurveBehavior : 'repeat');
@@ -73,6 +73,7 @@ const VideoForRenderingForwardFunction = ({ onError, volume: volumeProp, allowAm
73
73
  playbackRate: playbackRate !== null && playbackRate !== void 0 ? playbackRate : 1,
74
74
  toneFrequency: toneFrequency !== null && toneFrequency !== void 0 ? toneFrequency : null,
75
75
  audioStartFrame: Math.max(0, -((_a = sequenceContext === null || sequenceContext === void 0 ? void 0 : sequenceContext.relativeFrom) !== null && _a !== void 0 ? _a : 0)),
76
+ audioStreamIndex: audioStreamIndex !== null && audioStreamIndex !== void 0 ? audioStreamIndex : 0,
76
77
  });
77
78
  return () => unregisterRenderAsset(id);
78
79
  }, [
@@ -87,6 +88,7 @@ const VideoForRenderingForwardFunction = ({ onError, volume: volumeProp, allowAm
87
88
  playbackRate,
88
89
  toneFrequency,
89
90
  sequenceContext === null || sequenceContext === void 0 ? void 0 : sequenceContext.relativeFrom,
91
+ audioStreamIndex,
90
92
  ]);
91
93
  (0, react_1.useImperativeHandle)(ref, () => {
92
94
  return videoRef.current;
@@ -39,6 +39,7 @@ export type RemotionVideoProps = NativeVideoProps & {
39
39
  delayRenderRetries?: number;
40
40
  onError?: (err: Error) => void;
41
41
  onAutoPlayError?: null | (() => void);
42
+ audioStreamIndex?: number;
42
43
  };
43
44
  type DeprecatedOffthreadVideoProps = {
44
45
  /**
@@ -74,6 +75,7 @@ export type RemotionOffthreadVideoProps = {
74
75
  onAutoPlayError?: null | (() => void);
75
76
  onVideoFrame?: OnVideoFrame;
76
77
  crossOrigin?: '' | 'anonymous' | 'use-credentials';
78
+ audioStreamIndex?: number;
77
79
  } & RemotionMainVideoProps & DeprecatedOffthreadVideoProps;
78
80
  export type OnVideoFrame = (frame: CanvasImageSource) => void;
79
81
  export {};
@@ -104,7 +104,7 @@ function truthy(value) {
104
104
  }
105
105
 
106
106
  // src/version.ts
107
- var VERSION = "4.0.339";
107
+ var VERSION = "4.0.340";
108
108
 
109
109
  // src/multiple-versions-warning.ts
110
110
  var checkMultipleRemotionVersions = () => {
@@ -1325,6 +1325,7 @@ var RegularSequenceRefForwardingFunction = ({
1325
1325
  _remotionInternalLoopDisplay: loopDisplay,
1326
1326
  _remotionInternalStack: stack,
1327
1327
  _remotionInternalPremountDisplay: premountDisplay,
1328
+ _remotionInternalPostmountDisplay: postmountDisplay,
1328
1329
  ...other
1329
1330
  }, ref) => {
1330
1331
  const { layout = "absolute-fill" } = other;
@@ -1360,6 +1361,9 @@ var RegularSequenceRefForwardingFunction = ({
1360
1361
  const premounting = useMemo9(() => {
1361
1362
  return parentSequence?.premounting || Boolean(other._remotionInternalIsPremounting);
1362
1363
  }, [other._remotionInternalIsPremounting, parentSequence?.premounting]);
1364
+ const postmounting = useMemo9(() => {
1365
+ return parentSequence?.postmounting || Boolean(other._remotionInternalIsPostmounting);
1366
+ }, [other._remotionInternalIsPostmounting, parentSequence?.postmounting]);
1363
1367
  const contextValue = useMemo9(() => {
1364
1368
  return {
1365
1369
  cumulatedFrom,
@@ -1369,7 +1373,8 @@ var RegularSequenceRefForwardingFunction = ({
1369
1373
  id,
1370
1374
  height: height ?? parentSequence?.height ?? null,
1371
1375
  width: width ?? parentSequence?.width ?? null,
1372
- premounting
1376
+ premounting,
1377
+ postmounting
1373
1378
  };
1374
1379
  }, [
1375
1380
  cumulatedFrom,
@@ -1379,7 +1384,8 @@ var RegularSequenceRefForwardingFunction = ({
1379
1384
  id,
1380
1385
  height,
1381
1386
  width,
1382
- premounting
1387
+ premounting,
1388
+ postmounting
1383
1389
  ]);
1384
1390
  const timelineClipName = useMemo9(() => {
1385
1391
  return name ?? "";
@@ -1400,7 +1406,8 @@ var RegularSequenceRefForwardingFunction = ({
1400
1406
  nonce,
1401
1407
  loopDisplay,
1402
1408
  stack: stack ?? null,
1403
- premountDisplay: premountDisplay ?? null
1409
+ premountDisplay: premountDisplay ?? null,
1410
+ postmountDisplay: postmountDisplay ?? null
1404
1411
  });
1405
1412
  return () => {
1406
1413
  unregisterSequence(id);
@@ -1420,7 +1427,8 @@ var RegularSequenceRefForwardingFunction = ({
1420
1427
  nonce,
1421
1428
  loopDisplay,
1422
1429
  stack,
1423
- premountDisplay
1430
+ premountDisplay,
1431
+ postmountDisplay
1424
1432
  ]);
1425
1433
  const endThreshold = Math.ceil(cumulatedFrom + from + durationInFrames - 1);
1426
1434
  const content = absoluteFrame < cumulatedFrom + from ? null : absoluteFrame > endThreshold ? null : children;
@@ -1451,47 +1459,66 @@ var RegularSequenceRefForwardingFunction = ({
1451
1459
  });
1452
1460
  };
1453
1461
  var RegularSequence = forwardRef2(RegularSequenceRefForwardingFunction);
1454
- var PremountedSequenceRefForwardingFunction = (props, ref) => {
1462
+ var PremountedPostmountedSequenceRefForwardingFunction = (props, ref) => {
1455
1463
  const frame = useCurrentFrame();
1456
1464
  if (props.layout === "none") {
1457
- throw new Error('`<Sequence>` with `premountFor` prop does not support layout="none"');
1465
+ throw new Error('`<Sequence>` with `premountFor` and `postmountFor` props does not support layout="none"');
1458
1466
  }
1459
1467
  const {
1460
1468
  style: passedStyle,
1461
1469
  from = 0,
1470
+ durationInFrames = Infinity,
1462
1471
  premountFor = 0,
1472
+ postmountFor = 0,
1463
1473
  styleWhilePremounted,
1474
+ styleWhilePostmounted,
1464
1475
  ...otherProps
1465
1476
  } = props;
1477
+ const endThreshold = Math.ceil(from + durationInFrames - 1);
1466
1478
  const premountingActive = frame < from && frame >= from - premountFor;
1479
+ const postmountingActive = frame > endThreshold && frame <= endThreshold + postmountFor;
1480
+ const freezeFrame = premountingActive ? from : postmountingActive ? from + durationInFrames - 1 : 0;
1481
+ const isFreezingActive = premountingActive || postmountingActive;
1467
1482
  const style = useMemo9(() => {
1468
1483
  return {
1469
1484
  ...passedStyle,
1470
- opacity: premountingActive ? 0 : 1,
1471
- pointerEvents: premountingActive ? "none" : passedStyle?.pointerEvents ?? undefined,
1472
- ...premountingActive ? styleWhilePremounted : {}
1485
+ opacity: premountingActive || postmountingActive ? 0 : 1,
1486
+ pointerEvents: premountingActive || postmountingActive ? "none" : passedStyle?.pointerEvents ?? undefined,
1487
+ ...premountingActive ? styleWhilePremounted : {},
1488
+ ...postmountingActive ? styleWhilePostmounted : {}
1473
1489
  };
1474
- }, [passedStyle, premountingActive, styleWhilePremounted]);
1490
+ }, [
1491
+ passedStyle,
1492
+ premountingActive,
1493
+ postmountingActive,
1494
+ styleWhilePremounted,
1495
+ styleWhilePostmounted
1496
+ ]);
1475
1497
  return /* @__PURE__ */ jsx8(Freeze, {
1476
- frame: from,
1477
- active: premountingActive,
1498
+ frame: freezeFrame,
1499
+ active: isFreezingActive,
1478
1500
  children: /* @__PURE__ */ jsx8(Sequence, {
1479
1501
  ref,
1480
1502
  from,
1503
+ durationInFrames,
1481
1504
  style,
1482
1505
  _remotionInternalPremountDisplay: premountFor,
1506
+ _remotionInternalPostmountDisplay: postmountFor,
1483
1507
  _remotionInternalIsPremounting: premountingActive,
1508
+ _remotionInternalIsPostmounting: postmountingActive,
1484
1509
  ...otherProps
1485
1510
  })
1486
1511
  });
1487
1512
  };
1488
- var PremountedSequence = forwardRef2(PremountedSequenceRefForwardingFunction);
1513
+ var PremountedPostmountedSequence = forwardRef2(PremountedPostmountedSequenceRefForwardingFunction);
1489
1514
  var SequenceRefForwardingFunction = (props, ref) => {
1490
- if (props.layout !== "none" && props.premountFor && !getRemotionEnvironment().isRendering) {
1491
- return /* @__PURE__ */ jsx8(PremountedSequence, {
1492
- ...props,
1493
- ref
1494
- });
1515
+ if (props.layout !== "none" && !getRemotionEnvironment().isRendering) {
1516
+ if (props.premountFor || props.postmountFor) {
1517
+ return /* @__PURE__ */ jsx8(PremountedPostmountedSequence, {
1518
+ ...props,
1519
+ ref
1520
+ });
1521
+ }
1495
1522
  }
1496
1523
  return /* @__PURE__ */ jsx8(RegularSequence, {
1497
1524
  ...props,
@@ -3321,8 +3348,10 @@ var useMediaInTimeline = ({
3321
3348
  stack,
3322
3349
  showInTimeline,
3323
3350
  premountDisplay,
3351
+ postmountDisplay,
3324
3352
  onAutoPlayError,
3325
- isPremounting
3353
+ isPremounting,
3354
+ isPostmounting
3326
3355
  }) => {
3327
3356
  const videoConfig = useVideoConfig();
3328
3357
  const { rootId, audioAndVideoTags } = useContext17(TimelineContext);
@@ -3384,7 +3413,8 @@ var useMediaInTimeline = ({
3384
3413
  loopDisplay: undefined,
3385
3414
  playbackRate,
3386
3415
  stack,
3387
- premountDisplay
3416
+ premountDisplay,
3417
+ postmountDisplay
3388
3418
  });
3389
3419
  return () => {
3390
3420
  unregisterSequence(id);
@@ -3409,7 +3439,8 @@ var useMediaInTimeline = ({
3409
3439
  displayName,
3410
3440
  stack,
3411
3441
  showInTimeline,
3412
- premountDisplay
3442
+ premountDisplay,
3443
+ postmountDisplay
3413
3444
  ]);
3414
3445
  useEffect8(() => {
3415
3446
  const tag = {
@@ -3418,7 +3449,7 @@ var useMediaInTimeline = ({
3418
3449
  if (!imperativePlaying.current) {
3419
3450
  return;
3420
3451
  }
3421
- if (isPremounting) {
3452
+ if (isPremounting || isPostmounting) {
3422
3453
  return;
3423
3454
  }
3424
3455
  return playAndHandleNotAllowedError({
@@ -3443,6 +3474,7 @@ var useMediaInTimeline = ({
3443
3474
  onAutoPlayError,
3444
3475
  imperativePlaying,
3445
3476
  isPremounting,
3477
+ isPostmounting,
3446
3478
  logLevel,
3447
3479
  mountTime
3448
3480
  ]);
@@ -3722,6 +3754,7 @@ var useMediaBuffering = ({
3722
3754
  element,
3723
3755
  shouldBuffer,
3724
3756
  isPremounting,
3757
+ isPostmounting,
3725
3758
  logLevel,
3726
3759
  mountTime,
3727
3760
  src
@@ -3737,8 +3770,8 @@ var useMediaBuffering = ({
3737
3770
  if (!shouldBuffer) {
3738
3771
  return;
3739
3772
  }
3740
- if (isPremounting) {
3741
- if (current.readyState < current.HAVE_FUTURE_DATA) {
3773
+ if (isPremounting || isPostmounting) {
3774
+ if ((isPremounting || isPostmounting) && current.readyState < current.HAVE_FUTURE_DATA) {
3742
3775
  if (!navigator.userAgent.includes("Firefox/")) {
3743
3776
  playbackLogging({
3744
3777
  logLevel,
@@ -3842,7 +3875,16 @@ var useMediaBuffering = ({
3842
3875
  return () => {
3843
3876
  cleanup("element was unmounted or prop changed");
3844
3877
  };
3845
- }, [buffer, src, element, isPremounting, logLevel, shouldBuffer, mountTime]);
3878
+ }, [
3879
+ buffer,
3880
+ src,
3881
+ element,
3882
+ isPremounting,
3883
+ isPostmounting,
3884
+ logLevel,
3885
+ shouldBuffer,
3886
+ mountTime
3887
+ ]);
3846
3888
  return isBuffering;
3847
3889
  };
3848
3890
 
@@ -4080,6 +4122,7 @@ var useMediaPlayback = ({
4080
4122
  acceptableTimeshift,
4081
4123
  pauseWhenBuffering,
4082
4124
  isPremounting,
4125
+ isPostmounting,
4083
4126
  onAutoPlayError
4084
4127
  }) => {
4085
4128
  const { playbackRate: globalPlaybackRate } = useContext20(TimelineContext);
@@ -4124,6 +4167,7 @@ var useMediaPlayback = ({
4124
4167
  element: mediaRef,
4125
4168
  shouldBuffer: pauseWhenBuffering,
4126
4169
  isPremounting,
4170
+ isPostmounting,
4127
4171
  logLevel,
4128
4172
  mountTime,
4129
4173
  src: src ?? null
@@ -4155,7 +4199,7 @@ var useMediaPlayback = ({
4155
4199
  playbackLogging({
4156
4200
  logLevel,
4157
4201
  tag: "pause",
4158
- message: `Pausing ${mediaRef.current?.src} because ${isPremounting ? "media is premounting" : "Player is not playing"}`,
4202
+ message: `Pausing ${mediaRef.current?.src} because ${isPremounting ? "media is premounting" : isPostmounting ? "media is postmounting" : "Player is not playing"}`,
4159
4203
  mountTime
4160
4204
  });
4161
4205
  mediaRef.current?.pause();
@@ -4182,7 +4226,8 @@ var useMediaPlayback = ({
4182
4226
  mediaRef,
4183
4227
  mediaType,
4184
4228
  mountTime,
4185
- playing
4229
+ playing,
4230
+ isPostmounting
4186
4231
  ]);
4187
4232
  useLayoutEffect5(() => {
4188
4233
  const playbackRateToSet = Math.max(0, playbackRate);
@@ -4212,7 +4257,7 @@ var useMediaPlayback = ({
4212
4257
  mediaRef: mediaRef.current,
4213
4258
  time: shouldBeTime,
4214
4259
  logLevel,
4215
- why: `because time shift is too big. shouldBeTime = ${shouldBeTime}, isTime = ${mediaTagTime}, requestVideoCallbackTime = ${rvcTime}, timeShift = ${timeShift}${isVariableFpsVideo ? ", isVariableFpsVideo = true" : ""}, isPremounting = ${isPremounting}, pauseWhenBuffering = ${pauseWhenBuffering}`,
4260
+ why: `because time shift is too big. shouldBeTime = ${shouldBeTime}, isTime = ${mediaTagTime}, requestVideoCallbackTime = ${rvcTime}, timeShift = ${timeShift}${isVariableFpsVideo ? ", isVariableFpsVideo = true" : ""}, isPremounting = ${isPremounting}, isPostmounting = ${isPostmounting}, pauseWhenBuffering = ${pauseWhenBuffering}`,
4216
4261
  mountTime
4217
4262
  });
4218
4263
  lastSeekDueToShift.current = lastSeek.current;
@@ -4298,6 +4343,7 @@ var useMediaPlayback = ({
4298
4343
  src,
4299
4344
  onAutoPlayError,
4300
4345
  isPremounting,
4346
+ isPostmounting,
4301
4347
  pauseWhenBuffering,
4302
4348
  mountTime,
4303
4349
  mediaTagCurrentTime
@@ -4365,6 +4411,7 @@ var AudioForDevelopmentForwardRefFunction = (props, ref) => {
4365
4411
  useWebAudioApi,
4366
4412
  onError,
4367
4413
  onNativeError,
4414
+ audioStreamIndex,
4368
4415
  ...nativeProps
4369
4416
  } = props;
4370
4417
  const _propsValid = true;
@@ -4438,8 +4485,10 @@ var AudioForDevelopmentForwardRefFunction = (props, ref) => {
4438
4485
  stack: _remotionInternalStack,
4439
4486
  showInTimeline,
4440
4487
  premountDisplay: null,
4488
+ postmountDisplay: null,
4441
4489
  onAutoPlayError: null,
4442
- isPremounting: Boolean(sequenceContext?.premounting)
4490
+ isPremounting: Boolean(sequenceContext?.premounting),
4491
+ isPostmounting: Boolean(sequenceContext?.postmounting)
4443
4492
  });
4444
4493
  useMediaPlayback({
4445
4494
  mediaRef: audioRef,
@@ -4449,6 +4498,7 @@ var AudioForDevelopmentForwardRefFunction = (props, ref) => {
4449
4498
  onlyWarnForMediaSeekingError: false,
4450
4499
  acceptableTimeshift: acceptableTimeShiftInSeconds ?? null,
4451
4500
  isPremounting: Boolean(sequenceContext?.premounting),
4501
+ isPostmounting: Boolean(sequenceContext?.postmounting),
4452
4502
  pauseWhenBuffering,
4453
4503
  onAutoPlayError: null
4454
4504
  });
@@ -4521,6 +4571,7 @@ var AudioForRenderingRefForwardingFunction = (props, ref) => {
4521
4571
  delayRenderTimeoutInMilliseconds,
4522
4572
  loopVolumeCurveBehavior,
4523
4573
  pauseWhenBuffering,
4574
+ audioStreamIndex,
4524
4575
  ...nativeProps
4525
4576
  } = props;
4526
4577
  const absoluteFrame = useTimelinePosition();
@@ -4564,7 +4615,8 @@ var AudioForRenderingRefForwardingFunction = (props, ref) => {
4564
4615
  mediaFrame: frame,
4565
4616
  playbackRate: props.playbackRate ?? 1,
4566
4617
  toneFrequency: toneFrequency ?? null,
4567
- audioStartFrame: Math.max(0, -(sequenceContext?.relativeFrom ?? 0))
4618
+ audioStartFrame: Math.max(0, -(sequenceContext?.relativeFrom ?? 0)),
4619
+ audioStreamIndex: audioStreamIndex ?? 0
4568
4620
  });
4569
4621
  return () => unregisterRenderAsset(id);
4570
4622
  }, [
@@ -4580,7 +4632,8 @@ var AudioForRenderingRefForwardingFunction = (props, ref) => {
4580
4632
  playbackRate,
4581
4633
  props.playbackRate,
4582
4634
  toneFrequency,
4583
- sequenceContext?.relativeFrom
4635
+ sequenceContext?.relativeFrom,
4636
+ audioStreamIndex
4584
4637
  ]);
4585
4638
  const { src } = props;
4586
4639
  const needsToRenderAudioTag = ref || _remotionInternalNeedsDurationCalculation;
@@ -5381,6 +5434,7 @@ var ImgRefForwarding = ({
5381
5434
  }, [maxRetries, onError, retryIn]);
5382
5435
  if (typeof window !== "undefined") {
5383
5436
  const isPremounting = Boolean(sequenceContext?.premounting);
5437
+ const isPostmounting = Boolean(sequenceContext?.postmounting);
5384
5438
  useLayoutEffect7(() => {
5385
5439
  if (window.process?.env?.NODE_ENV === "test") {
5386
5440
  if (imageRef.current) {
@@ -5396,7 +5450,7 @@ var ImgRefForwarding = ({
5396
5450
  retries: delayRenderRetries ?? undefined,
5397
5451
  timeoutInMilliseconds: delayRenderTimeoutInMilliseconds ?? undefined
5398
5452
  });
5399
- const unblock = pauseWhenLoading && !isPremounting ? delayPlayback().unblock : () => {
5453
+ const unblock = pauseWhenLoading && !isPremounting && !isPostmounting ? delayPlayback().unblock : () => {
5400
5454
  return;
5401
5455
  };
5402
5456
  let unmounted = false;
@@ -5445,6 +5499,7 @@ var ImgRefForwarding = ({
5445
5499
  delayRenderTimeoutInMilliseconds,
5446
5500
  pauseWhenLoading,
5447
5501
  isPremounting,
5502
+ isPostmounting,
5448
5503
  onImageFrame
5449
5504
  ]);
5450
5505
  }
@@ -5969,6 +6024,7 @@ var VideoForDevelopmentRefForwardingFunction = (props2, ref) => {
5969
6024
  delayRenderTimeoutInMilliseconds,
5970
6025
  allowAmplificationDuringRender,
5971
6026
  useWebAudioApi,
6027
+ audioStreamIndex,
5972
6028
  ...nativeProps
5973
6029
  } = props2;
5974
6030
  const _propsValid = true;
@@ -6005,8 +6061,10 @@ var VideoForDevelopmentRefForwardingFunction = (props2, ref) => {
6005
6061
  stack: _remotionInternalStack,
6006
6062
  showInTimeline,
6007
6063
  premountDisplay: null,
6064
+ postmountDisplay: null,
6008
6065
  onAutoPlayError: onAutoPlayError ?? null,
6009
- isPremounting: Boolean(parentSequence?.premounting)
6066
+ isPremounting: Boolean(parentSequence?.premounting),
6067
+ isPostmounting: Boolean(parentSequence?.postmounting)
6010
6068
  });
6011
6069
  useMediaPlayback({
6012
6070
  mediaRef: videoRef,
@@ -6016,6 +6074,7 @@ var VideoForDevelopmentRefForwardingFunction = (props2, ref) => {
6016
6074
  onlyWarnForMediaSeekingError,
6017
6075
  acceptableTimeshift: acceptableTimeShiftInSeconds ?? null,
6018
6076
  isPremounting: Boolean(parentSequence?.premounting),
6077
+ isPostmounting: Boolean(parentSequence?.postmounting),
6019
6078
  pauseWhenBuffering,
6020
6079
  onAutoPlayError: onAutoPlayError ?? null
6021
6080
  });
@@ -7187,6 +7246,7 @@ var OffthreadVideoForRendering = ({
7187
7246
  delayRenderTimeoutInMilliseconds,
7188
7247
  onVideoFrame,
7189
7248
  crossOrigin,
7249
+ audioStreamIndex,
7190
7250
  ...props2
7191
7251
  }) => {
7192
7252
  const absoluteFrame = useTimelinePosition();
@@ -7235,7 +7295,8 @@ var OffthreadVideoForRendering = ({
7235
7295
  mediaFrame: frame,
7236
7296
  playbackRate: playbackRate ?? 1,
7237
7297
  toneFrequency: toneFrequency ?? null,
7238
- audioStartFrame: Math.max(0, -(sequenceContext?.relativeFrom ?? 0))
7298
+ audioStartFrame: Math.max(0, -(sequenceContext?.relativeFrom ?? 0)),
7299
+ audioStreamIndex: audioStreamIndex ?? 0
7239
7300
  });
7240
7301
  return () => unregisterRenderAsset(id);
7241
7302
  }, [
@@ -7249,7 +7310,8 @@ var OffthreadVideoForRendering = ({
7249
7310
  absoluteFrame,
7250
7311
  playbackRate,
7251
7312
  toneFrequency,
7252
- sequenceContext?.relativeFrom
7313
+ sequenceContext?.relativeFrom,
7314
+ audioStreamIndex
7253
7315
  ]);
7254
7316
  const currentTime = useMemo29(() => {
7255
7317
  return getExpectedMediaFrameUncorrected({
@@ -7591,6 +7653,7 @@ var VideoForRenderingForwardFunction = ({
7591
7653
  delayRenderRetries,
7592
7654
  delayRenderTimeoutInMilliseconds,
7593
7655
  loopVolumeCurveBehavior,
7656
+ audioStreamIndex,
7594
7657
  ...props2
7595
7658
  }, ref) => {
7596
7659
  const absoluteFrame = useTimelinePosition();
@@ -7640,7 +7703,8 @@ var VideoForRenderingForwardFunction = ({
7640
7703
  mediaFrame: frame,
7641
7704
  playbackRate: playbackRate ?? 1,
7642
7705
  toneFrequency: toneFrequency ?? null,
7643
- audioStartFrame: Math.max(0, -(sequenceContext?.relativeFrom ?? 0))
7706
+ audioStartFrame: Math.max(0, -(sequenceContext?.relativeFrom ?? 0)),
7707
+ audioStreamIndex: audioStreamIndex ?? 0
7644
7708
  });
7645
7709
  return () => unregisterRenderAsset(id);
7646
7710
  }, [
@@ -7654,7 +7718,8 @@ var VideoForRenderingForwardFunction = ({
7654
7718
  absoluteFrame,
7655
7719
  playbackRate,
7656
7720
  toneFrequency,
7657
- sequenceContext?.relativeFrom
7721
+ sequenceContext?.relativeFrom,
7722
+ audioStreamIndex
7658
7723
  ]);
7659
7724
  useImperativeHandle10(ref, () => {
7660
7725
  return videoRef.current;
@@ -1,5 +1,5 @@
1
1
  // src/version.ts
2
- var VERSION = "4.0.339";
2
+ var VERSION = "4.0.340";
3
3
  export {
4
4
  VERSION
5
5
  };
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "url": "https://github.com/remotion-dev/remotion/tree/main/packages/core"
4
4
  },
5
5
  "name": "remotion",
6
- "version": "4.0.339",
6
+ "version": "4.0.340",
7
7
  "description": "Make videos programmatically",
8
8
  "main": "dist/cjs/index.js",
9
9
  "types": "dist/cjs/index.d.ts",
@@ -28,7 +28,7 @@
28
28
  "webpack": "5.96.1",
29
29
  "zod": "3.22.3",
30
30
  "eslint": "9.19.0",
31
- "@remotion/eslint-config-internal": "4.0.339"
31
+ "@remotion/eslint-config-internal": "4.0.340"
32
32
  },
33
33
  "keywords": [
34
34
  "video",