remotion 3.3.51 → 3.3.52

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.
Files changed (198) hide show
  1. package/dist/AbsoluteFill.d.ts +6 -0
  2. package/dist/AbsoluteFill.js +28 -0
  3. package/dist/CanUseRemotionHooks.d.ts +5 -0
  4. package/dist/CanUseRemotionHooks.js +10 -0
  5. package/dist/Clipper.d.ts +7 -0
  6. package/dist/Clipper.js +24 -0
  7. package/dist/Composition.d.ts +23 -0
  8. package/dist/Composition.js +113 -0
  9. package/dist/CompositionManager.d.ts +82 -0
  10. package/dist/CompositionManager.js +164 -0
  11. package/dist/Folder.d.ts +15 -0
  12. package/dist/Folder.js +33 -0
  13. package/dist/IFrame.d.ts +2 -0
  14. package/dist/IFrame.js +24 -0
  15. package/dist/Img.d.ts +2 -0
  16. package/dist/Img.js +52 -0
  17. package/dist/NativeLayers.d.ts +13 -0
  18. package/dist/NativeLayers.js +29 -0
  19. package/dist/Null.d.ts +2 -0
  20. package/dist/Null.js +25 -0
  21. package/dist/RemotionRoot.d.ts +5 -0
  22. package/dist/RemotionRoot.js +73 -0
  23. package/dist/Sequence.d.ts +29 -0
  24. package/dist/Sequence.js +131 -0
  25. package/dist/Still.d.ts +2 -0
  26. package/dist/Still.js +9 -0
  27. package/dist/absolute-src.d.ts +1 -0
  28. package/dist/absolute-src.js +7 -0
  29. package/dist/asset-types.d.ts +50 -0
  30. package/dist/asset-types.js +1 -0
  31. package/dist/audio/Audio.d.ts +8 -0
  32. package/dist/audio/Audio.js +52 -0
  33. package/dist/audio/AudioForDevelopment.d.ts +11 -0
  34. package/dist/audio/AudioForDevelopment.js +94 -0
  35. package/dist/audio/AudioForRendering.d.ts +10 -0
  36. package/dist/audio/AudioForRendering.js +111 -0
  37. package/dist/audio/index.d.ts +2 -0
  38. package/dist/audio/index.js +18 -0
  39. package/dist/audio/props.d.ts +12 -0
  40. package/dist/audio/props.js +2 -0
  41. package/dist/audio/shared-audio-tags.d.ts +37 -0
  42. package/dist/audio/shared-audio-tags.js +222 -0
  43. package/dist/audio/use-audio-frame.d.ts +6 -0
  44. package/dist/audio/use-audio-frame.js +23 -0
  45. package/dist/bezier.d.ts +1 -0
  46. package/dist/bezier.js +114 -0
  47. package/dist/cancel-render.d.ts +1 -0
  48. package/dist/cancel-render.js +43 -0
  49. package/dist/cjs/series/index.js +5 -2
  50. package/dist/cjs/test/series.test.js +32 -27
  51. package/dist/cjs/version.d.ts +1 -1
  52. package/dist/cjs/version.js +1 -1
  53. package/dist/config/input-props.d.ts +1 -0
  54. package/dist/config/input-props.js +31 -0
  55. package/dist/config.d.ts +285 -0
  56. package/dist/config.js +21 -0
  57. package/dist/default-css.d.ts +3 -0
  58. package/dist/default-css.js +49 -0
  59. package/dist/delay-render.d.ts +14 -0
  60. package/dist/delay-render.js +77 -0
  61. package/dist/easing.d.ts +19 -0
  62. package/dist/easing.js +77 -0
  63. package/dist/esm/series/index.js +5 -2
  64. package/dist/esm/test/series.test.js +32 -27
  65. package/dist/esm/version.d.ts +1 -1
  66. package/dist/esm/version.js +1 -1
  67. package/dist/freeze.d.ts +7 -0
  68. package/dist/freeze.js +34 -0
  69. package/dist/get-asset-file-name.d.ts +1 -0
  70. package/dist/get-asset-file-name.js +14 -0
  71. package/dist/get-environment.d.ts +3 -0
  72. package/dist/get-environment.js +34 -0
  73. package/dist/get-preview-dom-element.d.ts +1 -0
  74. package/dist/get-preview-dom-element.js +7 -0
  75. package/dist/get-static-files.d.ts +17 -0
  76. package/dist/get-static-files.js +31 -0
  77. package/dist/get-timeline-clip-name.d.ts +1 -0
  78. package/dist/get-timeline-clip-name.js +25 -0
  79. package/dist/index.d.ts +92 -0
  80. package/dist/index.js +73 -0
  81. package/dist/internals.d.ts +97 -0
  82. package/dist/internals.js +99 -0
  83. package/dist/interpolate-colors.d.ts +5 -0
  84. package/dist/interpolate-colors.js +401 -0
  85. package/dist/interpolate.d.ts +18 -0
  86. package/dist/interpolate.js +123 -0
  87. package/dist/is-approximately-the-same.d.ts +1 -0
  88. package/dist/is-approximately-the-same.js +8 -0
  89. package/dist/is-player.d.ts +3 -0
  90. package/dist/is-player.js +14 -0
  91. package/dist/loading-indicator.d.ts +2 -0
  92. package/dist/loading-indicator.js +35 -0
  93. package/dist/loop/index.d.ts +9 -0
  94. package/dist/loop/index.js +29 -0
  95. package/dist/multiple-versions-warning.d.ts +1 -0
  96. package/dist/multiple-versions-warning.js +32 -0
  97. package/dist/nonce.d.ts +7 -0
  98. package/dist/nonce.js +17 -0
  99. package/dist/play-and-handle-not-allowed-error.d.ts +2 -0
  100. package/dist/play-and-handle-not-allowed-error.js +44 -0
  101. package/dist/portal-node.d.ts +1 -0
  102. package/dist/portal-node.js +23 -0
  103. package/dist/prefetch-state.d.ts +8 -0
  104. package/dist/prefetch-state.js +27 -0
  105. package/dist/prefetch.d.ts +9 -0
  106. package/dist/prefetch.js +108 -0
  107. package/dist/random.d.ts +7 -0
  108. package/dist/random.js +41 -0
  109. package/dist/register-root.d.ts +4 -0
  110. package/dist/register-root.js +33 -0
  111. package/dist/series/flatten-children.d.ts +2 -0
  112. package/dist/series/flatten-children.js +19 -0
  113. package/dist/series/index.d.ts +13 -0
  114. package/dist/series/index.js +60 -0
  115. package/dist/setup-env-variables.d.ts +2 -0
  116. package/dist/setup-env-variables.js +36 -0
  117. package/dist/spring/index.d.ts +27 -0
  118. package/dist/spring/index.js +51 -0
  119. package/dist/spring/measure-spring.d.ts +8 -0
  120. package/dist/spring/measure-spring.js +64 -0
  121. package/dist/spring/spring-utils.d.ts +21 -0
  122. package/dist/spring/spring-utils.js +103 -0
  123. package/dist/static-file.d.ts +5 -0
  124. package/dist/static-file.js +33 -0
  125. package/dist/timeline-position-state.d.ts +29 -0
  126. package/dist/timeline-position-state.js +41 -0
  127. package/dist/truthy.d.ts +3 -0
  128. package/dist/truthy.js +7 -0
  129. package/dist/tsconfig-cjs.tsbuildinfo +1 -1
  130. package/dist/use-current-frame.d.ts +6 -0
  131. package/dist/use-current-frame.js +28 -0
  132. package/dist/use-lazy-component.d.ts +7 -0
  133. package/dist/use-lazy-component.js +49 -0
  134. package/dist/use-media-in-timeline.d.ts +10 -0
  135. package/dist/use-media-in-timeline.js +129 -0
  136. package/dist/use-media-playback.d.ts +10 -0
  137. package/dist/use-media-playback.js +77 -0
  138. package/dist/use-media-tag-volume.d.ts +2 -0
  139. package/dist/use-media-tag-volume.js +31 -0
  140. package/dist/use-sync-volume-with-media-tag.d.ts +10 -0
  141. package/dist/use-sync-volume-with-media-tag.js +21 -0
  142. package/dist/use-unsafe-video-config.d.ts +2 -0
  143. package/dist/use-unsafe-video-config.js +27 -0
  144. package/dist/use-video-config.d.ts +7 -0
  145. package/dist/use-video-config.js +29 -0
  146. package/dist/use-video.d.ts +12 -0
  147. package/dist/use-video.js +28 -0
  148. package/dist/validate-media-props.d.ts +4 -0
  149. package/dist/validate-media-props.js +24 -0
  150. package/dist/validate-start-from-props.d.ts +1 -0
  151. package/dist/validate-start-from-props.js +31 -0
  152. package/dist/validation/validate-composition-id.d.ts +3 -0
  153. package/dist/validation/validate-composition-id.js +13 -0
  154. package/dist/validation/validate-dimensions.d.ts +1 -0
  155. package/dist/validation/validate-dimensions.js +21 -0
  156. package/dist/validation/validate-duration-in-frames.d.ts +1 -0
  157. package/dist/validation/validate-duration-in-frames.js +15 -0
  158. package/dist/validation/validate-folder-name.d.ts +3 -0
  159. package/dist/validation/validate-folder-name.js +19 -0
  160. package/dist/validation/validate-fps.d.ts +1 -0
  161. package/dist/validation/validate-fps.js +21 -0
  162. package/dist/validation/validate-offthreadvideo-image-format.d.ts +1 -0
  163. package/dist/validation/validate-offthreadvideo-image-format.js +15 -0
  164. package/dist/validation/validation-spring-duration.d.ts +1 -0
  165. package/dist/validation/validation-spring-duration.js +21 -0
  166. package/dist/version.d.ts +1 -0
  167. package/dist/version.js +5 -0
  168. package/dist/video/OffthreadVideo.d.ts +3 -0
  169. package/dist/video/OffthreadVideo.js +33 -0
  170. package/dist/video/OffthreadVideoForRendering.d.ts +3 -0
  171. package/dist/video/OffthreadVideoForRendering.js +104 -0
  172. package/dist/video/Video.d.ts +8 -0
  173. package/dist/video/Video.js +50 -0
  174. package/dist/video/VideoForDevelopment.d.ts +11 -0
  175. package/dist/video/VideoForDevelopment.js +113 -0
  176. package/dist/video/VideoForRendering.d.ts +10 -0
  177. package/dist/video/VideoForRendering.js +203 -0
  178. package/dist/video/duration-state.d.ts +17 -0
  179. package/dist/video/duration-state.js +34 -0
  180. package/dist/video/get-current-time.d.ts +13 -0
  181. package/dist/video/get-current-time.js +31 -0
  182. package/dist/video/index.d.ts +3 -0
  183. package/dist/video/index.js +7 -0
  184. package/dist/video/props.d.ts +25 -0
  185. package/dist/video/props.js +2 -0
  186. package/dist/video/video-fragment.d.ts +12 -0
  187. package/dist/video/video-fragment.js +60 -0
  188. package/dist/video-config.d.ts +8 -0
  189. package/dist/video-config.js +2 -0
  190. package/dist/volume-position-state.d.ts +19 -0
  191. package/dist/volume-position-state.js +32 -0
  192. package/dist/volume-prop.d.ts +7 -0
  193. package/dist/volume-prop.js +24 -0
  194. package/dist/warn-about-non-seekable-media.d.ts +1 -0
  195. package/dist/warn-about-non-seekable-media.js +34 -0
  196. package/dist/wrap-remotion-context.d.ts +18 -0
  197. package/dist/wrap-remotion-context.js +73 -0
  198. package/package.json +4 -5
@@ -0,0 +1,104 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.OffthreadVideoForRendering = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const react_1 = require("react");
6
+ const absolute_src_1 = require("../absolute-src");
7
+ const use_audio_frame_1 = require("../audio/use-audio-frame");
8
+ const CompositionManager_1 = require("../CompositionManager");
9
+ const default_css_1 = require("../default-css");
10
+ const Img_1 = require("../Img");
11
+ const internals_1 = require("../internals");
12
+ const random_1 = require("../random");
13
+ const Sequence_1 = require("../Sequence");
14
+ const timeline_position_state_1 = require("../timeline-position-state");
15
+ const use_current_frame_1 = require("../use-current-frame");
16
+ const use_unsafe_video_config_1 = require("../use-unsafe-video-config");
17
+ const volume_prop_1 = require("../volume-prop");
18
+ const get_current_time_1 = require("./get-current-time");
19
+ const DEFAULT_IMAGE_FORMAT = 'jpeg';
20
+ const OffthreadVideoForRendering = ({ onError, volume: volumeProp, playbackRate, src, muted, imageFormat, allowAmplificationDuringRender, ...props }) => {
21
+ const absoluteFrame = (0, timeline_position_state_1.useTimelinePosition)();
22
+ const frame = (0, use_current_frame_1.useCurrentFrame)();
23
+ const volumePropsFrame = (0, use_audio_frame_1.useFrameForVolumeProp)();
24
+ const videoConfig = (0, use_unsafe_video_config_1.useUnsafeVideoConfig)();
25
+ const sequenceContext = (0, react_1.useContext)(Sequence_1.SequenceContext);
26
+ const mediaStartsAt = (0, use_audio_frame_1.useMediaStartsAt)();
27
+ const { registerAsset, unregisterAsset } = (0, react_1.useContext)(CompositionManager_1.CompositionManager);
28
+ if (!src) {
29
+ throw new TypeError('No `src` was passed to <OffthreadVideo>.');
30
+ }
31
+ // Generate a string that's as unique as possible for this asset
32
+ // but at the same time the same on all threads
33
+ const id = (0, react_1.useMemo)(() => `offthreadvideo-${(0, random_1.random)(src !== null && src !== void 0 ? src : '')}-${sequenceContext === null || sequenceContext === void 0 ? void 0 : sequenceContext.cumulatedFrom}-${sequenceContext === null || sequenceContext === void 0 ? void 0 : sequenceContext.relativeFrom}-${sequenceContext === null || sequenceContext === void 0 ? void 0 : sequenceContext.durationInFrames}`, [
34
+ src,
35
+ sequenceContext === null || sequenceContext === void 0 ? void 0 : sequenceContext.cumulatedFrom,
36
+ sequenceContext === null || sequenceContext === void 0 ? void 0 : sequenceContext.relativeFrom,
37
+ sequenceContext === null || sequenceContext === void 0 ? void 0 : sequenceContext.durationInFrames,
38
+ ]);
39
+ if (!videoConfig) {
40
+ throw new Error('No video config found');
41
+ }
42
+ const volume = (0, volume_prop_1.evaluateVolume)({
43
+ volume: volumeProp,
44
+ frame: volumePropsFrame,
45
+ mediaVolume: 1,
46
+ allowAmplificationDuringRender: allowAmplificationDuringRender !== null && allowAmplificationDuringRender !== void 0 ? allowAmplificationDuringRender : false,
47
+ });
48
+ (0, react_1.useEffect)(() => {
49
+ if (!src) {
50
+ throw new Error('No src passed');
51
+ }
52
+ if (!window.remotion_videoEnabled) {
53
+ return;
54
+ }
55
+ if (muted) {
56
+ return;
57
+ }
58
+ if (volume <= 0) {
59
+ return;
60
+ }
61
+ registerAsset({
62
+ type: 'video',
63
+ src: (0, absolute_src_1.getAbsoluteSrc)(src),
64
+ id,
65
+ frame: absoluteFrame,
66
+ volume,
67
+ mediaFrame: frame,
68
+ playbackRate: playbackRate !== null && playbackRate !== void 0 ? playbackRate : 1,
69
+ allowAmplificationDuringRender: allowAmplificationDuringRender !== null && allowAmplificationDuringRender !== void 0 ? allowAmplificationDuringRender : false,
70
+ });
71
+ return () => unregisterAsset(id);
72
+ }, [
73
+ muted,
74
+ src,
75
+ registerAsset,
76
+ id,
77
+ unregisterAsset,
78
+ volume,
79
+ frame,
80
+ absoluteFrame,
81
+ playbackRate,
82
+ allowAmplificationDuringRender,
83
+ ]);
84
+ const currentTime = (0, react_1.useMemo)(() => {
85
+ return ((0, get_current_time_1.getExpectedMediaFrameUncorrected)({
86
+ frame,
87
+ playbackRate: playbackRate || 1,
88
+ startFrom: -mediaStartsAt,
89
+ }) / videoConfig.fps);
90
+ }, [frame, mediaStartsAt, playbackRate, videoConfig.fps]);
91
+ const actualSrc = (0, react_1.useMemo)(() => {
92
+ return `http://localhost:${window.remotion_proxyPort}/proxy?src=${encodeURIComponent((0, absolute_src_1.getAbsoluteSrc)(src))}&time=${encodeURIComponent(currentTime)}&imageFormat=${imageFormat !== null && imageFormat !== void 0 ? imageFormat : DEFAULT_IMAGE_FORMAT}`;
93
+ }, [currentTime, imageFormat, src]);
94
+ const onErr = (0, react_1.useCallback)((e) => {
95
+ onError === null || onError === void 0 ? void 0 : onError(e);
96
+ }, [onError]);
97
+ const className = (0, react_1.useMemo)(() => {
98
+ return [default_css_1.OFFTHREAD_VIDEO_CLASS_NAME, props.className]
99
+ .filter(internals_1.Internals.truthy)
100
+ .join(' ');
101
+ }, [props.className]);
102
+ return ((0, jsx_runtime_1.jsx)(Img_1.Img, { src: actualSrc, className: className, ...props, onError: onErr }));
103
+ };
104
+ exports.OffthreadVideoForRendering = OffthreadVideoForRendering;
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ import type { RemotionMainVideoProps } from './props';
3
+ export declare const Video: (props: Omit<React.DetailedHTMLProps<React.VideoHTMLAttributes<HTMLVideoElement>, HTMLVideoElement>, "nonce" | "autoPlay" | "controls" | "onEnded"> & {
4
+ volume?: import("../volume-prop").VolumeProp | undefined;
5
+ playbackRate?: number | undefined;
6
+ acceptableTimeShiftInSeconds?: number | undefined;
7
+ allowAmplificationDuringRender?: boolean | undefined;
8
+ } & RemotionMainVideoProps & React.RefAttributes<HTMLVideoElement | null>) => React.ReactElement | null;
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Video = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const react_1 = require("react");
6
+ const get_environment_1 = require("../get-environment");
7
+ const loop_1 = require("../loop");
8
+ const Sequence_1 = require("../Sequence");
9
+ const use_video_config_1 = require("../use-video-config");
10
+ const validate_media_props_1 = require("../validate-media-props");
11
+ const validate_start_from_props_1 = require("../validate-start-from-props");
12
+ const duration_state_1 = require("./duration-state");
13
+ const VideoForDevelopment_1 = require("./VideoForDevelopment");
14
+ const VideoForRendering_1 = require("./VideoForRendering");
15
+ const VideoForwardingFunction = (props, ref) => {
16
+ var _a;
17
+ const { startFrom, endAt, ...otherProps } = props;
18
+ const { loop, ...propsOtherThanLoop } = props;
19
+ const { fps } = (0, use_video_config_1.useVideoConfig)();
20
+ const environment = (0, get_environment_1.useRemotionEnvironment)();
21
+ const { durations, setDurations } = (0, react_1.useContext)(duration_state_1.DurationsContext);
22
+ if (typeof ref === 'string') {
23
+ throw new Error('string refs are not supported');
24
+ }
25
+ if (typeof props.src !== 'string') {
26
+ throw new TypeError(`The \`<Video>\` tag requires a string for \`src\`, but got ${JSON.stringify(props.src)} instead.`);
27
+ }
28
+ const onDuration = (0, react_1.useCallback)((src, durationInSeconds) => {
29
+ setDurations({ type: 'got-duration', durationInSeconds, src });
30
+ }, [setDurations]);
31
+ if (loop && props.src && durations[props.src] !== undefined) {
32
+ const naturalDuration = durations[props.src] * fps;
33
+ const playbackRate = (_a = props.playbackRate) !== null && _a !== void 0 ? _a : 1;
34
+ const durationInFrames = Math.floor(naturalDuration / playbackRate);
35
+ return ((0, jsx_runtime_1.jsx)(loop_1.Loop, { durationInFrames: durationInFrames, children: (0, jsx_runtime_1.jsx)(exports.Video, { ...propsOtherThanLoop, ref: ref }) }));
36
+ }
37
+ if (typeof startFrom !== 'undefined' || typeof endAt !== 'undefined') {
38
+ (0, validate_start_from_props_1.validateStartFromProps)(startFrom, endAt);
39
+ const startFromFrameNo = startFrom !== null && startFrom !== void 0 ? startFrom : 0;
40
+ const endAtFrameNo = endAt !== null && endAt !== void 0 ? endAt : Infinity;
41
+ return ((0, jsx_runtime_1.jsx)(Sequence_1.Sequence, { layout: "none", from: 0 - startFromFrameNo, showInTimeline: false, durationInFrames: endAtFrameNo, children: (0, jsx_runtime_1.jsx)(exports.Video, { ...otherProps, ref: ref }) }));
42
+ }
43
+ (0, validate_media_props_1.validateMediaProps)(props, 'Video');
44
+ if (environment === 'rendering') {
45
+ return ((0, jsx_runtime_1.jsx)(VideoForRendering_1.VideoForRendering, { onDuration: onDuration, ...otherProps, ref: ref }));
46
+ }
47
+ return ((0, jsx_runtime_1.jsx)(VideoForDevelopment_1.VideoForDevelopment, { onlyWarnForMediaSeekingError: false, ...otherProps, ref: ref, onDuration: onDuration }));
48
+ };
49
+ const forward = react_1.forwardRef;
50
+ exports.Video = forward(VideoForwardingFunction);
@@ -0,0 +1,11 @@
1
+ import type { ForwardRefExoticComponent, RefAttributes } from 'react';
2
+ import React from 'react';
3
+ export declare const VideoForDevelopment: ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.VideoHTMLAttributes<HTMLVideoElement>, HTMLVideoElement>, "nonce" | "autoPlay" | "controls" | "onEnded"> & {
4
+ volume?: import("../volume-prop").VolumeProp | undefined;
5
+ playbackRate?: number | undefined;
6
+ acceptableTimeShiftInSeconds?: number | undefined;
7
+ allowAmplificationDuringRender?: boolean | undefined;
8
+ } & {
9
+ onlyWarnForMediaSeekingError: boolean;
10
+ onDuration: (src: string, durationInSeconds: number) => void;
11
+ } & RefAttributes<HTMLVideoElement>>;
@@ -0,0 +1,113 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.VideoForDevelopment = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const react_1 = require("react");
6
+ const use_audio_frame_1 = require("../audio/use-audio-frame");
7
+ const prefetch_1 = require("../prefetch");
8
+ const Sequence_1 = require("../Sequence");
9
+ const use_media_in_timeline_1 = require("../use-media-in-timeline");
10
+ const use_media_playback_1 = require("../use-media-playback");
11
+ const use_media_tag_volume_1 = require("../use-media-tag-volume");
12
+ const use_sync_volume_with_media_tag_1 = require("../use-sync-volume-with-media-tag");
13
+ const use_video_config_1 = require("../use-video-config");
14
+ const volume_position_state_1 = require("../volume-position-state");
15
+ const video_fragment_1 = require("./video-fragment");
16
+ const VideoForDevelopmentRefForwardingFunction = (props, ref) => {
17
+ var _a, _b;
18
+ const videoRef = (0, react_1.useRef)(null);
19
+ const volumePropFrame = (0, use_audio_frame_1.useFrameForVolumeProp)();
20
+ const { fps, durationInFrames } = (0, use_video_config_1.useVideoConfig)();
21
+ const parentSequence = (0, react_1.useContext)(Sequence_1.SequenceContext);
22
+ const { volume, muted, playbackRate, onlyWarnForMediaSeekingError, src, onDuration,
23
+ // @ts-expect-error
24
+ acceptableTimeShift, acceptableTimeShiftInSeconds, ...nativeProps } = props;
25
+ if (typeof acceptableTimeShift !== 'undefined') {
26
+ throw new Error('acceptableTimeShift has been removed. Use acceptableTimeShiftInSeconds instead.');
27
+ }
28
+ const actualVolume = (0, use_media_tag_volume_1.useMediaTagVolume)(videoRef);
29
+ const [mediaVolume] = (0, volume_position_state_1.useMediaVolumeState)();
30
+ const [mediaMuted] = (0, volume_position_state_1.useMediaMutedState)();
31
+ (0, use_media_in_timeline_1.useMediaInTimeline)({
32
+ mediaRef: videoRef,
33
+ volume,
34
+ mediaVolume,
35
+ mediaType: 'video',
36
+ src,
37
+ playbackRate: (_a = props.playbackRate) !== null && _a !== void 0 ? _a : 1,
38
+ });
39
+ (0, use_sync_volume_with_media_tag_1.useSyncVolumeWithMediaTag)({
40
+ volumePropFrame,
41
+ actualVolume,
42
+ volume,
43
+ mediaVolume,
44
+ mediaRef: videoRef,
45
+ });
46
+ (0, use_media_playback_1.useMediaPlayback)({
47
+ mediaRef: videoRef,
48
+ src,
49
+ mediaType: 'video',
50
+ playbackRate: (_b = props.playbackRate) !== null && _b !== void 0 ? _b : 1,
51
+ onlyWarnForMediaSeekingError,
52
+ acceptableTimeshift: acceptableTimeShiftInSeconds !== null && acceptableTimeShiftInSeconds !== void 0 ? acceptableTimeShiftInSeconds : use_media_playback_1.DEFAULT_ACCEPTABLE_TIMESHIFT,
53
+ });
54
+ const actualFrom = parentSequence
55
+ ? parentSequence.relativeFrom + parentSequence.cumulatedFrom
56
+ : 0;
57
+ const duration = parentSequence
58
+ ? Math.min(parentSequence.durationInFrames, durationInFrames)
59
+ : durationInFrames;
60
+ const actualSrc = (0, video_fragment_1.useAppendVideoFragment)({
61
+ actualSrc: (0, prefetch_1.usePreload)(src),
62
+ actualFrom,
63
+ duration,
64
+ fps,
65
+ });
66
+ (0, react_1.useImperativeHandle)(ref, () => {
67
+ return videoRef.current;
68
+ }, []);
69
+ (0, react_1.useEffect)(() => {
70
+ const { current } = videoRef;
71
+ if (!current) {
72
+ return;
73
+ }
74
+ const errorHandler = () => {
75
+ var _a;
76
+ if (current === null || current === void 0 ? void 0 : current.error) {
77
+ console.error('Error occurred in video', current === null || current === void 0 ? void 0 : current.error);
78
+ throw new Error(`The browser threw an error while playing the video ${src}: Code ${current.error.code} - ${(_a = current === null || current === void 0 ? void 0 : current.error) === null || _a === void 0 ? void 0 : _a.message}. See https://remotion.dev/docs/media-playback-error for help`);
79
+ }
80
+ else {
81
+ throw new Error('The browser threw an error');
82
+ }
83
+ };
84
+ current.addEventListener('error', errorHandler, { once: true });
85
+ return () => {
86
+ current.removeEventListener('error', errorHandler);
87
+ };
88
+ }, [src]);
89
+ const currentOnDurationCallback = (0, react_1.useRef)();
90
+ currentOnDurationCallback.current = onDuration;
91
+ (0, react_1.useEffect)(() => {
92
+ var _a;
93
+ const { current } = videoRef;
94
+ if (!current) {
95
+ return;
96
+ }
97
+ if (current.duration) {
98
+ (_a = currentOnDurationCallback.current) === null || _a === void 0 ? void 0 : _a.call(currentOnDurationCallback, src, current.duration);
99
+ return;
100
+ }
101
+ const onLoadedMetadata = () => {
102
+ var _a;
103
+ (_a = currentOnDurationCallback.current) === null || _a === void 0 ? void 0 : _a.call(currentOnDurationCallback, src, current.duration);
104
+ };
105
+ current.addEventListener('loadedmetadata', onLoadedMetadata);
106
+ return () => {
107
+ current.removeEventListener('loadedmetadata', onLoadedMetadata);
108
+ };
109
+ }, [src]);
110
+ return ((0, jsx_runtime_1.jsx)("video", { ref: videoRef, muted: muted || mediaMuted, playsInline: true, src: actualSrc, ...nativeProps }));
111
+ };
112
+ // Copy types from forwardRef but not necessary to remove ref
113
+ exports.VideoForDevelopment = (0, react_1.forwardRef)(VideoForDevelopmentRefForwardingFunction);
@@ -0,0 +1,10 @@
1
+ import type { ForwardRefExoticComponent, RefAttributes } from 'react';
2
+ import React from 'react';
3
+ export declare const VideoForRendering: ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.VideoHTMLAttributes<HTMLVideoElement>, HTMLVideoElement>, "nonce" | "autoPlay" | "controls" | "onEnded"> & {
4
+ volume?: import("../volume-prop").VolumeProp | undefined;
5
+ playbackRate?: number | undefined;
6
+ acceptableTimeShiftInSeconds?: number | undefined;
7
+ allowAmplificationDuringRender?: boolean | undefined;
8
+ } & {
9
+ onDuration: (src: string, durationInSeconds: number) => void;
10
+ } & RefAttributes<HTMLVideoElement>>;
@@ -0,0 +1,203 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.VideoForRendering = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const react_1 = require("react");
6
+ const absolute_src_1 = require("../absolute-src");
7
+ const use_audio_frame_1 = require("../audio/use-audio-frame");
8
+ const CompositionManager_1 = require("../CompositionManager");
9
+ const delay_render_1 = require("../delay-render");
10
+ const get_environment_1 = require("../get-environment");
11
+ const is_approximately_the_same_1 = require("../is-approximately-the-same");
12
+ const random_1 = require("../random");
13
+ const Sequence_1 = require("../Sequence");
14
+ const timeline_position_state_1 = require("../timeline-position-state");
15
+ const use_current_frame_1 = require("../use-current-frame");
16
+ const use_unsafe_video_config_1 = require("../use-unsafe-video-config");
17
+ const volume_prop_1 = require("../volume-prop");
18
+ const warn_about_non_seekable_media_1 = require("../warn-about-non-seekable-media");
19
+ const get_current_time_1 = require("./get-current-time");
20
+ const VideoForRenderingForwardFunction = ({ onError, volume: volumeProp, allowAmplificationDuringRender, playbackRate, onDuration, ...props }, ref) => {
21
+ const absoluteFrame = (0, timeline_position_state_1.useTimelinePosition)();
22
+ const frame = (0, use_current_frame_1.useCurrentFrame)();
23
+ const volumePropsFrame = (0, use_audio_frame_1.useFrameForVolumeProp)();
24
+ const videoConfig = (0, use_unsafe_video_config_1.useUnsafeVideoConfig)();
25
+ const videoRef = (0, react_1.useRef)(null);
26
+ const sequenceContext = (0, react_1.useContext)(Sequence_1.SequenceContext);
27
+ const mediaStartsAt = (0, use_audio_frame_1.useMediaStartsAt)();
28
+ const environment = (0, get_environment_1.useRemotionEnvironment)();
29
+ const { registerAsset, unregisterAsset } = (0, react_1.useContext)(CompositionManager_1.CompositionManager);
30
+ // Generate a string that's as unique as possible for this asset
31
+ // but at the same time the same on all threads
32
+ const id = (0, react_1.useMemo)(() => {
33
+ var _a;
34
+ return `video-${(0, random_1.random)((_a = props.src) !== null && _a !== void 0 ? _a : '')}-${sequenceContext === null || sequenceContext === void 0 ? void 0 : sequenceContext.cumulatedFrom}-${sequenceContext === null || sequenceContext === void 0 ? void 0 : sequenceContext.relativeFrom}-${sequenceContext === null || sequenceContext === void 0 ? void 0 : sequenceContext.durationInFrames}`;
35
+ }, [
36
+ props.src,
37
+ sequenceContext === null || sequenceContext === void 0 ? void 0 : sequenceContext.cumulatedFrom,
38
+ sequenceContext === null || sequenceContext === void 0 ? void 0 : sequenceContext.relativeFrom,
39
+ sequenceContext === null || sequenceContext === void 0 ? void 0 : sequenceContext.durationInFrames,
40
+ ]);
41
+ if (!videoConfig) {
42
+ throw new Error('No video config found');
43
+ }
44
+ const volume = (0, volume_prop_1.evaluateVolume)({
45
+ volume: volumeProp,
46
+ frame: volumePropsFrame,
47
+ mediaVolume: 1,
48
+ allowAmplificationDuringRender: allowAmplificationDuringRender !== null && allowAmplificationDuringRender !== void 0 ? allowAmplificationDuringRender : false,
49
+ });
50
+ (0, react_1.useEffect)(() => {
51
+ if (!props.src) {
52
+ throw new Error('No src passed');
53
+ }
54
+ if (props.muted) {
55
+ return;
56
+ }
57
+ if (volume <= 0) {
58
+ return;
59
+ }
60
+ if (!window.remotion_audioEnabled) {
61
+ return;
62
+ }
63
+ registerAsset({
64
+ type: 'video',
65
+ src: (0, absolute_src_1.getAbsoluteSrc)(props.src),
66
+ id,
67
+ frame: absoluteFrame,
68
+ volume,
69
+ mediaFrame: frame,
70
+ playbackRate: playbackRate !== null && playbackRate !== void 0 ? playbackRate : 1,
71
+ allowAmplificationDuringRender: allowAmplificationDuringRender !== null && allowAmplificationDuringRender !== void 0 ? allowAmplificationDuringRender : false,
72
+ });
73
+ return () => unregisterAsset(id);
74
+ }, [
75
+ props.muted,
76
+ props.src,
77
+ registerAsset,
78
+ id,
79
+ unregisterAsset,
80
+ volume,
81
+ frame,
82
+ absoluteFrame,
83
+ playbackRate,
84
+ allowAmplificationDuringRender,
85
+ ]);
86
+ (0, react_1.useImperativeHandle)(ref, () => {
87
+ return videoRef.current;
88
+ }, []);
89
+ (0, react_1.useEffect)(() => {
90
+ if (!window.remotion_videoEnabled) {
91
+ return;
92
+ }
93
+ const { current } = videoRef;
94
+ if (!current) {
95
+ return;
96
+ }
97
+ const currentTime = (() => {
98
+ return (0, get_current_time_1.getMediaTime)({
99
+ fps: videoConfig.fps,
100
+ frame,
101
+ src: props.src,
102
+ playbackRate: playbackRate || 1,
103
+ startFrom: -mediaStartsAt,
104
+ mediaType: 'video',
105
+ });
106
+ })();
107
+ const handle = (0, delay_render_1.delayRender)(`Rendering <Video /> with src="${props.src}"`);
108
+ if (process.env.NODE_ENV === 'test') {
109
+ (0, delay_render_1.continueRender)(handle);
110
+ return;
111
+ }
112
+ if ((0, is_approximately_the_same_1.isApproximatelyTheSame)(current.currentTime, currentTime)) {
113
+ if (current.readyState >= 2) {
114
+ (0, delay_render_1.continueRender)(handle);
115
+ return;
116
+ }
117
+ const loadedDataHandler = () => {
118
+ (0, delay_render_1.continueRender)(handle);
119
+ };
120
+ current.addEventListener('loadeddata', loadedDataHandler, { once: true });
121
+ return () => {
122
+ current.removeEventListener('loadeddata', loadedDataHandler);
123
+ };
124
+ }
125
+ current.currentTime = currentTime;
126
+ const seekedHandler = () => {
127
+ (0, warn_about_non_seekable_media_1.warnAboutNonSeekableMedia)(current, 'exception');
128
+ if (window.navigator.platform.startsWith('Mac')) {
129
+ // Improve me: This is ensures frame perfectness but slows down render.
130
+ // Please see this issue for context: https://github.com/remotion-dev/remotion/issues/200
131
+ // Only affects macOS since it uses VideoToolbox decoding.
132
+ setTimeout(() => {
133
+ (0, delay_render_1.continueRender)(handle);
134
+ }, 100);
135
+ }
136
+ else {
137
+ (0, delay_render_1.continueRender)(handle);
138
+ }
139
+ };
140
+ current.addEventListener('seeked', seekedHandler, { once: true });
141
+ const endedHandler = () => {
142
+ (0, delay_render_1.continueRender)(handle);
143
+ };
144
+ current.addEventListener('ended', endedHandler, { once: true });
145
+ const errorHandler = () => {
146
+ var _a;
147
+ if (current === null || current === void 0 ? void 0 : current.error) {
148
+ console.error('Error occurred in video', current === null || current === void 0 ? void 0 : current.error);
149
+ throw new Error(`The browser threw an error while playing the video ${props.src}: Code ${current.error.code} - ${(_a = current === null || current === void 0 ? void 0 : current.error) === null || _a === void 0 ? void 0 : _a.message}. See https://remotion.dev/docs/media-playback-error for help`);
150
+ }
151
+ else {
152
+ throw new Error('The browser threw an error');
153
+ }
154
+ };
155
+ current.addEventListener('error', errorHandler, { once: true });
156
+ // If video skips to another frame or unmounts, we clear the created handle
157
+ return () => {
158
+ current.removeEventListener('ended', endedHandler);
159
+ current.removeEventListener('error', errorHandler);
160
+ current.removeEventListener('seeked', seekedHandler);
161
+ (0, delay_render_1.continueRender)(handle);
162
+ };
163
+ }, [
164
+ volumePropsFrame,
165
+ props.src,
166
+ playbackRate,
167
+ videoConfig.fps,
168
+ frame,
169
+ mediaStartsAt,
170
+ ]);
171
+ const { src } = props;
172
+ // If video source switches, make new handle
173
+ if (environment === 'rendering') {
174
+ // eslint-disable-next-line react-hooks/rules-of-hooks
175
+ (0, react_1.useLayoutEffect)(() => {
176
+ if (process.env.NODE_ENV === 'test') {
177
+ return;
178
+ }
179
+ const newHandle = (0, delay_render_1.delayRender)('Loading <Video> duration with src=' + src);
180
+ const { current } = videoRef;
181
+ const didLoad = () => {
182
+ if (current === null || current === void 0 ? void 0 : current.duration) {
183
+ onDuration(src, current.duration);
184
+ }
185
+ (0, delay_render_1.continueRender)(newHandle);
186
+ };
187
+ if (current === null || current === void 0 ? void 0 : current.duration) {
188
+ onDuration(src, current.duration);
189
+ (0, delay_render_1.continueRender)(newHandle);
190
+ }
191
+ else {
192
+ current === null || current === void 0 ? void 0 : current.addEventListener('loadedmetadata', didLoad, { once: true });
193
+ }
194
+ // If tag gets unmounted, clear pending handles because video metadata is not going to load
195
+ return () => {
196
+ current === null || current === void 0 ? void 0 : current.removeEventListener('loadedmetadata', didLoad);
197
+ (0, delay_render_1.continueRender)(newHandle);
198
+ };
199
+ }, [src, onDuration]);
200
+ }
201
+ return (0, jsx_runtime_1.jsx)("video", { ref: videoRef, ...props, onError: onError });
202
+ };
203
+ exports.VideoForRendering = (0, react_1.forwardRef)(VideoForRenderingForwardFunction);
@@ -0,0 +1,17 @@
1
+ import React from 'react';
2
+ declare type DurationState = Record<string, number>;
3
+ declare type DurationAction = {
4
+ type: 'got-duration';
5
+ src: string;
6
+ durationInSeconds: number;
7
+ };
8
+ export declare const durationReducer: (state: DurationState, action: DurationAction) => DurationState;
9
+ declare type TDurationsContext = {
10
+ durations: DurationState;
11
+ setDurations: React.Dispatch<DurationAction>;
12
+ };
13
+ export declare const DurationsContext: React.Context<TDurationsContext>;
14
+ export declare const DurationsContextProvider: React.FC<{
15
+ children: React.ReactNode;
16
+ }>;
17
+ export {};
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DurationsContextProvider = exports.DurationsContext = exports.durationReducer = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const react_1 = require("react");
6
+ const durationReducer = (state, action) => {
7
+ switch (action.type) {
8
+ case 'got-duration':
9
+ return {
10
+ ...state,
11
+ [action.src]: action.durationInSeconds,
12
+ };
13
+ default:
14
+ return state;
15
+ }
16
+ };
17
+ exports.durationReducer = durationReducer;
18
+ exports.DurationsContext = (0, react_1.createContext)({
19
+ durations: {},
20
+ setDurations: () => {
21
+ throw new Error('context missing');
22
+ },
23
+ });
24
+ const DurationsContextProvider = ({ children }) => {
25
+ const [durations, setDurations] = (0, react_1.useReducer)(exports.durationReducer, {});
26
+ const value = (0, react_1.useMemo)(() => {
27
+ return {
28
+ durations,
29
+ setDurations,
30
+ };
31
+ }, [durations]);
32
+ return ((0, jsx_runtime_1.jsx)(exports.DurationsContext.Provider, { value: value, children: children }));
33
+ };
34
+ exports.DurationsContextProvider = DurationsContextProvider;
@@ -0,0 +1,13 @@
1
+ export declare const getExpectedMediaFrameUncorrected: ({ frame, playbackRate, startFrom, }: {
2
+ frame: number;
3
+ playbackRate: number;
4
+ startFrom: number;
5
+ }) => number;
6
+ export declare const getMediaTime: ({ fps, frame, src, playbackRate, startFrom, mediaType, }: {
7
+ fps: number;
8
+ frame: number;
9
+ src: string;
10
+ playbackRate: number;
11
+ startFrom: number;
12
+ mediaType: 'video' | 'audio';
13
+ }) => number;
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ // Calculate the `.currentTime` of a video or audio element
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.getMediaTime = exports.getExpectedMediaFrameUncorrected = void 0;
5
+ const interpolate_1 = require("../interpolate");
6
+ const getExpectedMediaFrameUncorrected = ({ frame, playbackRate, startFrom, }) => {
7
+ return (0, interpolate_1.interpolate)(frame, [-1, startFrom, startFrom + 1], [-1, startFrom, startFrom + playbackRate]);
8
+ };
9
+ exports.getExpectedMediaFrameUncorrected = getExpectedMediaFrameUncorrected;
10
+ const getMediaTime = ({ fps, frame, src, playbackRate, startFrom, mediaType, }) => {
11
+ const expectedFrame = (0, exports.getExpectedMediaFrameUncorrected)({
12
+ frame,
13
+ playbackRate,
14
+ startFrom,
15
+ });
16
+ if (src.endsWith('webm')) {
17
+ // For WebM videos, we need to add a little bit of shift to get the right frame.
18
+ const msPerFrame = 1000 / fps;
19
+ const msShift = msPerFrame / 2;
20
+ return (expectedFrame * msPerFrame + msShift) / 1000;
21
+ }
22
+ if (mediaType === 'video') {
23
+ // In Chrome, for MP4s, if 30fps, the first frame is still displayed at 0.033333
24
+ // even though after that it increases by 0.033333333 each.
25
+ // So frame = 0 in Remotion is like frame = 1 for the browser
26
+ return (expectedFrame + 1) / fps;
27
+ }
28
+ // For audio, we don't do any shift correction
29
+ return expectedFrame / fps;
30
+ };
31
+ exports.getMediaTime = getMediaTime;
@@ -0,0 +1,3 @@
1
+ export { OffthreadVideo } from './OffthreadVideo';
2
+ export { OffthreadVideoImageFormat, OffthreadVideoProps as RemotionOffthreadVideoProps, RemotionMainVideoProps, RemotionVideoProps, } from './props';
3
+ export { Video } from './Video';
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Video = exports.OffthreadVideo = void 0;
4
+ var OffthreadVideo_1 = require("./OffthreadVideo");
5
+ Object.defineProperty(exports, "OffthreadVideo", { enumerable: true, get: function () { return OffthreadVideo_1.OffthreadVideo; } });
6
+ var Video_1 = require("./Video");
7
+ Object.defineProperty(exports, "Video", { enumerable: true, get: function () { return Video_1.Video; } });
@@ -0,0 +1,25 @@
1
+ import type React from 'react';
2
+ import type { VolumeProp } from '../volume-prop';
3
+ export declare type RemotionMainVideoProps = {
4
+ startFrom?: number;
5
+ endAt?: number;
6
+ };
7
+ export declare type RemotionVideoProps = Omit<React.DetailedHTMLProps<React.VideoHTMLAttributes<HTMLVideoElement>, HTMLVideoElement>, 'autoPlay' | 'controls' | 'onEnded' | 'nonce'> & {
8
+ volume?: VolumeProp;
9
+ playbackRate?: number;
10
+ acceptableTimeShiftInSeconds?: number;
11
+ allowAmplificationDuringRender?: boolean;
12
+ };
13
+ export declare type OffthreadVideoImageFormat = 'png' | 'jpeg';
14
+ export declare type OffthreadVideoProps = {
15
+ src: string;
16
+ className?: string;
17
+ style?: React.CSSProperties;
18
+ volume?: VolumeProp;
19
+ playbackRate?: number;
20
+ muted?: boolean;
21
+ onError?: React.ReactEventHandler<HTMLVideoElement | HTMLImageElement>;
22
+ imageFormat?: OffthreadVideoImageFormat;
23
+ acceptableTimeShiftInSeconds?: number;
24
+ allowAmplificationDuringRender?: boolean;
25
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });