@remotion/media 4.0.455 → 4.0.457

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.
@@ -37,20 +37,53 @@ var __callDispose = (stack, error, hasError) => {
37
37
  };
38
38
 
39
39
  // src/audio/audio.tsx
40
- import { Internals as Internals17, Sequence, useRemotionEnvironment as useRemotionEnvironment2 } from "remotion";
40
+ import { useState as useState3 } from "react";
41
+ import { useMemo as useMemo3 } from "react";
42
+ import {
43
+ useVideoConfig as useVideoConfig2
44
+ } from "remotion";
45
+ import { Internals as Internals16, Sequence, useRemotionEnvironment as useRemotionEnvironment2 } from "remotion";
46
+
47
+ // src/show-in-timeline.ts
48
+ import { Internals } from "remotion";
49
+ var getLoopDisplay = ({
50
+ loop,
51
+ mediaDurationInSeconds,
52
+ playbackRate,
53
+ trimAfter,
54
+ trimBefore,
55
+ sequenceDurationInFrames,
56
+ compFps
57
+ }) => {
58
+ if (!loop || !mediaDurationInSeconds) {
59
+ return;
60
+ }
61
+ const durationInFrames = Internals.calculateMediaDuration({
62
+ mediaDurationInFrames: mediaDurationInSeconds * compFps,
63
+ playbackRate,
64
+ trimAfter,
65
+ trimBefore
66
+ });
67
+ const maxTimes = sequenceDurationInFrames / durationInFrames;
68
+ return {
69
+ numberOfTimes: maxTimes,
70
+ startOffset: 0,
71
+ durationInFrames
72
+ };
73
+ };
41
74
 
42
75
  // src/audio/audio-for-preview.tsx
43
- import { useContext as useContext3, useEffect as useEffect2, useMemo as useMemo2, useRef, useState as useState2 } from "react";
76
+ import { useContext as useContext2, useEffect, useMemo, useRef, useState } from "react";
44
77
  import {
45
- Internals as Internals8,
78
+ Internals as Internals7,
46
79
  Audio as RemotionAudio,
47
80
  useBufferState,
48
81
  useCurrentFrame,
49
- useVideoConfig as useVideoConfig2
82
+ useVideoConfig
50
83
  } from "remotion";
51
84
 
52
85
  // src/get-time-in-seconds.ts
53
- import { Internals } from "remotion";
86
+ import { Internals as Internals2 } from "remotion";
54
87
  var getTimeInSeconds = ({
55
88
  loop,
56
89
  mediaDurationInSeconds,
@@ -65,7 +98,7 @@ var getTimeInSeconds = ({
65
98
  if (mediaDurationInSeconds === null && loop && ifNoMediaDuration === "fail") {
66
99
  throw new Error(`Could not determine duration of ${src}, but "loop" was set.`);
67
100
  }
68
- const loopDuration = loop ? Internals.calculateMediaDuration({
101
+ const loopDuration = loop ? Internals2.calculateMediaDuration({
69
102
  trimAfter,
70
103
  mediaDurationInFrames: mediaDurationInSeconds ? mediaDurationInSeconds * fps : Infinity,
71
104
  playbackRate: 1,
@@ -91,7 +124,7 @@ var calculateEndTime = ({
91
124
  if (mediaDurationInSeconds === null && ifNoMediaDuration === "fail") {
92
125
  throw new Error(`Could not determine duration of ${src}, but "loop" was set.`);
93
126
  }
94
- const mediaDuration = Internals.calculateMediaDuration({
127
+ const mediaDuration = Internals2.calculateMediaDuration({
95
128
  trimAfter,
96
129
  mediaDurationInFrames: mediaDurationInSeconds ? mediaDurationInSeconds * fps : Infinity,
97
130
  playbackRate: 1,
@@ -102,11 +135,11 @@ var calculateEndTime = ({
102
135
 
103
136
  // src/media-player.ts
104
137
  import { ALL_FORMATS, Input, UrlSource } from "mediabunny";
105
- import { Internals as Internals4 } from "remotion";
138
+ import { Internals as Internals5 } from "remotion";
106
139
 
107
140
  // src/audio-iterator-manager.ts
108
141
  import { AudioBufferSink, InputDisposedError } from "mediabunny";
109
- import { Internals as Internals2 } from "remotion";
142
+ import { Internals as Internals3 } from "remotion";
110
143
 
111
144
  // src/make-iterator-with-priming.ts
112
145
  var AUDIO_PRIMING_SECONDS = 0.5;
@@ -451,7 +484,7 @@ var audioIteratorManager = ({
451
484
  node.connect(gainNode);
452
485
  const started = scheduleAudioNode(node, mediaTimestamp, originalUnloopedMediaTimestamp, currentTime);
453
486
  if (started.type === "not-started") {
454
- Internals2.Log.verbose({ logLevel, tag: "audio-scheduling" }, "not started, disconnected: %s %s", mediaTimestamp.toFixed(3), buffer.duration.toFixed(3));
487
+ Internals3.Log.verbose({ logLevel, tag: "audio-scheduling" }, "not started, disconnected: %s %s", mediaTimestamp.toFixed(3), buffer.duration.toFixed(3));
455
488
  node.disconnect();
456
489
  return;
457
490
  }
@@ -808,7 +841,7 @@ var makeNonceManager = () => {
808
841
 
809
842
  // src/video-iterator-manager.ts
810
843
  import { CanvasSink } from "mediabunny";
811
- import { Internals as Internals3 } from "remotion";
844
+ import { Internals as Internals4 } from "remotion";
812
845
 
813
846
  // src/canvas-ahead-of-time.ts
814
847
  var canvasesAheadOfTime = (videoSink, startTimestamp) => {
@@ -1035,7 +1068,7 @@ var createVideoIterator = async (timeToSeek, cache) => {
1035
1068
  };
1036
1069
 
1037
1070
  // src/video-iterator-manager.ts
1038
- var { runEffectChain } = Internals3;
1071
+ var { runEffectChain } = Internals4;
1039
1072
  var videoIteratorManager = async ({
1040
1073
  delayPlaybackHandleIfNotPremounting,
1041
1074
  canvas,
@@ -1094,7 +1127,7 @@ var videoIteratorManager = async ({
1094
1127
  if (callback) {
1095
1128
  callback(frame.canvas);
1096
1129
  }
1097
- Internals3.Log.trace({ logLevel, tag: "@remotion/media" }, `[MediaPlayer] Drew frame ${frame.timestamp.toFixed(3)}s`);
1130
+ Internals4.Log.trace({ logLevel, tag: "@remotion/media" }, `[MediaPlayer] Drew frame ${frame.timestamp.toFixed(3)}s`);
1098
1131
  };
1099
1132
  const startVideoIterator = async (timeToSeek, nonce) => {
1100
1133
  let __stack = [];
@@ -1318,7 +1351,7 @@ class MediaPlayer {
1318
1351
  if (isNetworkError(err)) {
1319
1352
  throw error;
1320
1353
  }
1321
- Internals4.Log.error({ logLevel: this.logLevel, tag: "@remotion/media" }, `[MediaPlayer] Failed to recognize format for ${this.src}`, error);
1354
+ Internals5.Log.error({ logLevel: this.logLevel, tag: "@remotion/media" }, `[MediaPlayer] Failed to recognize format for ${this.src}`, error);
1322
1355
  return { type: "unknown-container-format" };
1323
1356
  }
1324
1357
  const [durationInSeconds, videoTrack, audioTracks] = await Promise.all([
@@ -1425,16 +1458,16 @@ class MediaPlayer {
1425
1458
  if (this.isDisposalError()) {
1426
1459
  return { type: "disposed" };
1427
1460
  }
1428
- Internals4.Log.error({ logLevel: this.logLevel, tag: "@remotion/media" }, "[MediaPlayer] Failed to start audio and video iterators", error);
1461
+ Internals5.Log.error({ logLevel: this.logLevel, tag: "@remotion/media" }, "[MediaPlayer] Failed to start audio and video iterators", error);
1429
1462
  }
1430
1463
  return { type: "success", durationInSeconds };
1431
1464
  } catch (error) {
1432
1465
  const err = error;
1433
1466
  if (isNetworkError(err)) {
1434
- Internals4.Log.error({ logLevel: this.logLevel, tag: "@remotion/media" }, `[MediaPlayer] Network/CORS error for ${this.src}`, err);
1467
+ Internals5.Log.error({ logLevel: this.logLevel, tag: "@remotion/media" }, `[MediaPlayer] Network/CORS error for ${this.src}`, err);
1435
1468
  return { type: "network-error" };
1436
1469
  }
1437
- Internals4.Log.error({ logLevel: this.logLevel, tag: "@remotion/media" }, "[MediaPlayer] Failed to initialize", error);
1470
+ Internals5.Log.error({ logLevel: this.logLevel, tag: "@remotion/media" }, "[MediaPlayer] Failed to initialize", error);
1438
1471
  throw error;
1439
1472
  }
1440
1473
  } catch (_catch) {
@@ -1722,45 +1755,6 @@ var callOnErrorAndResolve = ({
1722
1755
  return ["fallback", error];
1723
1756
  };
1724
1757
 
1725
- // src/show-in-timeline.ts
1726
- import { useMemo } from "react";
1727
- import { Internals as Internals5, useVideoConfig } from "remotion";
1728
- var useLoopDisplay = ({
1729
- loop,
1730
- mediaDurationInSeconds,
1731
- playbackRate,
1732
- trimAfter,
1733
- trimBefore
1734
- }) => {
1735
- const { durationInFrames: compDuration, fps } = useVideoConfig();
1736
- const loopDisplay = useMemo(() => {
1737
- if (!loop || !mediaDurationInSeconds) {
1738
- return;
1739
- }
1740
- const durationInFrames = Internals5.calculateMediaDuration({
1741
- mediaDurationInFrames: mediaDurationInSeconds * fps,
1742
- playbackRate,
1743
- trimAfter,
1744
- trimBefore
1745
- });
1746
- const maxTimes = compDuration / durationInFrames;
1747
- return {
1748
- numberOfTimes: maxTimes,
1749
- startOffset: 0,
1750
- durationInFrames
1751
- };
1752
- }, [
1753
- compDuration,
1754
- fps,
1755
- loop,
1756
- mediaDurationInSeconds,
1757
- playbackRate,
1758
- trimAfter,
1759
- trimBefore
1760
- ]);
1761
- return loopDisplay;
1762
- };
1763
-
1764
1758
  // src/use-common-effects.ts
1765
1759
  import { useContext, useLayoutEffect } from "react";
1766
1760
  import { Internals as Internals6 } from "remotion";
@@ -1909,113 +1903,6 @@ var useCommonEffects = ({
1909
1903
  }, [currentTime, logLevel, mediaPlayerReady, label, mediaPlayerRef]);
1910
1904
  };
1911
1905
 
1912
- // src/use-media-in-timeline.ts
1913
- import { useContext as useContext2, useEffect, useState } from "react";
1914
- import { Internals as Internals7 } from "remotion";
1915
- var useMediaInTimeline = ({
1916
- volume,
1917
- mediaVolume,
1918
- src,
1919
- mediaType,
1920
- playbackRate,
1921
- displayName,
1922
- stack,
1923
- showInTimeline,
1924
- premountDisplay,
1925
- postmountDisplay,
1926
- loopDisplay,
1927
- trimBefore,
1928
- trimAfter,
1929
- controls,
1930
- _experimentalEffects
1931
- }) => {
1932
- const parentSequence = useContext2(Internals7.SequenceContext);
1933
- const startsAt = Internals7.useMediaStartsAt();
1934
- const { registerSequence, unregisterSequence } = useContext2(Internals7.SequenceManager);
1935
- const [mediaId] = useState(() => String(Math.random()));
1936
- const {
1937
- volumes,
1938
- duration,
1939
- doesVolumeChange,
1940
- nonce,
1941
- rootId,
1942
- isStudio,
1943
- finalDisplayName
1944
- } = Internals7.useBasicMediaInTimeline({
1945
- volume,
1946
- mediaVolume,
1947
- mediaType,
1948
- src,
1949
- displayName,
1950
- trimBefore,
1951
- trimAfter,
1952
- playbackRate
1953
- });
1954
- useEffect(() => {
1955
- if (!src) {
1956
- throw new Error("No src passed");
1957
- }
1958
- if (!isStudio && window.process?.env?.NODE_ENV !== "test") {
1959
- return;
1960
- }
1961
- if (!showInTimeline) {
1962
- return;
1963
- }
1964
- registerSequence({
1965
- type: mediaType,
1966
- src,
1967
- id: mediaId,
1968
- duration,
1969
- from: 0,
1970
- parent: parentSequence?.id ?? null,
1971
- displayName: finalDisplayName,
1972
- rootId,
1973
- volume: volumes,
1974
- showInTimeline: true,
1975
- nonce: nonce.get(),
1976
- startMediaFrom: 0 - startsAt + (trimBefore ?? 0),
1977
- doesVolumeChange,
1978
- loopDisplay,
1979
- playbackRate,
1980
- stack,
1981
- premountDisplay,
1982
- postmountDisplay,
1983
- controls: controls ?? null,
1984
- effects: _experimentalEffects
1985
- });
1986
- return () => {
1987
- unregisterSequence(mediaId);
1988
- };
1989
- }, [
1990
- controls,
1991
- doesVolumeChange,
1992
- duration,
1993
- finalDisplayName,
1994
- isStudio,
1995
- loopDisplay,
1996
- mediaId,
1997
- mediaType,
1998
- nonce,
1999
- parentSequence?.id,
2000
- playbackRate,
2001
- postmountDisplay,
2002
- premountDisplay,
2003
- registerSequence,
2004
- rootId,
2005
- showInTimeline,
2006
- src,
2007
- stack,
2008
- startsAt,
2009
- unregisterSequence,
2010
- volumes,
2011
- trimBefore,
2012
- _experimentalEffects
2013
- ]);
2014
- return {
2015
- id: mediaId
2016
- };
2017
- };
2018
-
2019
1906
  // src/audio/audio-for-preview.tsx
2020
1907
  import { jsx } from "react/jsx-runtime";
2021
1908
  var {
@@ -2029,7 +1916,7 @@ var {
2029
1916
  warnAboutTooHighVolume,
2030
1917
  usePreload,
2031
1918
  SequenceContext
2032
- } = Internals8;
1919
+ } = Internals7;
2033
1920
  var AudioForPreviewAssertedShowing = ({
2034
1921
  src,
2035
1922
  playbackRate,
@@ -2049,23 +1936,22 @@ var AudioForPreviewAssertedShowing = ({
2049
1936
  fallbackHtml5AudioProps,
2050
1937
  onError,
2051
1938
  credentials,
2052
- controls
1939
+ setMediaDurationInSeconds
2053
1940
  }) => {
2054
1941
  const videoConfig = useUnsafeVideoConfig();
2055
1942
  const frame = useCurrentFrame();
2056
1943
  const mediaPlayerRef = useRef(null);
2057
1944
  const initialTrimBeforeRef = useRef(trimBefore);
2058
1945
  const initialTrimAfterRef = useRef(trimAfter);
2059
- const [mediaPlayerReady, setMediaPlayerReady] = useState2(false);
2060
- const [shouldFallbackToNativeAudio, setShouldFallbackToNativeAudio] = useState2(false);
1946
+ const [mediaPlayerReady, setMediaPlayerReady] = useState(false);
1947
+ const [shouldFallbackToNativeAudio, setShouldFallbackToNativeAudio] = useState(false);
2061
1948
  const [playing] = Timeline.usePlayingState();
2062
- const timelineContext = Internals8.useTimelineContext();
1949
+ const timelineContext = Internals7.useTimelineContext();
2063
1950
  const globalPlaybackRate = timelineContext.playbackRate;
2064
- const sharedAudioContext = useContext3(SharedAudioContext);
1951
+ const sharedAudioContext = useContext2(SharedAudioContext);
2065
1952
  const buffer = useBufferState();
2066
1953
  const [mediaMuted] = useMediaMutedState();
2067
1954
  const [mediaVolume] = useMediaVolumeState();
2068
- const [mediaDurationInSeconds, setMediaDurationInSeconds] = useState2(null);
2069
1955
  const volumePropFrame = useFrameForVolumeProp(loopVolumeCurveBehavior ?? "repeat");
2070
1956
  const userPreferredVolume = evaluateVolume({
2071
1957
  frame: volumePropFrame,
@@ -2083,43 +1969,16 @@ var AudioForPreviewAssertedShowing = ({
2083
1969
  const currentTimeRef = useRef(currentTime);
2084
1970
  currentTimeRef.current = currentTime;
2085
1971
  const preloadedSrc = usePreload(src);
2086
- const parentSequence = useContext3(SequenceContext);
1972
+ const parentSequence = useContext2(SequenceContext);
2087
1973
  const isPremounting = Boolean(parentSequence?.premounting);
2088
1974
  const isPostmounting = Boolean(parentSequence?.postmounting);
2089
1975
  const sequenceOffset = ((parentSequence?.cumulatedFrom ?? 0) + (parentSequence?.relativeFrom ?? 0)) / videoConfig.fps;
2090
- const loopDisplay = useLoopDisplay({
2091
- loop,
2092
- mediaDurationInSeconds,
2093
- playbackRate,
2094
- trimAfter,
2095
- trimBefore
2096
- });
2097
- const effects = useMemo2(() => {
2098
- return [];
2099
- }, []);
2100
- useMediaInTimeline({
2101
- volume,
2102
- mediaVolume,
2103
- mediaType: "audio",
2104
- src,
2105
- playbackRate,
2106
- displayName: name ?? null,
2107
- stack,
2108
- showInTimeline,
2109
- premountDisplay: parentSequence?.premountDisplay ?? null,
2110
- postmountDisplay: parentSequence?.postmountDisplay ?? null,
2111
- loopDisplay,
2112
- trimAfter,
2113
- trimBefore,
2114
- controls,
2115
- _experimentalEffects: effects
2116
- });
2117
- const bufferingContext = useContext3(Internals8.BufferingContextReact);
1976
+ const bufferingContext = useContext2(Internals7.BufferingContextReact);
2118
1977
  if (!bufferingContext) {
2119
1978
  throw new Error("useMediaPlayback must be used inside a <BufferingContext>");
2120
1979
  }
2121
1980
  const effectiveMuted = muted || mediaMuted || userPreferredVolume <= 0;
2122
- const isPlayerBuffering = Internals8.useIsPlayerBuffering(bufferingContext);
1981
+ const isPlayerBuffering = Internals7.useIsPlayerBuffering(bufferingContext);
2123
1982
  const initialPlaying = useRef(playing && !isPlayerBuffering);
2124
1983
  const initialIsPremounting = useRef(isPremounting);
2125
1984
  const initialIsPostmounting = useRef(isPostmounting);
@@ -2151,7 +2010,7 @@ var AudioForPreviewAssertedShowing = ({
2151
2010
  logLevel,
2152
2011
  label: "AudioForPreview"
2153
2012
  });
2154
- useEffect2(() => {
2013
+ useEffect(() => {
2155
2014
  if (!sharedAudioContext)
2156
2015
  return;
2157
2016
  if (!sharedAudioContext.audioContext)
@@ -2215,7 +2074,7 @@ var AudioForPreviewAssertedShowing = ({
2215
2074
  if (action === "fail") {
2216
2075
  throw errorToUse;
2217
2076
  } else {
2218
- Internals8.Log.warn({ logLevel, tag: "@remotion/media" }, fallbackMessage);
2077
+ Internals7.Log.warn({ logLevel, tag: "@remotion/media" }, fallbackMessage);
2219
2078
  setShouldFallbackToNativeAudio(true);
2220
2079
  }
2221
2080
  };
@@ -2238,7 +2097,7 @@ var AudioForPreviewAssertedShowing = ({
2238
2097
  if (result.type === "success") {
2239
2098
  setMediaPlayerReady(true);
2240
2099
  setMediaDurationInSeconds(result.durationInSeconds);
2241
- Internals8.Log.trace({ logLevel, tag: "@remotion/media" }, `[AudioForPreview] MediaPlayer initialized successfully`);
2100
+ Internals7.Log.trace({ logLevel, tag: "@remotion/media" }, `[AudioForPreview] MediaPlayer initialized successfully`);
2242
2101
  }
2243
2102
  }).catch((error) => {
2244
2103
  const [action, errorToUse] = callOnErrorAndResolve({
@@ -2251,7 +2110,7 @@ var AudioForPreviewAssertedShowing = ({
2251
2110
  if (action === "fail") {
2252
2111
  throw errorToUse;
2253
2112
  } else {
2254
- Internals8.Log.error({ logLevel, tag: "@remotion/media" }, "[AudioForPreview] Failed to initialize MediaPlayer", error);
2113
+ Internals7.Log.error({ logLevel, tag: "@remotion/media" }, "[AudioForPreview] Failed to initialize MediaPlayer", error);
2255
2114
  setShouldFallbackToNativeAudio(true);
2256
2115
  }
2257
2116
  });
@@ -2266,12 +2125,12 @@ var AudioForPreviewAssertedShowing = ({
2266
2125
  if (action === "fail") {
2267
2126
  throw errorToUse;
2268
2127
  }
2269
- Internals8.Log.error({ logLevel, tag: "@remotion/media" }, "[AudioForPreview] MediaPlayer initialization failed", errorToUse);
2128
+ Internals7.Log.error({ logLevel, tag: "@remotion/media" }, "[AudioForPreview] MediaPlayer initialization failed", errorToUse);
2270
2129
  setShouldFallbackToNativeAudio(true);
2271
2130
  }
2272
2131
  return () => {
2273
2132
  if (mediaPlayerRef.current) {
2274
- Internals8.Log.trace({ logLevel, tag: "@remotion/media" }, `[AudioForPreview] Disposing MediaPlayer`);
2133
+ Internals7.Log.trace({ logLevel, tag: "@remotion/media" }, `[AudioForPreview] Disposing MediaPlayer`);
2275
2134
  mediaPlayerRef.current.dispose();
2276
2135
  mediaPlayerRef.current = null;
2277
2136
  }
@@ -2288,7 +2147,8 @@ var AudioForPreviewAssertedShowing = ({
2288
2147
  disallowFallbackToHtml5Audio,
2289
2148
  buffer,
2290
2149
  onError,
2291
- credentials
2150
+ credentials,
2151
+ setMediaDurationInSeconds
2292
2152
  ]);
2293
2153
  if (shouldFallbackToNativeAudio && !disallowFallbackToHtml5Audio) {
2294
2154
  return /* @__PURE__ */ jsx(RemotionAudio, {
@@ -2331,14 +2191,14 @@ var AudioForPreview = ({
2331
2191
  fallbackHtml5AudioProps,
2332
2192
  onError,
2333
2193
  credentials,
2334
- controls
2194
+ setMediaDurationInSeconds
2335
2195
  }) => {
2336
2196
  const preloadedSrc = usePreload(src);
2337
- const defaultLogLevel = Internals8.useLogLevel();
2197
+ const defaultLogLevel = Internals7.useLogLevel();
2338
2198
  const frame = useCurrentFrame();
2339
- const videoConfig = useVideoConfig2();
2199
+ const videoConfig = useVideoConfig();
2340
2200
  const currentTime = frame / videoConfig.fps;
2341
- const showShow = useMemo2(() => {
2201
+ const showShow = useMemo(() => {
2342
2202
  return getTimeInSeconds({
2343
2203
  unloopedTimeInSeconds: currentTime,
2344
2204
  playbackRate,
@@ -2362,6 +2222,9 @@ var AudioForPreview = ({
2362
2222
  if (!showShow) {
2363
2223
  return null;
2364
2224
  }
2225
+ if (!setMediaDurationInSeconds) {
2226
+ throw new Error("setMediaDurationInSeconds is required");
2227
+ }
2365
2228
  return /* @__PURE__ */ jsx(AudioForPreviewAssertedShowing, {
2366
2229
  audioStreamIndex,
2367
2230
  src: preloadedSrc,
@@ -2381,16 +2244,16 @@ var AudioForPreview = ({
2381
2244
  onError,
2382
2245
  credentials,
2383
2246
  fallbackHtml5AudioProps,
2384
- controls
2247
+ setMediaDurationInSeconds
2385
2248
  });
2386
2249
  };
2387
2250
 
2388
2251
  // src/audio/audio-for-rendering.tsx
2389
- import { useContext as useContext4, useLayoutEffect as useLayoutEffect2, useMemo as useMemo3, useState as useState3 } from "react";
2252
+ import { useContext as useContext3, useLayoutEffect as useLayoutEffect2, useMemo as useMemo2, useState as useState2 } from "react";
2390
2253
  import {
2391
2254
  cancelRender as cancelRender2,
2392
2255
  Html5Audio,
2393
- Internals as Internals16,
2256
+ Internals as Internals15,
2394
2257
  random,
2395
2258
  useCurrentFrame as useCurrentFrame2,
2396
2259
  useDelayRender,
@@ -2399,13 +2262,13 @@ import {
2399
2262
 
2400
2263
  // src/caches.ts
2401
2264
  import React2 from "react";
2402
- import { cancelRender, Internals as Internals13 } from "remotion";
2265
+ import { cancelRender, Internals as Internals12 } from "remotion";
2403
2266
 
2404
2267
  // src/audio-extraction/audio-manager.ts
2405
- import { Internals as Internals10 } from "remotion";
2268
+ import { Internals as Internals9 } from "remotion";
2406
2269
 
2407
2270
  // src/audio-extraction/audio-iterator.ts
2408
- import { Internals as Internals9 } from "remotion";
2271
+ import { Internals as Internals8 } from "remotion";
2409
2272
 
2410
2273
  // src/audio-extraction/audio-cache.ts
2411
2274
  var makeAudioCache = () => {
@@ -2484,7 +2347,7 @@ var warnAboutMatroskaOnce = (src, logLevel) => {
2484
2347
  return;
2485
2348
  }
2486
2349
  warned[src] = true;
2487
- Internals9.Log.warn({ logLevel, tag: "@remotion/media" }, `Audio from ${src} will need to be read from the beginning. https://www.remotion.dev/docs/media/support#matroska-limitation`);
2350
+ Internals8.Log.warn({ logLevel, tag: "@remotion/media" }, `Audio from ${src} will need to be read from the beginning. https://www.remotion.dev/docs/media/support#matroska-limitation`);
2488
2351
  };
2489
2352
  var makeAudioIterator2 = ({
2490
2353
  audioSampleSink,
@@ -2552,7 +2415,7 @@ var makeAudioIterator2 = ({
2552
2415
  if (openTimestamps.length > 0) {
2553
2416
  const first = openTimestamps[0];
2554
2417
  const last = openTimestamps[openTimestamps.length - 1];
2555
- Internals9.Log.verbose({ logLevel, tag: "@remotion/media" }, "Open audio samples for src", src, `${first.toFixed(3)}...${last.toFixed(3)}`);
2418
+ Internals8.Log.verbose({ logLevel, tag: "@remotion/media" }, "Open audio samples for src", src, `${first.toFixed(3)}...${last.toFixed(3)}`);
2556
2419
  }
2557
2420
  };
2558
2421
  const getCacheStats = () => {
@@ -2649,7 +2512,7 @@ var makeAudioManager = () => {
2649
2512
  if (seenKeys.has(key)) {
2650
2513
  iterator.prepareForDeletion();
2651
2514
  iterators.splice(iterators.indexOf(iterator), 1);
2652
- Internals10.Log.verbose({ logLevel, tag: "@remotion/media" }, `Deleted duplicate iterator for ${iterator.src}`);
2515
+ Internals9.Log.verbose({ logLevel, tag: "@remotion/media" }, `Deleted duplicate iterator for ${iterator.src}`);
2653
2516
  }
2654
2517
  seenKeys.add(key);
2655
2518
  }
@@ -2670,7 +2533,7 @@ var makeAudioManager = () => {
2670
2533
  attempts++;
2671
2534
  }
2672
2535
  if ((await getTotalCacheStats()).totalSize > maxCacheSize && attempts >= maxAttempts) {
2673
- Internals10.Log.warn({ logLevel, tag: "@remotion/media" }, `Audio cache: Exceeded max cache size after ${maxAttempts} attempts. Still ${(await getTotalCacheStats()).totalSize} bytes used, target was ${maxCacheSize} bytes.`);
2536
+ Internals9.Log.warn({ logLevel, tag: "@remotion/media" }, `Audio cache: Exceeded max cache size after ${maxAttempts} attempts. Still ${(await getTotalCacheStats()).totalSize} bytes used, target was ${maxCacheSize} bytes.`);
2674
2537
  }
2675
2538
  for (const iterator of iterators) {
2676
2539
  if (iterator.src === src && await iterator.waitForCompletion() && iterator.canSatisfyRequestedTime(timeInSeconds)) {
@@ -2739,7 +2602,7 @@ var makeAudioManager = () => {
2739
2602
  };
2740
2603
 
2741
2604
  // src/video-extraction/keyframe-manager.ts
2742
- import { Internals as Internals12 } from "remotion";
2605
+ import { Internals as Internals11 } from "remotion";
2743
2606
 
2744
2607
  // src/render-timestamp-range.ts
2745
2608
  var renderTimestampRange = (timestamps) => {
@@ -2753,7 +2616,7 @@ var renderTimestampRange = (timestamps) => {
2753
2616
  };
2754
2617
 
2755
2618
  // src/video-extraction/keyframe-bank.ts
2756
- import { Internals as Internals11 } from "remotion";
2619
+ import { Internals as Internals10 } from "remotion";
2757
2620
 
2758
2621
  // src/video-extraction/get-allocation-size.ts
2759
2622
  var getAllocationSize = (sample) => {
@@ -2816,7 +2679,7 @@ var makeKeyframeBank = async ({
2816
2679
  }
2817
2680
  }
2818
2681
  if (deletedTimestamps.length > 0) {
2819
- Internals11.Log.verbose({ logLevel, tag: "@remotion/media" }, `Deleted ${deletedTimestamps.length} frame${deletedTimestamps.length === 1 ? "" : "s"} ${renderTimestampRange(deletedTimestamps)} for src ${src} because it is lower than ${timestampInSeconds}. Remaining: ${renderTimestampRange(frameTimestamps)}`);
2682
+ Internals10.Log.verbose({ logLevel, tag: "@remotion/media" }, `Deleted ${deletedTimestamps.length} frame${deletedTimestamps.length === 1 ? "" : "s"} ${renderTimestampRange(deletedTimestamps)} for src ${src} because it is lower than ${timestampInSeconds}. Remaining: ${renderTimestampRange(frameTimestamps)}`);
2820
2683
  }
2821
2684
  };
2822
2685
  const hasDecodedEnoughForTimestamp = (timestamp) => {
@@ -2839,7 +2702,7 @@ var makeKeyframeBank = async ({
2839
2702
  frameTimestamps.push(frame.timestamp);
2840
2703
  allocationSize += getAllocationSize(frame);
2841
2704
  lastUsed = Date.now();
2842
- Internals11.Log.trace({ logLevel, tag: "@remotion/media" }, `Added frame at ${frame.timestamp}sec to bank`);
2705
+ Internals10.Log.trace({ logLevel, tag: "@remotion/media" }, `Added frame at ${frame.timestamp}sec to bank`);
2843
2706
  };
2844
2707
  const ensureEnoughFramesForTimestamp = async (timestampInSeconds, logLevel, fps) => {
2845
2708
  while (!hasDecodedEnoughForTimestamp(timestampInSeconds)) {
@@ -2894,7 +2757,7 @@ var makeKeyframeBank = async ({
2894
2757
  throw new Error("No first frame found");
2895
2758
  }
2896
2759
  const startTimestampInSeconds = firstFrame.value.timestamp;
2897
- Internals11.Log.verbose({ logLevel: parentLogLevel, tag: "@remotion/media" }, `Creating keyframe bank from ${startTimestampInSeconds}sec`);
2760
+ Internals10.Log.verbose({ logLevel: parentLogLevel, tag: "@remotion/media" }, `Creating keyframe bank from ${startTimestampInSeconds}sec`);
2898
2761
  addFrame(firstFrame.value, parentLogLevel);
2899
2762
  const getRangeOfTimestamps = () => {
2900
2763
  if (frameTimestamps.length === 0) {
@@ -2912,7 +2775,7 @@ var makeKeyframeBank = async ({
2912
2775
  const prepareForDeletion = (logLevel, reason) => {
2913
2776
  const range = getRangeOfTimestamps();
2914
2777
  if (range) {
2915
- Internals11.Log.verbose({ logLevel, tag: "@remotion/media" }, `Preparing for deletion (${reason}) of keyframe bank from ${range?.firstTimestamp}sec to ${range?.lastTimestamp}sec`);
2778
+ Internals10.Log.verbose({ logLevel, tag: "@remotion/media" }, `Preparing for deletion (${reason}) of keyframe bank from ${range?.firstTimestamp}sec to ${range?.lastTimestamp}sec`);
2916
2779
  }
2917
2780
  let framesDeleted = 0;
2918
2781
  for (const frameTimestamp of frameTimestamps.slice()) {
@@ -2985,10 +2848,10 @@ var makeKeyframeManager = () => {
2985
2848
  if (size === 0) {
2986
2849
  continue;
2987
2850
  }
2988
- Internals12.Log.verbose({ logLevel, tag: "@remotion/media" }, `Open frames for src ${src}: ${renderTimestampRange(timestamps)}`);
2851
+ Internals11.Log.verbose({ logLevel, tag: "@remotion/media" }, `Open frames for src ${src}: ${renderTimestampRange(timestamps)}`);
2989
2852
  }
2990
2853
  }
2991
- Internals12.Log.verbose({ logLevel, tag: "@remotion/media" }, `Video cache stats: ${count} open frames, ${totalSize} bytes`);
2854
+ Internals11.Log.verbose({ logLevel, tag: "@remotion/media" }, `Video cache stats: ${count} open frames, ${totalSize} bytes`);
2992
2855
  };
2993
2856
  const getCacheStats = () => {
2994
2857
  let count = 0;
@@ -3042,7 +2905,7 @@ var makeKeyframeManager = () => {
3042
2905
  const { framesDeleted } = mostInThePastBank.prepareForDeletion(logLevel, "deleted oldest keyframe bank to stay under max cache size");
3043
2906
  sources[mostInThePastSrc].splice(mostInThePastIndex, 1);
3044
2907
  if (range) {
3045
- Internals12.Log.verbose({ logLevel, tag: "@remotion/media" }, `Deleted ${framesDeleted} frames for src ${mostInThePastSrc} from ${range?.firstTimestamp}sec to ${range?.lastTimestamp}sec to free up memory.`);
2908
+ Internals11.Log.verbose({ logLevel, tag: "@remotion/media" }, `Deleted ${framesDeleted} frames for src ${mostInThePastSrc} from ${range?.firstTimestamp}sec to ${range?.lastTimestamp}sec to free up memory.`);
3046
2909
  }
3047
2910
  }
3048
2911
  return { finish: false };
@@ -3056,12 +2919,12 @@ var makeKeyframeManager = () => {
3056
2919
  if (finish) {
3057
2920
  break;
3058
2921
  }
3059
- Internals12.Log.verbose({ logLevel, tag: "@remotion/media" }, "Deleted oldest keyframe bank to stay under max cache size", (cacheStats.totalSize / 1024 / 1024).toFixed(1), "out of", (maxCacheSize / 1024 / 1024).toFixed(1));
2922
+ Internals11.Log.verbose({ logLevel, tag: "@remotion/media" }, "Deleted oldest keyframe bank to stay under max cache size", (cacheStats.totalSize / 1024 / 1024).toFixed(1), "out of", (maxCacheSize / 1024 / 1024).toFixed(1));
3060
2923
  cacheStats = getTotalCacheStats();
3061
2924
  attempts++;
3062
2925
  }
3063
2926
  if (cacheStats.totalSize > maxCacheSize && attempts >= maxAttempts) {
3064
- Internals12.Log.warn({ logLevel, tag: "@remotion/media" }, `Exceeded max cache size after ${maxAttempts} attempts. Remaining cache size: ${(cacheStats.totalSize / 1024 / 1024).toFixed(1)} MB, target was ${(maxCacheSize / 1024 / 1024).toFixed(1)} MB.`);
2927
+ Internals11.Log.warn({ logLevel, tag: "@remotion/media" }, `Exceeded max cache size after ${maxAttempts} attempts. Remaining cache size: ${(cacheStats.totalSize / 1024 / 1024).toFixed(1)} MB, target was ${(maxCacheSize / 1024 / 1024).toFixed(1)} MB.`);
3065
2928
  }
3066
2929
  };
3067
2930
  const clearKeyframeBanksBeforeTime = ({
@@ -3082,7 +2945,7 @@ var makeKeyframeManager = () => {
3082
2945
  }
3083
2946
  if (range.lastTimestamp < threshold) {
3084
2947
  bank.prepareForDeletion(logLevel, "cleared before threshold " + threshold);
3085
- Internals12.Log.verbose({ logLevel, tag: "@remotion/media" }, `[Video] Cleared frames for src ${src} from ${range.firstTimestamp}sec to ${range.lastTimestamp}sec`);
2948
+ Internals11.Log.verbose({ logLevel, tag: "@remotion/media" }, `[Video] Cleared frames for src ${src} from ${range.firstTimestamp}sec to ${range.lastTimestamp}sec`);
3086
2949
  const bankIndex = banks.indexOf(bank);
3087
2950
  delete sources[src][bankIndex];
3088
2951
  } else {
@@ -3104,7 +2967,7 @@ var makeKeyframeManager = () => {
3104
2967
  const existingBanks = sources[src] ?? [];
3105
2968
  const existingBank = existingBanks?.find((bank) => bank.canSatisfyTimestamp(timestamp));
3106
2969
  if (!existingBank) {
3107
- Internals12.Log.trace({ logLevel, tag: "@remotion/media" }, `Creating new keyframe bank for src ${src} at timestamp ${timestamp}`);
2970
+ Internals11.Log.trace({ logLevel, tag: "@remotion/media" }, `Creating new keyframe bank for src ${src} at timestamp ${timestamp}`);
3108
2971
  const newKeyframeBank = await makeKeyframeBank({
3109
2972
  videoSampleSink,
3110
2973
  logLevel,
@@ -3115,10 +2978,10 @@ var makeKeyframeManager = () => {
3115
2978
  return newKeyframeBank;
3116
2979
  }
3117
2980
  if (existingBank.canSatisfyTimestamp(timestamp)) {
3118
- Internals12.Log.trace({ logLevel, tag: "@remotion/media" }, `Keyframe bank exists and satisfies timestamp ${timestamp}`);
2981
+ Internals11.Log.trace({ logLevel, tag: "@remotion/media" }, `Keyframe bank exists and satisfies timestamp ${timestamp}`);
3119
2982
  return existingBank;
3120
2983
  }
3121
- Internals12.Log.verbose({ logLevel, tag: "@remotion/media" }, `Keyframe bank exists but frame at time ${timestamp} does not exist anymore.`);
2984
+ Internals11.Log.verbose({ logLevel, tag: "@remotion/media" }, `Keyframe bank exists but frame at time ${timestamp} does not exist anymore.`);
3122
2985
  existingBank.prepareForDeletion(logLevel, "already existed but evicted");
3123
2986
  sources[src] = sources[src].filter((bank) => bank !== existingBank);
3124
2987
  const replacementKeybank = await makeKeyframeBank({
@@ -3209,20 +3072,20 @@ var getUncachedMaxCacheSize = (logLevel) => {
3209
3072
  if (window.remotion_mediaCacheSizeInBytes > 20000 * 1024 * 1024) {
3210
3073
  cancelRender(new Error(`The maximum value for the "mediaCacheSizeInBytes" prop is 20GB (${20000 * 1024 * 1024}), got: ${window.remotion_mediaCacheSizeInBytes}`));
3211
3074
  }
3212
- Internals13.Log.verbose({ logLevel, tag: "@remotion/media" }, `Using cache size set using "mediaCacheSizeInBytes": ${(window.remotion_mediaCacheSizeInBytes / 1024 / 1024).toFixed(1)} MB`);
3075
+ Internals12.Log.verbose({ logLevel, tag: "@remotion/media" }, `Using cache size set using "mediaCacheSizeInBytes": ${(window.remotion_mediaCacheSizeInBytes / 1024 / 1024).toFixed(1)} MB`);
3213
3076
  return window.remotion_mediaCacheSizeInBytes;
3214
3077
  }
3215
3078
  if (typeof window !== "undefined" && window.remotion_initialMemoryAvailable !== undefined && window.remotion_initialMemoryAvailable !== null) {
3216
3079
  const value = window.remotion_initialMemoryAvailable / 2;
3217
3080
  if (value < 500 * 1024 * 1024) {
3218
- Internals13.Log.verbose({ logLevel, tag: "@remotion/media" }, `Using cache size set based on minimum value of 500MB (which is more than half of the available system memory!)`);
3081
+ Internals12.Log.verbose({ logLevel, tag: "@remotion/media" }, `Using cache size set based on minimum value of 500MB (which is more than half of the available system memory!)`);
3219
3082
  return 500 * 1024 * 1024;
3220
3083
  }
3221
3084
  if (value > 20000 * 1024 * 1024) {
3222
- Internals13.Log.verbose({ logLevel, tag: "@remotion/media" }, `Using cache size set based on maximum value of 20GB (which is less than half of the available system memory)`);
3085
+ Internals12.Log.verbose({ logLevel, tag: "@remotion/media" }, `Using cache size set based on maximum value of 20GB (which is less than half of the available system memory)`);
3223
3086
  return 20000 * 1024 * 1024;
3224
3087
  }
3225
- Internals13.Log.verbose({ logLevel, tag: "@remotion/media" }, `Using cache size set based on available memory (50% of available memory): ${(value / 1024 / 1024).toFixed(1)} MB`);
3088
+ Internals12.Log.verbose({ logLevel, tag: "@remotion/media" }, `Using cache size set based on available memory (50% of available memory): ${(value / 1024 / 1024).toFixed(1)} MB`);
3226
3089
  return value;
3227
3090
  }
3228
3091
  return 1000 * 1000 * 1000;
@@ -3236,7 +3099,7 @@ var getMaxVideoCacheSize = (logLevel) => {
3236
3099
  return cachedMaxCacheSize;
3237
3100
  };
3238
3101
  var useMaxMediaCacheSize = (logLevel) => {
3239
- const context = React2.useContext(Internals13.MaxMediaCacheSizeContext);
3102
+ const context = React2.useContext(Internals12.MaxMediaCacheSizeContext);
3240
3103
  if (context === null) {
3241
3104
  return getMaxVideoCacheSize(logLevel);
3242
3105
  }
@@ -3490,7 +3353,7 @@ var combineAudioDataAndClosePrevious = (audioDataArray) => {
3490
3353
  };
3491
3354
 
3492
3355
  // src/get-sink.ts
3493
- import { Internals as Internals14 } from "remotion";
3356
+ import { Internals as Internals13 } from "remotion";
3494
3357
 
3495
3358
  // src/video-extraction/get-frames-since-keyframe.ts
3496
3359
  import {
@@ -3659,7 +3522,7 @@ var getSink = (src, logLevel, credentials) => {
3659
3522
  const cacheKey = credentials ? `${src}::${credentials}` : src;
3660
3523
  let promise = sinkPromises[cacheKey];
3661
3524
  if (!promise) {
3662
- Internals14.Log.verbose({
3525
+ Internals13.Log.verbose({
3663
3526
  logLevel,
3664
3527
  tag: "@remotion/media"
3665
3528
  }, `Sink for ${src} was not found, creating new sink`);
@@ -3800,7 +3663,7 @@ var extractAudio = (params) => {
3800
3663
  };
3801
3664
 
3802
3665
  // src/video-extraction/extract-frame.ts
3803
- import { Internals as Internals15 } from "remotion";
3666
+ import { Internals as Internals14 } from "remotion";
3804
3667
  var extractFrameInternal = async ({
3805
3668
  src,
3806
3669
  timeInSeconds: unloopedTimeInSeconds,
@@ -3882,7 +3745,7 @@ var extractFrameInternal = async ({
3882
3745
  durationInSeconds: await sink.getDuration()
3883
3746
  };
3884
3747
  } catch (err) {
3885
- Internals15.Log.info({ logLevel, tag: "@remotion/media" }, `Error decoding ${src} at time ${timeInSeconds}: ${err}`, err);
3748
+ Internals14.Log.info({ logLevel, tag: "@remotion/media" }, `Error decoding ${src} at time ${timeInSeconds}: ${err}`, err);
3886
3749
  return { type: "cannot-decode", durationInSeconds: mediaDurationInSeconds };
3887
3750
  }
3888
3751
  };
@@ -4286,13 +4149,13 @@ var AudioForRendering = ({
4286
4149
  onError,
4287
4150
  credentials
4288
4151
  }) => {
4289
- const defaultLogLevel = Internals16.useLogLevel();
4152
+ const defaultLogLevel = Internals15.useLogLevel();
4290
4153
  const logLevel = overriddenLogLevel ?? defaultLogLevel;
4291
4154
  const frame = useCurrentFrame2();
4292
- const absoluteFrame = Internals16.useTimelinePosition();
4293
- const videoConfig = Internals16.useUnsafeVideoConfig();
4294
- const { registerRenderAsset, unregisterRenderAsset } = useContext4(Internals16.RenderAssetManager);
4295
- const startsAt = Internals16.useMediaStartsAt();
4155
+ const absoluteFrame = Internals15.useTimelinePosition();
4156
+ const videoConfig = Internals15.useUnsafeVideoConfig();
4157
+ const { registerRenderAsset, unregisterRenderAsset } = useContext3(Internals15.RenderAssetManager);
4158
+ const startsAt = Internals15.useMediaStartsAt();
4296
4159
  const environment = useRemotionEnvironment();
4297
4160
  if (!videoConfig) {
4298
4161
  throw new Error("No video config found");
@@ -4302,16 +4165,16 @@ var AudioForRendering = ({
4302
4165
  }
4303
4166
  const { fps } = videoConfig;
4304
4167
  const { delayRender, continueRender } = useDelayRender();
4305
- const [replaceWithHtml5Audio, setReplaceWithHtml5Audio] = useState3(false);
4306
- const sequenceContext = useContext4(Internals16.SequenceContext);
4307
- const id = useMemo3(() => `media-audio-${random(src)}-${sequenceContext?.cumulatedFrom}-${sequenceContext?.relativeFrom}-${sequenceContext?.durationInFrames}`, [
4168
+ const [replaceWithHtml5Audio, setReplaceWithHtml5Audio] = useState2(false);
4169
+ const sequenceContext = useContext3(Internals15.SequenceContext);
4170
+ const id = useMemo2(() => `media-audio-${random(src)}-${sequenceContext?.cumulatedFrom}-${sequenceContext?.relativeFrom}-${sequenceContext?.durationInFrames}`, [
4308
4171
  src,
4309
4172
  sequenceContext?.cumulatedFrom,
4310
4173
  sequenceContext?.relativeFrom,
4311
4174
  sequenceContext?.durationInFrames
4312
4175
  ]);
4313
4176
  const maxCacheSize = useMaxMediaCacheSize(logLevel);
4314
- const audioEnabled = Internals16.useAudioEnabled();
4177
+ const audioEnabled = Internals15.useAudioEnabled();
4315
4178
  useLayoutEffect2(() => {
4316
4179
  const timestamp = frame / fps;
4317
4180
  const durationInSeconds = 1 / fps;
@@ -4362,7 +4225,7 @@ var AudioForRendering = ({
4362
4225
  if (action === "fail") {
4363
4226
  cancelRender2(errorToUse);
4364
4227
  }
4365
- Internals16.Log.warn({ logLevel, tag: "@remotion/media" }, fallbackMessage);
4228
+ Internals15.Log.warn({ logLevel, tag: "@remotion/media" }, fallbackMessage);
4366
4229
  setReplaceWithHtml5Audio(true);
4367
4230
  };
4368
4231
  if (result.type === "unknown-container-format") {
@@ -4389,12 +4252,12 @@ var AudioForRendering = ({
4389
4252
  frame,
4390
4253
  startsAt
4391
4254
  });
4392
- const volume = Internals16.evaluateVolume({
4255
+ const volume = Internals15.evaluateVolume({
4393
4256
  volume: volumeProp,
4394
4257
  frame: volumePropsFrame,
4395
4258
  mediaVolume: 1
4396
4259
  });
4397
- Internals16.warnAboutTooHighVolume(volume);
4260
+ Internals15.warnAboutTooHighVolume(volume);
4398
4261
  if (audio && volume > 0) {
4399
4262
  applyVolume(audio.data, volume);
4400
4263
  registerRenderAsset({
@@ -4471,7 +4334,7 @@ var AudioForRendering = ({
4471
4334
 
4472
4335
  // src/audio/audio.tsx
4473
4336
  import { jsx as jsx3 } from "react/jsx-runtime";
4474
- var { validateMediaProps } = Internals17;
4337
+ var { validateMediaProps } = Internals16;
4475
4338
  var audioSchema = {
4476
4339
  volume: {
4477
4340
  type: "number",
@@ -4495,41 +4358,92 @@ var AudioInner = (props) => {
4495
4358
  name,
4496
4359
  stack,
4497
4360
  showInTimeline,
4498
- controls,
4361
+ _experimentalControls: controls,
4499
4362
  from,
4500
4363
  durationInFrames,
4501
4364
  ...otherProps
4502
4365
  } = props;
4503
4366
  const environment = useRemotionEnvironment2();
4367
+ const [mediaVolume] = Internals16.useMediaVolumeState();
4368
+ const mediaStartsAt = Internals16.useMediaStartsAt();
4369
+ const videoConfig = useVideoConfig2();
4370
+ const sequenceDurationInFrames = Math.min(durationInFrames ?? Infinity, Math.max(0, videoConfig.durationInFrames - (from ?? 0)));
4371
+ const basicInfo = Internals16.useBasicMediaInTimeline({
4372
+ src: props.src,
4373
+ volume: props.volume,
4374
+ playbackRate: props.playbackRate ?? 1,
4375
+ trimBefore: props.trimBefore,
4376
+ trimAfter: props.trimAfter,
4377
+ sequenceDurationInFrames,
4378
+ mediaType: "audio",
4379
+ displayName: name ?? "<Audio>",
4380
+ mediaVolume,
4381
+ mediaStartsAt,
4382
+ loop: props.loop ?? false
4383
+ });
4384
+ const [mediaDurationInSeconds, setMediaDurationInSeconds] = useState3(null);
4385
+ const loopDisplay = useMemo3(() => getLoopDisplay({
4386
+ loop: props.loop ?? false,
4387
+ mediaDurationInSeconds,
4388
+ playbackRate: props.playbackRate ?? 1,
4389
+ trimAfter: props.trimAfter,
4390
+ trimBefore: props.trimBefore,
4391
+ sequenceDurationInFrames,
4392
+ compFps: videoConfig.fps
4393
+ }), [
4394
+ props.loop,
4395
+ mediaDurationInSeconds,
4396
+ props.playbackRate,
4397
+ props.trimAfter,
4398
+ props.trimBefore,
4399
+ sequenceDurationInFrames,
4400
+ videoConfig.fps
4401
+ ]);
4402
+ const isMedia = useMemo3(() => ({
4403
+ type: "audio",
4404
+ data: basicInfo
4405
+ }), [basicInfo]);
4504
4406
  if (typeof props.src !== "string") {
4505
4407
  throw new TypeError(`The \`<Audio>\` tag requires a string for \`src\`, but got ${JSON.stringify(props.src)} instead.`);
4506
4408
  }
4507
4409
  validateMediaProps({ playbackRate: props.playbackRate, volume: props.volume }, "Audio");
4410
+ if (sequenceDurationInFrames === 0) {
4411
+ return null;
4412
+ }
4508
4413
  return /* @__PURE__ */ jsx3(Sequence, {
4509
4414
  layout: "none",
4510
4415
  from: from ?? 0,
4511
- durationInFrames: durationInFrames ?? Infinity,
4512
- showInTimeline: false,
4416
+ durationInFrames: basicInfo.duration,
4417
+ _remotionInternalStack: stack,
4418
+ _remotionInternalIsMedia: isMedia,
4419
+ name: name ?? "<Audio>",
4420
+ _experimentalControls: controls,
4421
+ _remotionInternalLoopDisplay: loopDisplay,
4422
+ showInTimeline: showInTimeline ?? true,
4513
4423
  children: environment.isRendering ? /* @__PURE__ */ jsx3(AudioForRendering, {
4514
4424
  ...otherProps
4515
4425
  }) : /* @__PURE__ */ jsx3(AudioForPreview, {
4516
4426
  name,
4517
4427
  ...otherProps,
4518
4428
  stack: stack ?? null,
4519
- controls
4429
+ setMediaDurationInSeconds
4520
4430
  })
4521
4431
  });
4522
4432
  };
4523
- var Audio = Internals17.wrapInSchema(AudioInner, audioSchema);
4524
- Internals17.addSequenceStackTraces(Audio);
4433
+ var Audio = Internals16.wrapInSchema(AudioInner, audioSchema);
4434
+ Internals16.addSequenceStackTraces(Audio);
4525
4435
 
4526
4436
  // src/video/video.tsx
4527
- import { Internals as Internals21, Sequence as Sequence2, useRemotionEnvironment as useRemotionEnvironment4 } from "remotion";
4437
+ import { useMemo as useMemo6, useState as useState6 } from "react";
4438
+ import {
4439
+ useVideoConfig as useVideoConfig5
4440
+ } from "remotion";
4441
+ import { Internals as Internals20, Sequence as Sequence2, useRemotionEnvironment as useRemotionEnvironment4 } from "remotion";
4528
4442
 
4529
4443
  // src/video/video-for-preview.tsx
4530
4444
  import {
4531
- useContext as useContext5,
4532
- useEffect as useEffect3,
4445
+ useContext as useContext4,
4446
+ useEffect as useEffect2,
4533
4447
  useLayoutEffect as useLayoutEffect3,
4534
4448
  useMemo as useMemo4,
4535
4449
  useRef as useRef2,
@@ -4537,7 +4451,7 @@ import {
4537
4451
  } from "react";
4538
4452
  import {
4539
4453
  Html5Video,
4540
- Internals as Internals19,
4454
+ Internals as Internals18,
4541
4455
  useBufferState as useBufferState2,
4542
4456
  useCurrentFrame as useCurrentFrame3,
4543
4457
  useVideoConfig as useVideoConfig3
@@ -4567,7 +4481,7 @@ var getCachedVideoFrame = (src) => {
4567
4481
  };
4568
4482
 
4569
4483
  // src/video/warn-object-fit-css.ts
4570
- import { Internals as Internals18 } from "remotion";
4484
+ import { Internals as Internals17 } from "remotion";
4571
4485
  var OBJECT_FIT_CLASS_PATTERN = /\bobject-(contain|cover|fill|none|scale-down)\b/;
4572
4486
  var warnedStyle = false;
4573
4487
  var warnedClassName = false;
@@ -4578,11 +4492,11 @@ var warnAboutObjectFitInStyleOrClassName = ({
4578
4492
  }) => {
4579
4493
  if (!warnedStyle && style?.objectFit) {
4580
4494
  warnedStyle = true;
4581
- Internals18.Log.warn({ logLevel, tag: "@remotion/media" }, "Use the `objectFit` prop instead of the `style` prop.");
4495
+ Internals17.Log.warn({ logLevel, tag: "@remotion/media" }, "Use the `objectFit` prop instead of the `style` prop.");
4582
4496
  }
4583
4497
  if (!warnedClassName && className && OBJECT_FIT_CLASS_PATTERN.test(className)) {
4584
4498
  warnedClassName = true;
4585
- Internals18.Log.warn({ logLevel, tag: "@remotion/media" }, "Use the `objectFit` prop instead of `object-*` CSS class names.");
4499
+ Internals17.Log.warn({ logLevel, tag: "@remotion/media" }, "Use the `objectFit` prop instead of `object-*` CSS class names.");
4586
4500
  }
4587
4501
  };
4588
4502
 
@@ -4599,10 +4513,8 @@ var {
4599
4513
  warnAboutTooHighVolume: warnAboutTooHighVolume2,
4600
4514
  usePreload: usePreload2,
4601
4515
  SequenceContext: SequenceContext2,
4602
- SequenceVisibilityToggleContext,
4603
- useEffectChainState,
4604
- useMemoizedEffects
4605
- } = Internals19;
4516
+ useEffectChainState
4517
+ } = Internals18;
4606
4518
  var VideoForPreviewAssertedShowing = ({
4607
4519
  src: unpreloadedSrc,
4608
4520
  style,
@@ -4615,7 +4527,6 @@ var VideoForPreviewAssertedShowing = ({
4615
4527
  onVideoFrame,
4616
4528
  showInTimeline,
4617
4529
  loop,
4618
- name,
4619
4530
  trimAfter,
4620
4531
  trimBefore,
4621
4532
  stack,
@@ -4626,10 +4537,10 @@ var VideoForPreviewAssertedShowing = ({
4626
4537
  headless,
4627
4538
  onError,
4628
4539
  credentials,
4629
- controls,
4630
4540
  objectFit: objectFitProp,
4631
4541
  _experimentalInitiallyDrawCachedFrame,
4632
- _experimentalEffects
4542
+ _experimentalEffects,
4543
+ setMediaDurationInSeconds
4633
4544
  }) => {
4634
4545
  const src = usePreload2(unpreloadedSrc);
4635
4546
  const canvasRef = useRef2(null);
@@ -4642,14 +4553,12 @@ var VideoForPreviewAssertedShowing = ({
4642
4553
  const [mediaPlayerReady, setMediaPlayerReady] = useState4(false);
4643
4554
  const [shouldFallbackToNativeVideo, setShouldFallbackToNativeVideo] = useState4(false);
4644
4555
  const [playing] = Timeline2.usePlayingState();
4645
- const timelineContext = Internals19.useTimelineContext();
4556
+ const timelineContext = Internals18.useTimelineContext();
4646
4557
  const globalPlaybackRate = timelineContext.playbackRate;
4647
- const sharedAudioContext = useContext5(SharedAudioContext2);
4558
+ const sharedAudioContext = useContext4(SharedAudioContext2);
4648
4559
  const buffer = useBufferState2();
4649
4560
  const [mediaMuted] = useMediaMutedState2();
4650
4561
  const [mediaVolume] = useMediaVolumeState2();
4651
- const [mediaDurationInSeconds, setMediaDurationInSeconds] = useState4(null);
4652
- const { hidden } = useContext5(SequenceVisibilityToggleContext);
4653
4562
  const volumePropFrame = useFrameForVolumeProp2(loopVolumeCurveBehavior);
4654
4563
  const userPreferredVolume = evaluateVolume2({
4655
4564
  frame: volumePropFrame,
@@ -4663,50 +4572,24 @@ var VideoForPreviewAssertedShowing = ({
4663
4572
  const effectChainState = useEffectChainState();
4664
4573
  const experimentalEffectsRef = useRef2(_experimentalEffects);
4665
4574
  experimentalEffectsRef.current = _experimentalEffects;
4666
- const memoizedEffects = useMemoizedEffects(_experimentalEffects.flat());
4667
4575
  const effectChainStateRef = useRef2(effectChainState);
4668
4576
  effectChainStateRef.current = effectChainState;
4669
4577
  const frameRef = useRef2(frame);
4670
4578
  frameRef.current = frame;
4671
- const parentSequence = useContext5(SequenceContext2);
4579
+ const parentSequence = useContext4(SequenceContext2);
4672
4580
  const isPremounting = Boolean(parentSequence?.premounting);
4673
4581
  const isPostmounting = Boolean(parentSequence?.postmounting);
4674
4582
  const sequenceOffset = ((parentSequence?.cumulatedFrom ?? 0) + (parentSequence?.relativeFrom ?? 0)) / videoConfig.fps;
4675
- const loopDisplay = useLoopDisplay({
4676
- loop,
4677
- mediaDurationInSeconds,
4678
- playbackRate,
4679
- trimAfter,
4680
- trimBefore
4681
- });
4682
- const { id: timelineId } = useMediaInTimeline({
4683
- volume,
4684
- mediaType: "video",
4685
- src,
4686
- playbackRate,
4687
- displayName: name ?? null,
4688
- stack,
4689
- showInTimeline,
4690
- premountDisplay: parentSequence?.premountDisplay ?? null,
4691
- postmountDisplay: parentSequence?.postmountDisplay ?? null,
4692
- loopDisplay,
4693
- mediaVolume,
4694
- trimAfter,
4695
- trimBefore,
4696
- controls,
4697
- _experimentalEffects: memoizedEffects
4698
- });
4699
- const isSequenceHidden = hidden[timelineId] ?? false;
4700
4583
  const currentTime = frame / videoConfig.fps;
4701
4584
  const currentTimeRef = useRef2(currentTime);
4702
4585
  currentTimeRef.current = currentTime;
4703
4586
  const preloadedSrc = usePreload2(src);
4704
- const buffering = useContext5(Internals19.BufferingContextReact);
4587
+ const buffering = useContext4(Internals18.BufferingContextReact);
4705
4588
  if (!buffering) {
4706
4589
  throw new Error("useMediaPlayback must be used inside a <BufferingContext>");
4707
4590
  }
4708
- const effectiveMuted = isSequenceHidden || muted || mediaMuted || userPreferredVolume <= 0;
4709
- const isPlayerBuffering = Internals19.useIsPlayerBuffering(buffering);
4591
+ const effectiveMuted = muted || mediaMuted || userPreferredVolume <= 0;
4592
+ const isPlayerBuffering = Internals18.useIsPlayerBuffering(buffering);
4710
4593
  const initialPlaying = useRef2(playing && !isPlayerBuffering);
4711
4594
  const initialIsPremounting = useRef2(isPremounting);
4712
4595
  const initialIsPostmounting = useRef2(isPostmounting);
@@ -4753,7 +4636,7 @@ var VideoForPreviewAssertedShowing = ({
4753
4636
  cacheVideoFrame(src, canvas);
4754
4637
  };
4755
4638
  }, [_experimentalInitiallyDrawCachedFrame, src]);
4756
- useEffect3(() => {
4639
+ useEffect2(() => {
4757
4640
  if (!sharedAudioContext)
4758
4641
  return;
4759
4642
  if (!sharedAudioContext.audioContext)
@@ -4817,7 +4700,7 @@ var VideoForPreviewAssertedShowing = ({
4817
4700
  if (action === "fail") {
4818
4701
  throw errorToUse;
4819
4702
  }
4820
- Internals19.Log.warn({ logLevel, tag: "@remotion/media" }, fallbackMessage);
4703
+ Internals18.Log.warn({ logLevel, tag: "@remotion/media" }, fallbackMessage);
4821
4704
  setShouldFallbackToNativeVideo(true);
4822
4705
  };
4823
4706
  if (result.type === "unknown-container-format") {
@@ -4852,7 +4735,7 @@ var VideoForPreviewAssertedShowing = ({
4852
4735
  if (action === "fail") {
4853
4736
  throw errorToUse;
4854
4737
  }
4855
- Internals19.Log.error({ logLevel, tag: "@remotion/media" }, "[VideoForPreview] Failed to initialize MediaPlayer", errorToUse);
4738
+ Internals18.Log.error({ logLevel, tag: "@remotion/media" }, "[VideoForPreview] Failed to initialize MediaPlayer", errorToUse);
4856
4739
  setShouldFallbackToNativeVideo(true);
4857
4740
  });
4858
4741
  } catch (error) {
@@ -4866,12 +4749,12 @@ var VideoForPreviewAssertedShowing = ({
4866
4749
  if (action === "fail") {
4867
4750
  throw errorToUse;
4868
4751
  }
4869
- Internals19.Log.error({ logLevel, tag: "@remotion/media" }, "[VideoForPreview] MediaPlayer initialization failed", errorToUse);
4752
+ Internals18.Log.error({ logLevel, tag: "@remotion/media" }, "[VideoForPreview] MediaPlayer initialization failed", errorToUse);
4870
4753
  setShouldFallbackToNativeVideo(true);
4871
4754
  }
4872
4755
  return () => {
4873
4756
  if (mediaPlayerRef.current) {
4874
- Internals19.Log.trace({ logLevel, tag: "@remotion/media" }, `[VideoForPreview] Disposing MediaPlayer`);
4757
+ Internals18.Log.trace({ logLevel, tag: "@remotion/media" }, `[VideoForPreview] Disposing MediaPlayer`);
4875
4758
  mediaPlayerRef.current.dispose();
4876
4759
  mediaPlayerRef.current = null;
4877
4760
  }
@@ -4890,11 +4773,12 @@ var VideoForPreviewAssertedShowing = ({
4890
4773
  sharedAudioContext,
4891
4774
  videoConfig.fps,
4892
4775
  onError,
4893
- credentials
4776
+ credentials,
4777
+ setMediaDurationInSeconds
4894
4778
  ]);
4895
4779
  warnAboutObjectFitInStyleOrClassName({ style, className, logLevel });
4896
4780
  const classNameValue = useMemo4(() => {
4897
- return [Internals19.OBJECTFIT_CONTAIN_CLASS_NAME, className].filter(Internals19.truthy).join(" ");
4781
+ return [Internals18.OBJECTFIT_CONTAIN_CLASS_NAME, className].filter(Internals18.truthy).join(" ");
4898
4782
  }, [className]);
4899
4783
  useCommonEffects({
4900
4784
  mediaPlayerRef,
@@ -4936,10 +4820,9 @@ var VideoForPreviewAssertedShowing = ({
4936
4820
  const actualStyle = useMemo4(() => {
4937
4821
  return {
4938
4822
  ...style,
4939
- opacity: isSequenceHidden ? 0 : style?.opacity ?? 1,
4940
4823
  objectFit: objectFitProp
4941
4824
  };
4942
- }, [isSequenceHidden, objectFitProp, style]);
4825
+ }, [objectFitProp, style]);
4943
4826
  if (shouldFallbackToNativeVideo && !disallowFallbackToOffthreadVideo) {
4944
4827
  return /* @__PURE__ */ jsx4(Html5Video, {
4945
4828
  src,
@@ -4951,7 +4834,7 @@ var VideoForPreviewAssertedShowing = ({
4951
4834
  trimBefore,
4952
4835
  playbackRate,
4953
4836
  loopVolumeCurveBehavior,
4954
- name,
4837
+ name: "<Html5Video> (fallback)",
4955
4838
  loop,
4956
4839
  showInTimeline,
4957
4840
  stack: stack ?? undefined,
@@ -4996,21 +4879,20 @@ var VideoForPreview = (props) => {
4996
4879
  return null;
4997
4880
  }
4998
4881
  return /* @__PURE__ */ jsx4(VideoForPreviewAssertedShowing, {
4999
- ...props,
5000
- controls: props.controls
4882
+ ...props
5001
4883
  });
5002
4884
  };
5003
4885
 
5004
4886
  // src/video/video-for-rendering.tsx
5005
4887
  import {
5006
- useContext as useContext6,
4888
+ useContext as useContext5,
5007
4889
  useLayoutEffect as useLayoutEffect4,
5008
4890
  useMemo as useMemo5,
5009
4891
  useRef as useRef3,
5010
4892
  useState as useState5
5011
4893
  } from "react";
5012
4894
  import {
5013
- Internals as Internals20,
4895
+ Internals as Internals19,
5014
4896
  Loop,
5015
4897
  random as random2,
5016
4898
  useCurrentFrame as useCurrentFrame4,
@@ -5034,7 +4916,6 @@ var VideoForRendering = ({
5034
4916
  className,
5035
4917
  fallbackOffthreadVideoProps,
5036
4918
  audioStreamIndex,
5037
- name,
5038
4919
  disallowFallbackToOffthreadVideo,
5039
4920
  stack,
5040
4921
  toneFrequency,
@@ -5049,11 +4930,11 @@ var VideoForRendering = ({
5049
4930
  throw new TypeError("No `src` was passed to <Video>.");
5050
4931
  }
5051
4932
  const frame = useCurrentFrame4();
5052
- const absoluteFrame = Internals20.useTimelinePosition();
4933
+ const absoluteFrame = Internals19.useTimelinePosition();
5053
4934
  const { fps } = useVideoConfig4();
5054
- const { registerRenderAsset, unregisterRenderAsset } = useContext6(Internals20.RenderAssetManager);
5055
- const startsAt = Internals20.useMediaStartsAt();
5056
- const sequenceContext = useContext6(Internals20.SequenceContext);
4935
+ const { registerRenderAsset, unregisterRenderAsset } = useContext5(Internals19.RenderAssetManager);
4936
+ const startsAt = Internals19.useMediaStartsAt();
4937
+ const sequenceContext = useContext5(Internals19.SequenceContext);
5057
4938
  const id = useMemo5(() => `media-video-${random2(src)}-${sequenceContext?.cumulatedFrom}-${sequenceContext?.relativeFrom}-${sequenceContext?.durationInFrames}`, [
5058
4939
  src,
5059
4940
  sequenceContext?.cumulatedFrom,
@@ -5064,8 +4945,8 @@ var VideoForRendering = ({
5064
4945
  const { delayRender, continueRender, cancelRender: cancelRender3 } = useDelayRender2();
5065
4946
  const canvasRef = useRef3(null);
5066
4947
  const [replaceWithOffthreadVideo, setReplaceWithOffthreadVideo] = useState5(false);
5067
- const audioEnabled = Internals20.useAudioEnabled();
5068
- const videoEnabled = Internals20.useVideoEnabled();
4948
+ const audioEnabled = Internals19.useAudioEnabled();
4949
+ const videoEnabled = Internals19.useVideoEnabled();
5069
4950
  const maxCacheSize = useMaxMediaCacheSize(logLevel);
5070
4951
  const [error, setError] = useState5(null);
5071
4952
  if (error) {
@@ -5130,7 +5011,7 @@ var VideoForRendering = ({
5130
5011
  return;
5131
5012
  }
5132
5013
  if (window.remotion_isMainTab) {
5133
- Internals20.Log.warn({ logLevel, tag: "@remotion/media" }, fallbackMessage);
5014
+ Internals19.Log.warn({ logLevel, tag: "@remotion/media" }, fallbackMessage);
5134
5015
  }
5135
5016
  setReplaceWithOffthreadVideo({
5136
5017
  durationInSeconds: mediaDurationInSeconds
@@ -5185,12 +5066,12 @@ var VideoForRendering = ({
5185
5066
  frame,
5186
5067
  startsAt
5187
5068
  });
5188
- const volume = Internals20.evaluateVolume({
5069
+ const volume = Internals19.evaluateVolume({
5189
5070
  volume: volumeProp,
5190
5071
  frame: volumePropsFrame,
5191
5072
  mediaVolume: 1
5192
5073
  });
5193
- Internals20.warnAboutTooHighVolume(volume);
5074
+ Internals19.warnAboutTooHighVolume(volume);
5194
5075
  if (audio && volume > 0) {
5195
5076
  applyVolume(audio.data, volume);
5196
5077
  registerRenderAsset({
@@ -5248,7 +5129,7 @@ var VideoForRendering = ({
5248
5129
  ]);
5249
5130
  warnAboutObjectFitInStyleOrClassName({ style, className, logLevel });
5250
5131
  const classNameValue = useMemo5(() => {
5251
- return [Internals20.OBJECTFIT_CONTAIN_CLASS_NAME, className].filter(Internals20.truthy).join(" ");
5132
+ return [Internals19.OBJECTFIT_CONTAIN_CLASS_NAME, className].filter(Internals19.truthy).join(" ");
5252
5133
  }, [className]);
5253
5134
  const styleWithObjectFit = useMemo5(() => {
5254
5135
  return {
@@ -5257,7 +5138,7 @@ var VideoForRendering = ({
5257
5138
  };
5258
5139
  }, [objectFitProp, style]);
5259
5140
  if (replaceWithOffthreadVideo) {
5260
- const fallback = /* @__PURE__ */ jsx5(Internals20.InnerOffthreadVideo, {
5141
+ const fallback = /* @__PURE__ */ jsx5(Internals19.InnerOffthreadVideo, {
5261
5142
  src,
5262
5143
  playbackRate: playbackRate ?? 1,
5263
5144
  muted: muted ?? false,
@@ -5265,12 +5146,12 @@ var VideoForRendering = ({
5265
5146
  loopVolumeCurveBehavior: loopVolumeCurveBehavior ?? "repeat",
5266
5147
  delayRenderRetries: delayRenderRetries ?? undefined,
5267
5148
  delayRenderTimeoutInMilliseconds: delayRenderTimeoutInMilliseconds ?? undefined,
5149
+ name: "Fallback to <OffthreadVideo>",
5268
5150
  style: styleWithObjectFit,
5269
5151
  allowAmplificationDuringRender: true,
5270
5152
  transparent: fallbackOffthreadVideoProps?.transparent ?? true,
5271
5153
  toneMapped: fallbackOffthreadVideoProps?.toneMapped ?? true,
5272
5154
  audioStreamIndex: audioStreamIndex ?? 0,
5273
- name,
5274
5155
  className,
5275
5156
  onVideoFrame,
5276
5157
  volume: volumeProp,
@@ -5297,7 +5178,7 @@ var VideoForRendering = ({
5297
5178
  }
5298
5179
  return /* @__PURE__ */ jsx5(Loop, {
5299
5180
  layout: "none",
5300
- durationInFrames: Internals20.calculateMediaDuration({
5181
+ durationInFrames: Internals19.calculateMediaDuration({
5301
5182
  trimAfter: trimAfterValue,
5302
5183
  mediaDurationInFrames: replaceWithOffthreadVideo.durationInSeconds * fps,
5303
5184
  playbackRate,
@@ -5320,7 +5201,7 @@ var VideoForRendering = ({
5320
5201
 
5321
5202
  // src/video/video.tsx
5322
5203
  import { jsx as jsx6 } from "react/jsx-runtime";
5323
- var { validateMediaTrimProps, resolveTrimProps, validateMediaProps: validateMediaProps2 } = Internals21;
5204
+ var { validateMediaTrimProps, resolveTrimProps, validateMediaProps: validateMediaProps2 } = Internals20;
5324
5205
  var videoSchema = {
5325
5206
  volume: {
5326
5207
  type: "number",
@@ -5379,7 +5260,6 @@ var InnerVideo = ({
5379
5260
  loop,
5380
5261
  loopVolumeCurveBehavior,
5381
5262
  muted,
5382
- name,
5383
5263
  onVideoFrame,
5384
5264
  playbackRate,
5385
5265
  style,
@@ -5393,10 +5273,11 @@ var InnerVideo = ({
5393
5273
  headless,
5394
5274
  onError,
5395
5275
  credentials,
5396
- controls,
5276
+ _experimentalControls: controls,
5397
5277
  objectFit,
5398
5278
  _experimentalInitiallyDrawCachedFrame,
5399
- _experimentalEffects
5279
+ _experimentalEffects,
5280
+ setMediaDurationInSeconds
5400
5281
  }) => {
5401
5282
  const environment = useRemotionEnvironment4();
5402
5283
  if (typeof src !== "string") {
@@ -5422,7 +5303,6 @@ var InnerVideo = ({
5422
5303
  delayRenderRetries: delayRenderRetries ?? null,
5423
5304
  delayRenderTimeoutInMilliseconds: delayRenderTimeoutInMilliseconds ?? null,
5424
5305
  disallowFallbackToOffthreadVideo: disallowFallbackToOffthreadVideo ?? false,
5425
- name,
5426
5306
  fallbackOffthreadVideoProps,
5427
5307
  logLevel,
5428
5308
  loop,
@@ -5444,9 +5324,9 @@ var InnerVideo = ({
5444
5324
  });
5445
5325
  }
5446
5326
  return /* @__PURE__ */ jsx6(VideoForPreview, {
5327
+ setMediaDurationInSeconds,
5447
5328
  audioStreamIndex: audioStreamIndex ?? 0,
5448
5329
  className,
5449
- name,
5450
5330
  logLevel,
5451
5331
  loop,
5452
5332
  loopVolumeCurveBehavior,
@@ -5498,19 +5378,66 @@ var VideoInner = ({
5498
5378
  headless,
5499
5379
  onError,
5500
5380
  credentials,
5501
- controls,
5381
+ _experimentalControls: controls,
5502
5382
  objectFit,
5503
5383
  _experimentalInitiallyDrawCachedFrame,
5504
5384
  _experimentalEffects,
5505
- from,
5506
- durationInFrames
5385
+ durationInFrames,
5386
+ from
5507
5387
  }) => {
5508
- const fallbackLogLevel = Internals21.useLogLevel();
5388
+ const fallbackLogLevel = Internals20.useLogLevel();
5389
+ const [mediaVolume] = Internals20.useMediaVolumeState();
5390
+ const mediaStartsAt = Internals20.useMediaStartsAt();
5391
+ const videoConfig = useVideoConfig5();
5392
+ const sequenceDurationInFrames = Math.min(durationInFrames ?? Infinity, Math.max(0, videoConfig.durationInFrames - (from ?? 0)));
5393
+ const basicInfo = Internals20.useBasicMediaInTimeline({
5394
+ src,
5395
+ volume,
5396
+ playbackRate: playbackRate ?? 1,
5397
+ trimBefore,
5398
+ trimAfter,
5399
+ sequenceDurationInFrames,
5400
+ mediaType: "video",
5401
+ displayName: name ?? "<Video>",
5402
+ mediaVolume,
5403
+ mediaStartsAt,
5404
+ loop: loop ?? false
5405
+ });
5406
+ const [mediaDurationInSeconds, setMediaDurationInSeconds] = useState6(null);
5407
+ const loopDisplay = useMemo6(() => getLoopDisplay({
5408
+ loop: loop ?? false,
5409
+ mediaDurationInSeconds,
5410
+ playbackRate: playbackRate ?? 1,
5411
+ trimAfter,
5412
+ trimBefore,
5413
+ sequenceDurationInFrames,
5414
+ compFps: videoConfig.fps
5415
+ }), [
5416
+ loop,
5417
+ mediaDurationInSeconds,
5418
+ playbackRate,
5419
+ trimAfter,
5420
+ trimBefore,
5421
+ sequenceDurationInFrames,
5422
+ videoConfig.fps
5423
+ ]);
5424
+ const isMedia = useMemo6(() => ({
5425
+ type: "video",
5426
+ data: basicInfo
5427
+ }), [basicInfo]);
5428
+ if (sequenceDurationInFrames === 0) {
5429
+ return null;
5430
+ }
5509
5431
  return /* @__PURE__ */ jsx6(Sequence2, {
5510
5432
  layout: "none",
5511
5433
  from: from ?? 0,
5512
- durationInFrames: durationInFrames ?? Infinity,
5513
- showInTimeline: false,
5434
+ durationInFrames: basicInfo.duration,
5435
+ _remotionInternalStack: stack,
5436
+ _remotionInternalIsMedia: isMedia,
5437
+ name: name ?? "<Video>",
5438
+ _experimentalControls: controls,
5439
+ _remotionInternalLoopDisplay: loopDisplay,
5440
+ showInTimeline: showInTimeline ?? true,
5514
5441
  children: /* @__PURE__ */ jsx6(InnerVideo, {
5515
5442
  audioStreamIndex: audioStreamIndex ?? 0,
5516
5443
  className,
@@ -5522,7 +5449,6 @@ var VideoInner = ({
5522
5449
  loop: loop ?? false,
5523
5450
  loopVolumeCurveBehavior: loopVolumeCurveBehavior ?? "repeat",
5524
5451
  muted: muted ?? false,
5525
- name,
5526
5452
  onVideoFrame,
5527
5453
  playbackRate: playbackRate ?? 1,
5528
5454
  showInTimeline: showInTimeline ?? true,
@@ -5537,15 +5463,16 @@ var VideoInner = ({
5537
5463
  headless: headless ?? false,
5538
5464
  onError,
5539
5465
  credentials,
5540
- controls,
5466
+ _experimentalControls: controls,
5541
5467
  objectFit: objectFit ?? "contain",
5542
5468
  _experimentalInitiallyDrawCachedFrame: _experimentalInitiallyDrawCachedFrame ?? false,
5543
- _experimentalEffects: _experimentalEffects ?? []
5469
+ _experimentalEffects: _experimentalEffects ?? [],
5470
+ setMediaDurationInSeconds
5544
5471
  })
5545
5472
  });
5546
5473
  };
5547
- var Video = Internals21.wrapInSchema(VideoInner, videoSchema);
5548
- Internals21.addSequenceStackTraces(Video);
5474
+ var Video = Internals20.wrapInSchema(VideoInner, videoSchema);
5475
+ Internals20.addSequenceStackTraces(Video);
5549
5476
 
5550
5477
  // src/index.ts
5551
5478
  var experimental_Audio = Audio;