remotion 4.0.0-webhook.26 → 4.0.0
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.
- package/LICENSE.md +8 -8
- package/README.md +7 -7
- package/dist/{AbsoluteFill.d.ts → cjs/AbsoluteFill.d.ts} +2 -2
- package/dist/{AbsoluteFill.js → cjs/AbsoluteFill.js} +2 -2
- package/dist/cjs/AssetManager.d.ts +11 -0
- package/dist/cjs/AssetManager.js +40 -0
- package/dist/{CanUseRemotionHooks.d.ts → cjs/CanUseRemotionHooks.d.ts} +0 -0
- package/dist/{CanUseRemotionHooks.js → cjs/CanUseRemotionHooks.js} +0 -0
- package/dist/cjs/Clipper.d.ts +7 -0
- package/dist/cjs/Clipper.js +24 -0
- package/dist/cjs/Composition.d.ts +56 -0
- package/dist/cjs/Composition.js +121 -0
- package/dist/cjs/CompositionManager.d.ts +74 -0
- package/dist/{CompositionManager.js → cjs/CompositionManager.js} +29 -66
- package/dist/cjs/CompositionManagerContext.d.ts +19 -0
- package/dist/cjs/CompositionManagerContext.js +16 -0
- package/dist/cjs/EditorProps.d.ts +15 -0
- package/dist/cjs/EditorProps.js +53 -0
- package/dist/{Folder.d.ts → cjs/Folder.d.ts} +6 -2
- package/dist/{Folder.js → cjs/Folder.js} +10 -6
- package/dist/{IFrame.d.ts → cjs/IFrame.d.ts} +4 -0
- package/dist/{IFrame.js → cjs/IFrame.js} +8 -4
- package/dist/cjs/Img.d.ts +9 -0
- package/dist/cjs/Img.js +100 -0
- package/dist/cjs/NativeLayers.d.ts +13 -0
- package/dist/cjs/NativeLayers.js +29 -0
- package/dist/cjs/Null.d.ts +2 -0
- package/dist/cjs/Null.js +25 -0
- package/dist/{RemotionRoot.d.ts → cjs/RemotionRoot.d.ts} +1 -0
- package/dist/cjs/RemotionRoot.js +74 -0
- package/dist/cjs/ResolveCompositionConfig.d.ts +24 -0
- package/dist/cjs/ResolveCompositionConfig.js +198 -0
- package/dist/cjs/Sequence.d.ts +22 -0
- package/dist/{Sequence.js → cjs/Sequence.js} +27 -29
- package/dist/cjs/SequenceContext.d.ts +9 -0
- package/dist/cjs/SequenceContext.js +5 -0
- package/dist/cjs/SequenceManager.d.ts +11 -0
- package/dist/cjs/SequenceManager.js +57 -0
- package/dist/cjs/Still.d.ts +8 -0
- package/dist/cjs/Still.js +22 -0
- package/dist/{absolute-src.d.ts → cjs/absolute-src.d.ts} +0 -0
- package/dist/{absolute-src.js → cjs/absolute-src.js} +0 -0
- package/dist/{asset-types.d.ts → cjs/asset-types.d.ts} +0 -0
- package/dist/{asset-types.js → cjs/asset-types.js} +0 -0
- package/dist/{audio → cjs/audio}/Audio.d.ts +10 -4
- package/dist/cjs/audio/Audio.js +58 -0
- package/dist/cjs/audio/AudioForDevelopment.d.ts +11 -0
- package/dist/cjs/audio/AudioForDevelopment.js +101 -0
- package/dist/cjs/audio/AudioForRendering.d.ts +10 -0
- package/dist/cjs/audio/AudioForRendering.js +111 -0
- package/dist/cjs/audio/index.d.ts +2 -0
- package/dist/{audio → cjs/audio}/index.js +2 -2
- package/dist/cjs/audio/props.d.ts +12 -0
- package/dist/{audio → cjs/audio}/props.js +0 -0
- package/dist/{audio → cjs/audio}/shared-audio-tags.d.ts +10 -4
- package/dist/{audio → cjs/audio}/shared-audio-tags.js +35 -13
- package/dist/{audio → cjs/audio}/use-audio-frame.d.ts +0 -0
- package/dist/{audio → cjs/audio}/use-audio-frame.js +4 -4
- package/dist/{bezier.d.ts → cjs/bezier.d.ts} +0 -0
- package/dist/{bezier.js → cjs/bezier.js} +0 -0
- package/dist/cjs/cancel-render.d.ts +5 -0
- package/dist/cjs/cancel-render.js +47 -0
- package/dist/{config → cjs/config}/input-props.d.ts +0 -0
- package/dist/{config → cjs/config}/input-props.js +3 -3
- package/dist/{default-css.d.ts → cjs/default-css.d.ts} +0 -0
- package/dist/{default-css.js → cjs/default-css.js} +0 -0
- package/dist/{delay-render.d.ts → cjs/delay-render.d.ts} +4 -4
- package/dist/{delay-render.js → cjs/delay-render.js} +12 -12
- package/dist/{easing.d.ts → cjs/easing.d.ts} +4 -0
- package/dist/{easing.js → cjs/easing.js} +6 -2
- package/dist/cjs/freeze.d.ts +11 -0
- package/dist/{freeze.js → cjs/freeze.js} +14 -6
- package/dist/{get-asset-file-name.d.ts → cjs/get-asset-file-name.d.ts} +0 -0
- package/dist/{get-asset-file-name.js → cjs/get-asset-file-name.js} +0 -0
- package/dist/cjs/get-environment.d.ts +3 -0
- package/dist/{get-environment.js → cjs/get-environment.js} +14 -2
- package/dist/cjs/get-preview-dom-element.d.ts +2 -0
- package/dist/cjs/get-preview-dom-element.js +8 -0
- package/dist/cjs/get-static-files.d.ts +21 -0
- package/dist/cjs/get-static-files.js +35 -0
- package/dist/{get-timeline-clip-name.d.ts → cjs/get-timeline-clip-name.d.ts} +0 -0
- package/dist/{get-timeline-clip-name.js → cjs/get-timeline-clip-name.js} +0 -0
- package/dist/cjs/index.d.ts +102 -0
- package/dist/cjs/index.js +105 -0
- package/dist/cjs/internals.d.ts +132 -0
- package/dist/cjs/internals.js +123 -0
- package/dist/{interpolate-colors.d.ts → cjs/interpolate-colors.d.ts} +5 -0
- package/dist/{interpolate-colors.js → cjs/interpolate-colors.js} +10 -10
- package/dist/{interpolate.d.ts → cjs/interpolate.d.ts} +11 -7
- package/dist/{interpolate.js → cjs/interpolate.js} +0 -0
- package/dist/{is-approximately-the-same.d.ts → cjs/is-approximately-the-same.d.ts} +0 -0
- package/dist/{is-approximately-the-same.js → cjs/is-approximately-the-same.js} +0 -0
- package/dist/cjs/is-player.d.ts +3 -0
- package/dist/cjs/is-player.js +14 -0
- package/dist/{loading-indicator.d.ts → cjs/loading-indicator.d.ts} +0 -0
- package/dist/{loading-indicator.js → cjs/loading-indicator.js} +4 -4
- package/dist/cjs/loop/index.d.ts +13 -0
- package/dist/cjs/loop/index.js +45 -0
- package/dist/{multiple-versions-warning.d.ts → cjs/multiple-versions-warning.d.ts} +0 -0
- package/dist/{multiple-versions-warning.js → cjs/multiple-versions-warning.js} +11 -6
- package/dist/{nonce.d.ts → cjs/nonce.d.ts} +1 -1
- package/dist/{nonce.js → cjs/nonce.js} +6 -0
- package/dist/{play-and-handle-not-allowed-error.d.ts → cjs/play-and-handle-not-allowed-error.d.ts} +0 -0
- package/dist/{play-and-handle-not-allowed-error.js → cjs/play-and-handle-not-allowed-error.js} +4 -0
- package/dist/{portal-node.d.ts → cjs/portal-node.d.ts} +0 -0
- package/dist/{portal-node.js → cjs/portal-node.js} +0 -0
- package/dist/cjs/prefetch-state.d.ts +8 -0
- package/dist/cjs/prefetch-state.js +27 -0
- package/dist/cjs/prefetch.d.ts +13 -0
- package/dist/{prefetch.js → cjs/prefetch.js} +43 -17
- package/dist/cjs/props-if-has-props.d.ts +10 -0
- package/dist/{video-config.js → cjs/props-if-has-props.js} +0 -0
- package/dist/cjs/random.d.ts +6 -0
- package/dist/{random.js → cjs/random.js} +3 -3
- package/dist/{register-root.d.ts → cjs/register-root.d.ts} +4 -0
- package/dist/{register-root.js → cjs/register-root.js} +4 -0
- package/dist/cjs/resolve-video-config.d.ts +8 -0
- package/dist/cjs/resolve-video-config.js +82 -0
- package/dist/cjs/series/flatten-children.d.ts +2 -0
- package/dist/{series → cjs/series}/flatten-children.js +0 -0
- package/dist/cjs/series/index.d.ts +17 -0
- package/dist/{series → cjs/series}/index.js +22 -9
- package/dist/cjs/setup-env-variables.d.ts +1 -0
- package/dist/{setup-env-variables.js → cjs/setup-env-variables.js} +7 -9
- package/dist/{spring → cjs/spring}/index.d.ts +10 -6
- package/dist/cjs/spring/index.js +75 -0
- package/dist/cjs/spring/measure-spring.d.ts +12 -0
- package/dist/{spring → cjs/spring}/measure-spring.js +8 -4
- package/dist/{spring → cjs/spring}/spring-utils.d.ts +2 -2
- package/dist/{spring → cjs/spring}/spring-utils.js +0 -0
- package/dist/cjs/static-file.d.ts +33 -0
- package/dist/cjs/static-file.js +87 -0
- package/dist/{timeline-position-state.d.ts → cjs/timeline-position-state.d.ts} +9 -7
- package/dist/cjs/timeline-position-state.js +67 -0
- package/dist/cjs/truthy.d.ts +3 -0
- package/dist/{truthy.js → cjs/truthy.js} +0 -0
- package/dist/cjs/use-current-frame.d.ts +5 -0
- package/dist/{use-current-frame.js → cjs/use-current-frame.js} +8 -9
- package/dist/cjs/use-lazy-component.d.ts +7 -0
- package/dist/{use-lazy-component.js → cjs/use-lazy-component.js} +0 -0
- package/dist/{use-media-in-timeline.d.ts → cjs/use-media-in-timeline.d.ts} +3 -2
- package/dist/{use-media-in-timeline.js → cjs/use-media-in-timeline.js} +29 -25
- package/dist/{use-media-playback.d.ts → cjs/use-media-playback.d.ts} +3 -1
- package/dist/cjs/use-media-playback.js +86 -0
- package/dist/{use-media-tag-volume.d.ts → cjs/use-media-tag-volume.d.ts} +0 -0
- package/dist/{use-media-tag-volume.js → cjs/use-media-tag-volume.js} +0 -0
- package/dist/{use-sync-volume-with-media-tag.d.ts → cjs/use-sync-volume-with-media-tag.d.ts} +2 -2
- package/dist/{use-sync-volume-with-media-tag.js → cjs/use-sync-volume-with-media-tag.js} +5 -4
- package/dist/{use-unsafe-video-config.d.ts → cjs/use-unsafe-video-config.d.ts} +1 -1
- package/dist/{use-unsafe-video-config.js → cjs/use-unsafe-video-config.js} +6 -5
- package/dist/cjs/use-video-config.d.ts +8 -0
- package/dist/cjs/use-video-config.js +34 -0
- package/dist/cjs/use-video.d.ts +7 -0
- package/dist/cjs/use-video.js +38 -0
- package/dist/cjs/validate-frame.d.ts +5 -0
- package/dist/cjs/validate-frame.js +24 -0
- package/dist/cjs/validate-media-props.d.ts +4 -0
- package/dist/{validate-media-props.js → cjs/validate-media-props.js} +0 -0
- package/dist/{validate-start-from-props.d.ts → cjs/validate-start-from-props.d.ts} +0 -0
- package/dist/{validate-start-from-props.js → cjs/validate-start-from-props.js} +0 -0
- package/dist/{validation → cjs/validation}/validate-composition-id.d.ts +0 -0
- package/dist/{validation → cjs/validation}/validate-composition-id.js +0 -0
- package/dist/cjs/validation/validate-default-props.d.ts +1 -0
- package/dist/cjs/validation/validate-default-props.js +15 -0
- package/dist/cjs/validation/validate-dimensions.d.ts +1 -0
- package/dist/{validation → cjs/validation}/validate-dimensions.js +2 -2
- package/dist/cjs/validation/validate-duration-in-frames.d.ts +4 -0
- package/dist/{validation → cjs/validation}/validate-duration-in-frames.js +10 -3
- package/dist/{validation → cjs/validation}/validate-folder-name.d.ts +0 -0
- package/dist/{validation → cjs/validation}/validate-folder-name.js +0 -0
- package/dist/cjs/validation/validate-fps.d.ts +1 -0
- package/dist/{validation → cjs/validation}/validate-fps.js +2 -2
- package/dist/{validation → cjs/validation}/validation-spring-duration.d.ts +0 -0
- package/dist/{validation → cjs/validation}/validation-spring-duration.js +0 -0
- package/dist/cjs/version.d.ts +1 -0
- package/dist/{version.js → cjs/version.js} +1 -1
- package/dist/cjs/video/OffthreadVideo.d.ts +7 -0
- package/dist/cjs/video/OffthreadVideo.js +40 -0
- package/dist/{video → cjs/video}/OffthreadVideoForRendering.d.ts +1 -1
- package/dist/cjs/video/OffthreadVideoForRendering.js +103 -0
- package/dist/cjs/video/Video.d.ts +12 -0
- package/dist/cjs/video/Video.js +55 -0
- package/dist/{video → cjs/video}/VideoForDevelopment.d.ts +5 -2
- package/dist/cjs/video/VideoForDevelopment.js +117 -0
- package/dist/cjs/video/VideoForRendering.d.ts +10 -0
- package/dist/cjs/video/VideoForRendering.js +208 -0
- package/dist/cjs/video/duration-state.d.ts +17 -0
- package/dist/cjs/video/duration-state.js +35 -0
- package/dist/{video → cjs/video}/get-current-time.d.ts +0 -0
- package/dist/{video → cjs/video}/get-current-time.js +12 -11
- package/dist/cjs/video/index.d.ts +3 -0
- package/dist/{video → cjs/video}/index.js +4 -4
- package/dist/cjs/video/props.d.ts +32 -0
- package/dist/cjs/video/props.js +2 -0
- package/dist/cjs/video/video-fragment.d.ts +12 -0
- package/dist/cjs/video/video-fragment.js +60 -0
- package/dist/cjs/video-config.d.ts +9 -0
- package/dist/{video/props.js → cjs/video-config.js} +0 -0
- package/dist/{volume-position-state.d.ts → cjs/volume-position-state.d.ts} +4 -4
- package/dist/{volume-position-state.js → cjs/volume-position-state.js} +0 -0
- package/dist/{volume-prop.d.ts → cjs/volume-prop.d.ts} +3 -2
- package/dist/{volume-prop.js → cjs/volume-prop.js} +4 -3
- package/dist/{warn-about-non-seekable-media.d.ts → cjs/warn-about-non-seekable-media.d.ts} +0 -0
- package/dist/{warn-about-non-seekable-media.js → cjs/warn-about-non-seekable-media.js} +2 -2
- package/dist/cjs/wrap-remotion-context.d.ts +31 -0
- package/dist/cjs/wrap-remotion-context.js +85 -0
- package/dist/esm/index.mjs +4643 -0
- package/dist/esm/version.mjs +4 -0
- package/package.json +80 -57
- package/version.js +2 -1
- package/.prettierrc.js +0 -14
- package/.turbo/turbo-build.log +0 -5
- package/dist/Composition.d.ts +0 -22
- package/dist/Composition.js +0 -98
- package/dist/CompositionManager.d.ts +0 -79
- package/dist/Img.d.ts +0 -2
- package/dist/Img.js +0 -51
- package/dist/RemotionRoot.js +0 -71
- package/dist/Sequence.d.ts +0 -29
- package/dist/Still.d.ts +0 -3
- package/dist/Still.js +0 -9
- package/dist/audio/Audio.js +0 -32
- package/dist/audio/AudioForDevelopment.d.ts +0 -8
- package/dist/audio/AudioForDevelopment.js +0 -71
- package/dist/audio/AudioForRendering.d.ts +0 -6
- package/dist/audio/AudioForRendering.js +0 -75
- package/dist/audio/index.d.ts +0 -2
- package/dist/audio/props.d.ts +0 -10
- package/dist/config.d.ts +0 -218
- package/dist/config.js +0 -21
- package/dist/freeze.d.ts +0 -7
- package/dist/get-environment.d.ts +0 -2
- package/dist/get-preview-dom-element.d.ts +0 -1
- package/dist/get-preview-dom-element.js +0 -7
- package/dist/index.d.ts +0 -72
- package/dist/index.js +0 -58
- package/dist/internals.d.ts +0 -88
- package/dist/internals.js +0 -93
- package/dist/loop/index.d.ts +0 -9
- package/dist/loop/index.js +0 -28
- package/dist/prefetch-state.d.ts +0 -13
- package/dist/prefetch-state.js +0 -26
- package/dist/prefetch.d.ts +0 -7
- package/dist/random.d.ts +0 -6
- package/dist/series/flatten-children.d.ts +0 -2
- package/dist/series/index.d.ts +0 -13
- package/dist/setup-env-variables.d.ts +0 -2
- package/dist/spring/index.js +0 -51
- package/dist/spring/measure-spring.d.ts +0 -8
- package/dist/static-file.d.ts +0 -1
- package/dist/static-file.js +0 -29
- package/dist/timeline-position-state.js +0 -41
- package/dist/truthy.d.ts +0 -3
- package/dist/use-current-frame.d.ts +0 -6
- package/dist/use-lazy-component.d.ts +0 -7
- package/dist/use-media-playback.js +0 -75
- package/dist/use-video-config.d.ts +0 -7
- package/dist/use-video-config.js +0 -26
- package/dist/use-video.d.ts +0 -13
- package/dist/use-video.js +0 -28
- package/dist/validate-media-props.d.ts +0 -4
- package/dist/validation/validate-dimensions.d.ts +0 -1
- package/dist/validation/validate-duration-in-frames.d.ts +0 -1
- package/dist/validation/validate-fps.d.ts +0 -1
- package/dist/validation/validate-offthreadvideo-image-format.d.ts +0 -1
- package/dist/validation/validate-offthreadvideo-image-format.js +0 -15
- package/dist/version.d.ts +0 -1
- package/dist/video/LoopedVideo.d.ts +0 -3
- package/dist/video/LoopedVideo.js +0 -16
- package/dist/video/OffthreadVideo.d.ts +0 -3
- package/dist/video/OffthreadVideo.js +0 -27
- package/dist/video/OffthreadVideoForRendering.js +0 -101
- package/dist/video/Video.d.ts +0 -6
- package/dist/video/Video.js +0 -29
- package/dist/video/VideoForDevelopment.js +0 -69
- package/dist/video/VideoForRendering.d.ts +0 -6
- package/dist/video/VideoForRendering.js +0 -168
- package/dist/video/duration-state.d.ts +0 -8
- package/dist/video/duration-state.js +0 -15
- package/dist/video/index.d.ts +0 -3
- package/dist/video/props.d.ts +0 -21
- package/dist/video-config.d.ts +0 -8
- package/dist/wrap-remotion-context.d.ts +0 -14
- package/dist/wrap-remotion-context.js +0 -65
- package/ensure-correct-version.js +0 -24
- package/tsconfig.json +0 -12
- package/version.d.ts +0 -1
|
@@ -0,0 +1,103 @@
|
|
|
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_js_1 = require("../absolute-src.js");
|
|
7
|
+
const AssetManager_js_1 = require("../AssetManager.js");
|
|
8
|
+
const use_audio_frame_js_1 = require("../audio/use-audio-frame.js");
|
|
9
|
+
const default_css_js_1 = require("../default-css.js");
|
|
10
|
+
const Img_js_1 = require("../Img.js");
|
|
11
|
+
const random_js_1 = require("../random.js");
|
|
12
|
+
const SequenceContext_js_1 = require("../SequenceContext.js");
|
|
13
|
+
const timeline_position_state_js_1 = require("../timeline-position-state.js");
|
|
14
|
+
const truthy_js_1 = require("../truthy.js");
|
|
15
|
+
const use_current_frame_js_1 = require("../use-current-frame.js");
|
|
16
|
+
const use_unsafe_video_config_js_1 = require("../use-unsafe-video-config.js");
|
|
17
|
+
const volume_prop_js_1 = require("../volume-prop.js");
|
|
18
|
+
const get_current_time_js_1 = require("./get-current-time.js");
|
|
19
|
+
const OffthreadVideoForRendering = ({ onError, volume: volumeProp, playbackRate, src, muted, allowAmplificationDuringRender, transparent = false, ...props }) => {
|
|
20
|
+
const absoluteFrame = (0, timeline_position_state_js_1.useTimelinePosition)();
|
|
21
|
+
const frame = (0, use_current_frame_js_1.useCurrentFrame)();
|
|
22
|
+
const volumePropsFrame = (0, use_audio_frame_js_1.useFrameForVolumeProp)();
|
|
23
|
+
const videoConfig = (0, use_unsafe_video_config_js_1.useUnsafeVideoConfig)();
|
|
24
|
+
const sequenceContext = (0, react_1.useContext)(SequenceContext_js_1.SequenceContext);
|
|
25
|
+
const mediaStartsAt = (0, use_audio_frame_js_1.useMediaStartsAt)();
|
|
26
|
+
const { registerAsset, unregisterAsset } = (0, react_1.useContext)(AssetManager_js_1.AssetManager);
|
|
27
|
+
if (!src) {
|
|
28
|
+
throw new TypeError('No `src` was passed to <OffthreadVideo>.');
|
|
29
|
+
}
|
|
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)(() => `offthreadvideo-${(0, random_js_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}`, [
|
|
33
|
+
src,
|
|
34
|
+
sequenceContext === null || sequenceContext === void 0 ? void 0 : sequenceContext.cumulatedFrom,
|
|
35
|
+
sequenceContext === null || sequenceContext === void 0 ? void 0 : sequenceContext.relativeFrom,
|
|
36
|
+
sequenceContext === null || sequenceContext === void 0 ? void 0 : sequenceContext.durationInFrames,
|
|
37
|
+
]);
|
|
38
|
+
if (!videoConfig) {
|
|
39
|
+
throw new Error('No video config found');
|
|
40
|
+
}
|
|
41
|
+
const volume = (0, volume_prop_js_1.evaluateVolume)({
|
|
42
|
+
volume: volumeProp,
|
|
43
|
+
frame: volumePropsFrame,
|
|
44
|
+
mediaVolume: 1,
|
|
45
|
+
allowAmplificationDuringRender: allowAmplificationDuringRender !== null && allowAmplificationDuringRender !== void 0 ? allowAmplificationDuringRender : false,
|
|
46
|
+
});
|
|
47
|
+
(0, react_1.useEffect)(() => {
|
|
48
|
+
if (!src) {
|
|
49
|
+
throw new Error('No src passed');
|
|
50
|
+
}
|
|
51
|
+
if (!window.remotion_audioEnabled) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
if (muted) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
if (volume <= 0) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
registerAsset({
|
|
61
|
+
type: 'video',
|
|
62
|
+
src: (0, absolute_src_js_1.getAbsoluteSrc)(src),
|
|
63
|
+
id,
|
|
64
|
+
frame: absoluteFrame,
|
|
65
|
+
volume,
|
|
66
|
+
mediaFrame: frame,
|
|
67
|
+
playbackRate: playbackRate !== null && playbackRate !== void 0 ? playbackRate : 1,
|
|
68
|
+
allowAmplificationDuringRender: allowAmplificationDuringRender !== null && allowAmplificationDuringRender !== void 0 ? allowAmplificationDuringRender : false,
|
|
69
|
+
});
|
|
70
|
+
return () => unregisterAsset(id);
|
|
71
|
+
}, [
|
|
72
|
+
muted,
|
|
73
|
+
src,
|
|
74
|
+
registerAsset,
|
|
75
|
+
id,
|
|
76
|
+
unregisterAsset,
|
|
77
|
+
volume,
|
|
78
|
+
frame,
|
|
79
|
+
absoluteFrame,
|
|
80
|
+
playbackRate,
|
|
81
|
+
allowAmplificationDuringRender,
|
|
82
|
+
]);
|
|
83
|
+
const currentTime = (0, react_1.useMemo)(() => {
|
|
84
|
+
return ((0, get_current_time_js_1.getExpectedMediaFrameUncorrected)({
|
|
85
|
+
frame,
|
|
86
|
+
playbackRate: playbackRate || 1,
|
|
87
|
+
startFrom: -mediaStartsAt,
|
|
88
|
+
}) / videoConfig.fps);
|
|
89
|
+
}, [frame, mediaStartsAt, playbackRate, videoConfig.fps]);
|
|
90
|
+
const actualSrc = (0, react_1.useMemo)(() => {
|
|
91
|
+
return `http://localhost:${window.remotion_proxyPort}/proxy?src=${encodeURIComponent((0, absolute_src_js_1.getAbsoluteSrc)(src))}&time=${encodeURIComponent(currentTime)}&transparent=${String(transparent)}`;
|
|
92
|
+
}, [currentTime, src, transparent]);
|
|
93
|
+
const onErr = (0, react_1.useCallback)((e) => {
|
|
94
|
+
onError === null || onError === void 0 ? void 0 : onError(e);
|
|
95
|
+
}, [onError]);
|
|
96
|
+
const className = (0, react_1.useMemo)(() => {
|
|
97
|
+
return [default_css_js_1.OFFTHREAD_VIDEO_CLASS_NAME, props.className]
|
|
98
|
+
.filter(truthy_js_1.truthy)
|
|
99
|
+
.join(' ');
|
|
100
|
+
}, [props.className]);
|
|
101
|
+
return ((0, jsx_runtime_1.jsx)(Img_js_1.Img, { src: actualSrc, className: className, ...props, onError: onErr }));
|
|
102
|
+
};
|
|
103
|
+
exports.OffthreadVideoForRendering = OffthreadVideoForRendering;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { RemotionMainVideoProps } from './props.js';
|
|
3
|
+
/**
|
|
4
|
+
* @description allows you to include a video file in your Remotion project. It wraps the native HTMLVideoElement.
|
|
5
|
+
* @see [Documentation](https://www.remotion.dev/docs/video)
|
|
6
|
+
*/
|
|
7
|
+
export declare const Video: (props: Omit<React.DetailedHTMLProps<React.VideoHTMLAttributes<HTMLVideoElement>, HTMLVideoElement>, "nonce" | "onEnded" | "autoPlay" | "controls"> & {
|
|
8
|
+
volume?: import("../volume-prop.js").VolumeProp | undefined;
|
|
9
|
+
playbackRate?: number | undefined;
|
|
10
|
+
acceptableTimeShiftInSeconds?: number | undefined;
|
|
11
|
+
allowAmplificationDuringRender?: boolean | undefined;
|
|
12
|
+
} & RemotionMainVideoProps & React.RefAttributes<HTMLVideoElement | null>) => React.ReactElement | null;
|
|
@@ -0,0 +1,55 @@
|
|
|
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 absolute_src_js_1 = require("../absolute-src.js");
|
|
7
|
+
const get_environment_js_1 = require("../get-environment.js");
|
|
8
|
+
const index_js_1 = require("../loop/index.js");
|
|
9
|
+
const Sequence_js_1 = require("../Sequence.js");
|
|
10
|
+
const use_video_config_js_1 = require("../use-video-config.js");
|
|
11
|
+
const validate_media_props_js_1 = require("../validate-media-props.js");
|
|
12
|
+
const validate_start_from_props_js_1 = require("../validate-start-from-props.js");
|
|
13
|
+
const duration_state_js_1 = require("./duration-state.js");
|
|
14
|
+
const VideoForDevelopment_js_1 = require("./VideoForDevelopment.js");
|
|
15
|
+
const VideoForRendering_js_1 = require("./VideoForRendering.js");
|
|
16
|
+
const VideoForwardingFunction = (props, ref) => {
|
|
17
|
+
var _a;
|
|
18
|
+
const { startFrom, endAt, ...otherProps } = props;
|
|
19
|
+
const { loop, ...propsOtherThanLoop } = props;
|
|
20
|
+
const { fps } = (0, use_video_config_js_1.useVideoConfig)();
|
|
21
|
+
const environment = (0, get_environment_js_1.useRemotionEnvironment)();
|
|
22
|
+
const { durations, setDurations } = (0, react_1.useContext)(duration_state_js_1.DurationsContext);
|
|
23
|
+
if (typeof ref === 'string') {
|
|
24
|
+
throw new Error('string refs are not supported');
|
|
25
|
+
}
|
|
26
|
+
if (typeof props.src !== 'string') {
|
|
27
|
+
throw new TypeError(`The \`<Video>\` tag requires a string for \`src\`, but got ${JSON.stringify(props.src)} instead.`);
|
|
28
|
+
}
|
|
29
|
+
const onDuration = (0, react_1.useCallback)((src, durationInSeconds) => {
|
|
30
|
+
setDurations({ type: 'got-duration', durationInSeconds, src });
|
|
31
|
+
}, [setDurations]);
|
|
32
|
+
if (loop && props.src && durations[(0, absolute_src_js_1.getAbsoluteSrc)(props.src)] !== undefined) {
|
|
33
|
+
const naturalDuration = durations[(0, absolute_src_js_1.getAbsoluteSrc)(props.src)] * fps;
|
|
34
|
+
const playbackRate = (_a = props.playbackRate) !== null && _a !== void 0 ? _a : 1;
|
|
35
|
+
const durationInFrames = Math.floor(naturalDuration / playbackRate);
|
|
36
|
+
return ((0, jsx_runtime_1.jsx)(index_js_1.Loop, { durationInFrames: durationInFrames, children: (0, jsx_runtime_1.jsx)(exports.Video, { ...propsOtherThanLoop, ref: ref }) }));
|
|
37
|
+
}
|
|
38
|
+
if (typeof startFrom !== 'undefined' || typeof endAt !== 'undefined') {
|
|
39
|
+
(0, validate_start_from_props_js_1.validateStartFromProps)(startFrom, endAt);
|
|
40
|
+
const startFromFrameNo = startFrom !== null && startFrom !== void 0 ? startFrom : 0;
|
|
41
|
+
const endAtFrameNo = endAt !== null && endAt !== void 0 ? endAt : Infinity;
|
|
42
|
+
return ((0, jsx_runtime_1.jsx)(Sequence_js_1.Sequence, { layout: "none", from: 0 - startFromFrameNo, showInTimeline: false, durationInFrames: endAtFrameNo, children: (0, jsx_runtime_1.jsx)(exports.Video, { ...otherProps, ref: ref }) }));
|
|
43
|
+
}
|
|
44
|
+
(0, validate_media_props_js_1.validateMediaProps)(props, 'Video');
|
|
45
|
+
if (environment === 'rendering') {
|
|
46
|
+
return ((0, jsx_runtime_1.jsx)(VideoForRendering_js_1.VideoForRendering, { onDuration: onDuration, ...otherProps, ref: ref }));
|
|
47
|
+
}
|
|
48
|
+
return ((0, jsx_runtime_1.jsx)(VideoForDevelopment_js_1.VideoForDevelopment, { onlyWarnForMediaSeekingError: false, ...otherProps, ref: ref, onDuration: onDuration }));
|
|
49
|
+
};
|
|
50
|
+
const forward = react_1.forwardRef;
|
|
51
|
+
/**
|
|
52
|
+
* @description allows you to include a video file in your Remotion project. It wraps the native HTMLVideoElement.
|
|
53
|
+
* @see [Documentation](https://www.remotion.dev/docs/video)
|
|
54
|
+
*/
|
|
55
|
+
exports.Video = forward(VideoForwardingFunction);
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import type { ForwardRefExoticComponent, RefAttributes } from 'react';
|
|
2
2
|
import React from 'react';
|
|
3
|
-
export declare const VideoForDevelopment: ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.VideoHTMLAttributes<HTMLVideoElement>, HTMLVideoElement>, "
|
|
4
|
-
volume?: import("../volume-prop").VolumeProp | undefined;
|
|
3
|
+
export declare const VideoForDevelopment: ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.VideoHTMLAttributes<HTMLVideoElement>, HTMLVideoElement>, "nonce" | "onEnded" | "autoPlay" | "controls"> & {
|
|
4
|
+
volume?: import("../volume-prop.js").VolumeProp | undefined;
|
|
5
5
|
playbackRate?: number | undefined;
|
|
6
|
+
acceptableTimeShiftInSeconds?: number | undefined;
|
|
7
|
+
allowAmplificationDuringRender?: boolean | undefined;
|
|
6
8
|
} & {
|
|
7
9
|
onlyWarnForMediaSeekingError: boolean;
|
|
10
|
+
onDuration: (src: string, durationInSeconds: number) => void;
|
|
8
11
|
} & RefAttributes<HTMLVideoElement>>;
|
|
@@ -0,0 +1,117 @@
|
|
|
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_js_1 = require("../audio/use-audio-frame.js");
|
|
7
|
+
const prefetch_js_1 = require("../prefetch.js");
|
|
8
|
+
const SequenceContext_js_1 = require("../SequenceContext.js");
|
|
9
|
+
const use_media_in_timeline_js_1 = require("../use-media-in-timeline.js");
|
|
10
|
+
const use_media_playback_js_1 = require("../use-media-playback.js");
|
|
11
|
+
const use_media_tag_volume_js_1 = require("../use-media-tag-volume.js");
|
|
12
|
+
const use_sync_volume_with_media_tag_js_1 = require("../use-sync-volume-with-media-tag.js");
|
|
13
|
+
const use_video_config_js_1 = require("../use-video-config.js");
|
|
14
|
+
const volume_position_state_js_1 = require("../volume-position-state.js");
|
|
15
|
+
const video_fragment_js_1 = require("./video-fragment.js");
|
|
16
|
+
const VideoForDevelopmentRefForwardingFunction = (props, ref) => {
|
|
17
|
+
var _a, _b;
|
|
18
|
+
const videoRef = (0, react_1.useRef)(null);
|
|
19
|
+
const volumePropFrame = (0, use_audio_frame_js_1.useFrameForVolumeProp)();
|
|
20
|
+
const { fps, durationInFrames } = (0, use_video_config_js_1.useVideoConfig)();
|
|
21
|
+
const parentSequence = (0, react_1.useContext)(SequenceContext_js_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_js_1.useMediaTagVolume)(videoRef);
|
|
29
|
+
const [mediaVolume] = (0, volume_position_state_js_1.useMediaVolumeState)();
|
|
30
|
+
const [mediaMuted] = (0, volume_position_state_js_1.useMediaMutedState)();
|
|
31
|
+
(0, use_media_in_timeline_js_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_js_1.useSyncVolumeWithMediaTag)({
|
|
40
|
+
volumePropFrame,
|
|
41
|
+
actualVolume,
|
|
42
|
+
volume,
|
|
43
|
+
mediaVolume,
|
|
44
|
+
mediaRef: videoRef,
|
|
45
|
+
});
|
|
46
|
+
(0, use_media_playback_js_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_js_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_js_1.useAppendVideoFragment)({
|
|
61
|
+
actualSrc: (0, prefetch_js_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
|
+
// If user is handling the error, we don't cause an unhandled exception
|
|
79
|
+
if (props.onError) {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
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. Pass an onError() prop to handle the error.`);
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
throw new Error('The browser threw an error');
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
current.addEventListener('error', errorHandler, { once: true });
|
|
89
|
+
return () => {
|
|
90
|
+
current.removeEventListener('error', errorHandler);
|
|
91
|
+
};
|
|
92
|
+
}, [props.onError, src]);
|
|
93
|
+
const currentOnDurationCallback = (0, react_1.useRef)();
|
|
94
|
+
currentOnDurationCallback.current = onDuration;
|
|
95
|
+
(0, react_1.useEffect)(() => {
|
|
96
|
+
var _a;
|
|
97
|
+
const { current } = videoRef;
|
|
98
|
+
if (!current) {
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
if (current.duration) {
|
|
102
|
+
(_a = currentOnDurationCallback.current) === null || _a === void 0 ? void 0 : _a.call(currentOnDurationCallback, src, current.duration);
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
const onLoadedMetadata = () => {
|
|
106
|
+
var _a;
|
|
107
|
+
(_a = currentOnDurationCallback.current) === null || _a === void 0 ? void 0 : _a.call(currentOnDurationCallback, src, current.duration);
|
|
108
|
+
};
|
|
109
|
+
current.addEventListener('loadedmetadata', onLoadedMetadata);
|
|
110
|
+
return () => {
|
|
111
|
+
current.removeEventListener('loadedmetadata', onLoadedMetadata);
|
|
112
|
+
};
|
|
113
|
+
}, [src]);
|
|
114
|
+
return ((0, jsx_runtime_1.jsx)("video", { ref: videoRef, muted: muted || mediaMuted, playsInline: true, src: actualSrc, ...nativeProps }));
|
|
115
|
+
};
|
|
116
|
+
// Copy types from forwardRef but not necessary to remove ref
|
|
117
|
+
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" | "onEnded" | "autoPlay" | "controls"> & {
|
|
4
|
+
volume?: import("../volume-prop.js").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,208 @@
|
|
|
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_js_1 = require("../absolute-src.js");
|
|
7
|
+
const AssetManager_js_1 = require("../AssetManager.js");
|
|
8
|
+
const use_audio_frame_js_1 = require("../audio/use-audio-frame.js");
|
|
9
|
+
const delay_render_js_1 = require("../delay-render.js");
|
|
10
|
+
const get_environment_js_1 = require("../get-environment.js");
|
|
11
|
+
const is_approximately_the_same_js_1 = require("../is-approximately-the-same.js");
|
|
12
|
+
const random_js_1 = require("../random.js");
|
|
13
|
+
const SequenceContext_js_1 = require("../SequenceContext.js");
|
|
14
|
+
const timeline_position_state_js_1 = require("../timeline-position-state.js");
|
|
15
|
+
const use_current_frame_js_1 = require("../use-current-frame.js");
|
|
16
|
+
const use_unsafe_video_config_js_1 = require("../use-unsafe-video-config.js");
|
|
17
|
+
const volume_prop_js_1 = require("../volume-prop.js");
|
|
18
|
+
const warn_about_non_seekable_media_js_1 = require("../warn-about-non-seekable-media.js");
|
|
19
|
+
const get_current_time_js_1 = require("./get-current-time.js");
|
|
20
|
+
const VideoForRenderingForwardFunction = ({ onError, volume: volumeProp, allowAmplificationDuringRender, playbackRate, onDuration, ...props }, ref) => {
|
|
21
|
+
const absoluteFrame = (0, timeline_position_state_js_1.useTimelinePosition)();
|
|
22
|
+
const frame = (0, use_current_frame_js_1.useCurrentFrame)();
|
|
23
|
+
const volumePropsFrame = (0, use_audio_frame_js_1.useFrameForVolumeProp)();
|
|
24
|
+
const videoConfig = (0, use_unsafe_video_config_js_1.useUnsafeVideoConfig)();
|
|
25
|
+
const videoRef = (0, react_1.useRef)(null);
|
|
26
|
+
const sequenceContext = (0, react_1.useContext)(SequenceContext_js_1.SequenceContext);
|
|
27
|
+
const mediaStartsAt = (0, use_audio_frame_js_1.useMediaStartsAt)();
|
|
28
|
+
const environment = (0, get_environment_js_1.useRemotionEnvironment)();
|
|
29
|
+
const { registerAsset, unregisterAsset } = (0, react_1.useContext)(AssetManager_js_1.AssetManager);
|
|
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_js_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_js_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_js_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_js_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_js_1.delayRender)(`Rendering <Video /> with src="${props.src}"`);
|
|
108
|
+
if (process.env.NODE_ENV === 'test') {
|
|
109
|
+
(0, delay_render_js_1.continueRender)(handle);
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
if ((0, is_approximately_the_same_js_1.isApproximatelyTheSame)(current.currentTime, currentTime)) {
|
|
113
|
+
if (current.readyState >= 2) {
|
|
114
|
+
(0, delay_render_js_1.continueRender)(handle);
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
const loadedDataHandler = () => {
|
|
118
|
+
(0, delay_render_js_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_js_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_js_1.continueRender)(handle);
|
|
134
|
+
}, 100);
|
|
135
|
+
}
|
|
136
|
+
else {
|
|
137
|
+
(0, delay_render_js_1.continueRender)(handle);
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
current.addEventListener('seeked', seekedHandler, { once: true });
|
|
141
|
+
const endedHandler = () => {
|
|
142
|
+
(0, delay_render_js_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
|
+
// If user is handling the error, we don't cause an unhandled exception
|
|
150
|
+
if (onError) {
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
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. Pass an onError() prop to handle the error.`);
|
|
154
|
+
}
|
|
155
|
+
else {
|
|
156
|
+
throw new Error('The browser threw an error');
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
current.addEventListener('error', errorHandler, { once: true });
|
|
160
|
+
// If video skips to another frame or unmounts, we clear the created handle
|
|
161
|
+
return () => {
|
|
162
|
+
current.removeEventListener('ended', endedHandler);
|
|
163
|
+
current.removeEventListener('error', errorHandler);
|
|
164
|
+
current.removeEventListener('seeked', seekedHandler);
|
|
165
|
+
(0, delay_render_js_1.continueRender)(handle);
|
|
166
|
+
};
|
|
167
|
+
}, [
|
|
168
|
+
volumePropsFrame,
|
|
169
|
+
props.src,
|
|
170
|
+
playbackRate,
|
|
171
|
+
videoConfig.fps,
|
|
172
|
+
frame,
|
|
173
|
+
mediaStartsAt,
|
|
174
|
+
onError,
|
|
175
|
+
]);
|
|
176
|
+
const { src } = props;
|
|
177
|
+
// If video source switches, make new handle
|
|
178
|
+
if (environment === 'rendering') {
|
|
179
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
180
|
+
(0, react_1.useLayoutEffect)(() => {
|
|
181
|
+
if (process.env.NODE_ENV === 'test') {
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
const newHandle = (0, delay_render_js_1.delayRender)('Loading <Video> duration with src=' + src);
|
|
185
|
+
const { current } = videoRef;
|
|
186
|
+
const didLoad = () => {
|
|
187
|
+
if (current === null || current === void 0 ? void 0 : current.duration) {
|
|
188
|
+
onDuration(src, current.duration);
|
|
189
|
+
}
|
|
190
|
+
(0, delay_render_js_1.continueRender)(newHandle);
|
|
191
|
+
};
|
|
192
|
+
if (current === null || current === void 0 ? void 0 : current.duration) {
|
|
193
|
+
onDuration(src, current.duration);
|
|
194
|
+
(0, delay_render_js_1.continueRender)(newHandle);
|
|
195
|
+
}
|
|
196
|
+
else {
|
|
197
|
+
current === null || current === void 0 ? void 0 : current.addEventListener('loadedmetadata', didLoad, { once: true });
|
|
198
|
+
}
|
|
199
|
+
// If tag gets unmounted, clear pending handles because video metadata is not going to load
|
|
200
|
+
return () => {
|
|
201
|
+
current === null || current === void 0 ? void 0 : current.removeEventListener('loadedmetadata', didLoad);
|
|
202
|
+
(0, delay_render_js_1.continueRender)(newHandle);
|
|
203
|
+
};
|
|
204
|
+
}, [src, onDuration]);
|
|
205
|
+
}
|
|
206
|
+
return (0, jsx_runtime_1.jsx)("video", { ref: videoRef, ...props, onError: onError });
|
|
207
|
+
};
|
|
208
|
+
exports.VideoForRendering = (0, react_1.forwardRef)(VideoForRenderingForwardFunction);
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
type DurationState = Record<string, number>;
|
|
3
|
+
type DurationAction = {
|
|
4
|
+
type: 'got-duration';
|
|
5
|
+
src: string;
|
|
6
|
+
durationInSeconds: number;
|
|
7
|
+
};
|
|
8
|
+
export declare const durationReducer: (state: DurationState, action: DurationAction) => DurationState;
|
|
9
|
+
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,35 @@
|
|
|
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 absolute_src_js_1 = require("../absolute-src.js");
|
|
7
|
+
const durationReducer = (state, action) => {
|
|
8
|
+
switch (action.type) {
|
|
9
|
+
case 'got-duration':
|
|
10
|
+
return {
|
|
11
|
+
...state,
|
|
12
|
+
[(0, absolute_src_js_1.getAbsoluteSrc)(action.src)]: action.durationInSeconds,
|
|
13
|
+
};
|
|
14
|
+
default:
|
|
15
|
+
return state;
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
exports.durationReducer = durationReducer;
|
|
19
|
+
exports.DurationsContext = (0, react_1.createContext)({
|
|
20
|
+
durations: {},
|
|
21
|
+
setDurations: () => {
|
|
22
|
+
throw new Error('context missing');
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
const DurationsContextProvider = ({ children }) => {
|
|
26
|
+
const [durations, setDurations] = (0, react_1.useReducer)(exports.durationReducer, {});
|
|
27
|
+
const value = (0, react_1.useMemo)(() => {
|
|
28
|
+
return {
|
|
29
|
+
durations,
|
|
30
|
+
setDurations,
|
|
31
|
+
};
|
|
32
|
+
}, [durations]);
|
|
33
|
+
return ((0, jsx_runtime_1.jsx)(exports.DurationsContext.Provider, { value: value, children: children }));
|
|
34
|
+
};
|
|
35
|
+
exports.DurationsContextProvider = DurationsContextProvider;
|
|
File without changes
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
// Calculate the `.currentTime` of a video or audio element
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.getMediaTime = exports.getExpectedMediaFrameUncorrected = void 0;
|
|
5
|
-
const
|
|
5
|
+
const interpolate_js_1 = require("../interpolate.js");
|
|
6
6
|
const getExpectedMediaFrameUncorrected = ({ frame, playbackRate, startFrom, }) => {
|
|
7
|
-
return (0,
|
|
7
|
+
return (0, interpolate_js_1.interpolate)(frame, [-1, startFrom, startFrom + 1], [-1, startFrom, startFrom + playbackRate]);
|
|
8
8
|
};
|
|
9
9
|
exports.getExpectedMediaFrameUncorrected = getExpectedMediaFrameUncorrected;
|
|
10
10
|
const getMediaTime = ({ fps, frame, src, playbackRate, startFrom, mediaType, }) => {
|
|
@@ -13,19 +13,20 @@ const getMediaTime = ({ fps, frame, src, playbackRate, startFrom, mediaType, })
|
|
|
13
13
|
playbackRate,
|
|
14
14
|
startFrom,
|
|
15
15
|
});
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
if (mediaType === 'video') {
|
|
16
|
+
const isChrome = typeof window !== 'undefined' &&
|
|
17
|
+
window.navigator.userAgent.match(/Chrome\/([0-9]+)/);
|
|
18
|
+
if (isChrome &&
|
|
19
|
+
Number(isChrome[1]) < 112 &&
|
|
20
|
+
mediaType === 'video' &&
|
|
21
|
+
src.endsWith('.mp4')) {
|
|
23
22
|
// In Chrome, for MP4s, if 30fps, the first frame is still displayed at 0.033333
|
|
24
23
|
// even though after that it increases by 0.033333333 each.
|
|
25
24
|
// So frame = 0 in Remotion is like frame = 1 for the browser
|
|
26
25
|
return (expectedFrame + 1) / fps;
|
|
27
26
|
}
|
|
28
|
-
// For
|
|
29
|
-
|
|
27
|
+
// For WebM videos, we need to add a little bit of shift to get the right frame.
|
|
28
|
+
const msPerFrame = 1000 / fps;
|
|
29
|
+
const msShift = msPerFrame / 2;
|
|
30
|
+
return (expectedFrame * msPerFrame + msShift) / 1000;
|
|
30
31
|
};
|
|
31
32
|
exports.getMediaTime = getMediaTime;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Video = exports.OffthreadVideo = void 0;
|
|
4
|
-
var
|
|
5
|
-
Object.defineProperty(exports, "OffthreadVideo", { enumerable: true, get: function () { return
|
|
6
|
-
var
|
|
7
|
-
Object.defineProperty(exports, "Video", { enumerable: true, get: function () { return
|
|
4
|
+
var OffthreadVideo_js_1 = require("./OffthreadVideo.js");
|
|
5
|
+
Object.defineProperty(exports, "OffthreadVideo", { enumerable: true, get: function () { return OffthreadVideo_js_1.OffthreadVideo; } });
|
|
6
|
+
var Video_js_1 = require("./Video.js");
|
|
7
|
+
Object.defineProperty(exports, "Video", { enumerable: true, get: function () { return Video_js_1.Video; } });
|