@zync/zync-screnplay-player 0.1.221 → 0.1.223
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/dist/bundle.js +1 -1
- package/dist/screenplay/RemotionRenderer/components/LottieAnimationGlobal.js +21 -21
- package/dist/screenplay/RemotionRenderer/components/layouts/Keyword.js +3 -3
- package/dist/screenplay/RemotionRenderer/components/layouts/MotionStill.js +3 -3
- package/dist/screenplay/RemotionRenderer/components/layouts/MultiHandoff.js +264 -0
- package/dist/screenplay/RemotionRenderer/components/utils/FaceCenteredVideo.js +50 -50
- package/dist/screenplay/RemotionRenderer/components/utils/PausableImg.js +4 -4
- package/dist/screenplay/RemotionRenderer/components/utils/README.md +80 -80
- package/dist/screenplay/RemotionRenderer/components/utils/StretchTextDemo.js +3 -3
- package/dist/screenplay/RemotionRenderer/development.js +1165 -3064
- package/dist/screenplay/RemotionRenderer/helpers/convertToSeconds.js +8 -8
- package/dist/screenplay/RemotionRenderer/helpers/faceBasedVideoStyles.js +4 -4
- package/dist/screenplay/RemotionRenderer/helpers/faceCenteredVideoTransforms.js +46 -46
- package/dist/screenplay/RemotionRenderer/main/lib/layouts/LayoutFactory.js +5 -0
- package/dist/screenplay/RemotionRenderer/main/lib/layouts/MultiHandoffLayout.js +53 -0
- package/dist/screenplay/RemotionRenderer/main/screenplaySchema.js +51 -51
- package/dist/screenplay/RemotionRenderer/registeredComponents.js +4 -2
- package/dist/screenplay/RemotionRenderer/tracks/LayoutVideoTrack.js +20 -20
- package/package.json +47 -47
|
@@ -8,9 +8,9 @@ import React, { useEffect, useState } from 'react';
|
|
|
8
8
|
import { delayRender, continueRender, cancelRender } from 'remotion';
|
|
9
9
|
import { Lottie } from '@remotion/lottie';
|
|
10
10
|
|
|
11
|
-
/**
|
|
12
|
-
* Convert a HEX color string (e.g. "#ff8800") to the RGBA float array that
|
|
13
|
-
* Lottie expects: [r, g, b, a] where each component is 0‑1.
|
|
11
|
+
/**
|
|
12
|
+
* Convert a HEX color string (e.g. "#ff8800") to the RGBA float array that
|
|
13
|
+
* Lottie expects: [r, g, b, a] where each component is 0‑1.
|
|
14
14
|
*/
|
|
15
15
|
var hexToRGBA = function hexToRGBA(hex) {
|
|
16
16
|
var clean = hex.replace('#', '');
|
|
@@ -25,9 +25,9 @@ var hexToRGBA = function hexToRGBA(hex) {
|
|
|
25
25
|
];
|
|
26
26
|
};
|
|
27
27
|
|
|
28
|
-
/**
|
|
29
|
-
* Recursively walks through shape objects and overrides any fill (fl) or
|
|
30
|
-
* stroke (st) color with the provided RGBA array.
|
|
28
|
+
/**
|
|
29
|
+
* Recursively walks through shape objects and overrides any fill (fl) or
|
|
30
|
+
* stroke (st) color with the provided RGBA array.
|
|
31
31
|
*/
|
|
32
32
|
var _applyColor = function applyColor(shapes, rgba) {
|
|
33
33
|
shapes === null || shapes === void 0 ? void 0 : shapes.forEach(function (shape) {
|
|
@@ -40,11 +40,11 @@ var _applyColor = function applyColor(shapes, rgba) {
|
|
|
40
40
|
});
|
|
41
41
|
};
|
|
42
42
|
|
|
43
|
-
/**
|
|
44
|
-
* Traverses all layers (top‑level + asset layers) and applies the primary
|
|
45
|
-
* color to every fill / stroke it encounters. This is useful for Lottie files
|
|
46
|
-
* that were exported with a single static color (e.g. white) and do not use
|
|
47
|
-
* layer naming conventions like "PrimaryColor".
|
|
43
|
+
/**
|
|
44
|
+
* Traverses all layers (top‑level + asset layers) and applies the primary
|
|
45
|
+
* color to every fill / stroke it encounters. This is useful for Lottie files
|
|
46
|
+
* that were exported with a single static color (e.g. white) and do not use
|
|
47
|
+
* layer naming conventions like "PrimaryColor".
|
|
48
48
|
*/
|
|
49
49
|
var replaceGlobalColor = function replaceGlobalColor(data, hex) {
|
|
50
50
|
var _data$assets;
|
|
@@ -60,16 +60,16 @@ var replaceGlobalColor = function replaceGlobalColor(data, hex) {
|
|
|
60
60
|
});
|
|
61
61
|
};
|
|
62
62
|
|
|
63
|
-
/**
|
|
64
|
-
* LottieAnimationGlobal – specialised wrapper to render the provided Lottie
|
|
65
|
-
* (e.g. text‑bubble‑animation.json) while dynamically replacing **all** stroke
|
|
66
|
-
* and fill colors with the supplied `primaryColor`.
|
|
67
|
-
*
|
|
68
|
-
* Props:
|
|
69
|
-
* • animationPath – URL or local path to the json file.
|
|
70
|
-
* • primaryColor – HEX string, defaults to "#ffffff".
|
|
71
|
-
* • autoplay – boolean, whether to start playing immediately.
|
|
72
|
-
* • loop – boolean, whether to loop the animation.
|
|
63
|
+
/**
|
|
64
|
+
* LottieAnimationGlobal – specialised wrapper to render the provided Lottie
|
|
65
|
+
* (e.g. text‑bubble‑animation.json) while dynamically replacing **all** stroke
|
|
66
|
+
* and fill colors with the supplied `primaryColor`.
|
|
67
|
+
*
|
|
68
|
+
* Props:
|
|
69
|
+
* • animationPath – URL or local path to the json file.
|
|
70
|
+
* • primaryColor – HEX string, defaults to "#ffffff".
|
|
71
|
+
* • autoplay – boolean, whether to start playing immediately.
|
|
72
|
+
* • loop – boolean, whether to loop the animation.
|
|
73
73
|
*/
|
|
74
74
|
export var LottieAnimationGlobal = function LottieAnimationGlobal(_ref) {
|
|
75
75
|
var animationPath = _ref.animationPath,
|
|
@@ -295,7 +295,7 @@ var KeywordComponent = function KeywordComponent(_ref4) {
|
|
|
295
295
|
}
|
|
296
296
|
}, /*#__PURE__*/React.createElement("div", {
|
|
297
297
|
style: {
|
|
298
|
-
position: "fixed",
|
|
298
|
+
position: shouldUseSquareInLandscape ? "absolute" : "fixed",
|
|
299
299
|
zIndex: 999,
|
|
300
300
|
height: CHROME_PADDING,
|
|
301
301
|
width: width,
|
|
@@ -304,7 +304,7 @@ var KeywordComponent = function KeywordComponent(_ref4) {
|
|
|
304
304
|
}
|
|
305
305
|
}), /*#__PURE__*/React.createElement("div", {
|
|
306
306
|
style: {
|
|
307
|
-
position: "fixed",
|
|
307
|
+
position: shouldUseSquareInLandscape ? "absolute" : "fixed",
|
|
308
308
|
zIndex: 999,
|
|
309
309
|
width: CHROME_PADDING,
|
|
310
310
|
height: height,
|
|
@@ -313,7 +313,7 @@ var KeywordComponent = function KeywordComponent(_ref4) {
|
|
|
313
313
|
}
|
|
314
314
|
}), /*#__PURE__*/React.createElement("div", {
|
|
315
315
|
style: {
|
|
316
|
-
position: "fixed",
|
|
316
|
+
position: shouldUseSquareInLandscape ? "absolute" : "fixed",
|
|
317
317
|
zIndex: 999,
|
|
318
318
|
width: CHROME_PADDING,
|
|
319
319
|
height: height,
|
|
@@ -205,7 +205,7 @@ var MotionStillComponent = function MotionStillComponent(_ref3) {
|
|
|
205
205
|
}
|
|
206
206
|
}, /*#__PURE__*/React.createElement("div", {
|
|
207
207
|
style: {
|
|
208
|
-
position: "fixed",
|
|
208
|
+
position: shouldUseSquareInLandscape ? "absolute" : "fixed",
|
|
209
209
|
zIndex: 999,
|
|
210
210
|
height: CHROME_PADDING,
|
|
211
211
|
width: width,
|
|
@@ -214,7 +214,7 @@ var MotionStillComponent = function MotionStillComponent(_ref3) {
|
|
|
214
214
|
}
|
|
215
215
|
}), /*#__PURE__*/React.createElement("div", {
|
|
216
216
|
style: {
|
|
217
|
-
position: "fixed",
|
|
217
|
+
position: shouldUseSquareInLandscape ? "absolute" : "fixed",
|
|
218
218
|
zIndex: 999,
|
|
219
219
|
width: CHROME_PADDING,
|
|
220
220
|
height: height,
|
|
@@ -223,7 +223,7 @@ var MotionStillComponent = function MotionStillComponent(_ref3) {
|
|
|
223
223
|
}
|
|
224
224
|
}), /*#__PURE__*/React.createElement("div", {
|
|
225
225
|
style: {
|
|
226
|
-
position: "fixed",
|
|
226
|
+
position: shouldUseSquareInLandscape ? "absolute" : "fixed",
|
|
227
227
|
zIndex: 999,
|
|
228
228
|
width: CHROME_PADDING,
|
|
229
229
|
height: height,
|
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
import { AbsoluteFill, Freeze, OffthreadVideo, Sequence, useCurrentFrame, useVideoConfig } from 'remotion';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { useOrientationBased } from '../../hooks/useOrientationBased.js';
|
|
4
|
+
import { calculateInputRangeInPhases, DEFAULT_TIME_INTERPOLATE_OPTIONS, timeInterpolate } from '../../hooks/useTimeInterpolate.js';
|
|
5
|
+
import { useTheme } from '../../theme/hooks/useTheme.js';
|
|
6
|
+
import FaceCenteredVideo from '../utils/FaceCenteredVideo';
|
|
7
|
+
import { BlurOverlay } from '../utils/BlurOverlay';
|
|
8
|
+
var TOTAL_Y_PADDING = 20;
|
|
9
|
+
var TOTAL_X_PADDING = 20;
|
|
10
|
+
var GAP_BETWEEN_VIDEOS = 5;
|
|
11
|
+
var MIN_HANDOFF_OVERLAP = 0.5;
|
|
12
|
+
var getTransitionMetrics = function getTransitionMetrics(videos, handoffOverlapSeconds, fps) {
|
|
13
|
+
var startTimesInSeconds = [0];
|
|
14
|
+
for (var i = 1; i < videos.length; i += 1) {
|
|
15
|
+
var _videos;
|
|
16
|
+
var prevDuration = ((_videos = videos[i - 1]) === null || _videos === void 0 ? void 0 : _videos.videoDuration) || 0;
|
|
17
|
+
var overlap = handoffOverlapSeconds[i - 1] || 0;
|
|
18
|
+
var delay = Math.max(0, prevDuration - overlap);
|
|
19
|
+
startTimesInSeconds[i] = startTimesInSeconds[i - 1] + delay;
|
|
20
|
+
}
|
|
21
|
+
var transitions = [];
|
|
22
|
+
for (var _i = 0; _i < videos.length - 1; _i += 1) {
|
|
23
|
+
var _videos$_i, _videos2;
|
|
24
|
+
var _overlap = handoffOverlapSeconds[_i] || 0;
|
|
25
|
+
var phaseDurationsInSeconds = [0.5, Math.max(MIN_HANDOFF_OVERLAP, _overlap), 0.5];
|
|
26
|
+
var delayInSeconds = startTimesInSeconds[_i + 1] || 0;
|
|
27
|
+
var inputRangeInSeconds = calculateInputRangeInPhases(phaseDurationsInSeconds, delayInSeconds);
|
|
28
|
+
transitions.push({
|
|
29
|
+
index: _i,
|
|
30
|
+
from: _i,
|
|
31
|
+
to: _i + 1,
|
|
32
|
+
isResponderToSeeker: ((_videos$_i = videos[_i]) === null || _videos$_i === void 0 ? void 0 : _videos$_i.speakerRole) === 'responder' && ((_videos2 = videos[_i + 1]) === null || _videos2 === void 0 ? void 0 : _videos2.speakerRole) === 'seeker',
|
|
33
|
+
inputRangeInSeconds: inputRangeInSeconds,
|
|
34
|
+
startFrame: delayInSeconds * fps,
|
|
35
|
+
endFrame: inputRangeInSeconds[inputRangeInSeconds.length - 1] * fps
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
return {
|
|
39
|
+
transitions: transitions,
|
|
40
|
+
startFrames: startTimesInSeconds.map(function (time) {
|
|
41
|
+
return time * fps;
|
|
42
|
+
})
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
var renderClip = function renderClip(_ref) {
|
|
46
|
+
var clip = _ref.clip,
|
|
47
|
+
useSquareInLandscape = _ref.useSquareInLandscape,
|
|
48
|
+
orientation = _ref.orientation,
|
|
49
|
+
videoWidth = _ref.videoWidth,
|
|
50
|
+
videoHeight = _ref.videoHeight,
|
|
51
|
+
translateX = _ref.translateX;
|
|
52
|
+
if (!(clip !== null && clip !== void 0 && clip.videoFile)) {
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
var renderWidth = useSquareInLandscape ? Math.min(videoWidth, 1080) : videoWidth;
|
|
56
|
+
var renderHeight = useSquareInLandscape ? Math.min(videoHeight, 1080) : videoHeight;
|
|
57
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
58
|
+
style: {
|
|
59
|
+
transform: "translateX(".concat(translateX, "px)")
|
|
60
|
+
}
|
|
61
|
+
}, clip.noBackgroundFaceMetadata ? /*#__PURE__*/React.createElement(FaceCenteredVideo, {
|
|
62
|
+
startFrom: clip.startVideoFrom,
|
|
63
|
+
src: clip.videoFile,
|
|
64
|
+
faceMetadata: clip.noBackgroundFaceMetadata,
|
|
65
|
+
aspectRatio: orientation,
|
|
66
|
+
containerWidth: renderWidth,
|
|
67
|
+
containerHeight: renderHeight,
|
|
68
|
+
useAveragePosition: true
|
|
69
|
+
}) : /*#__PURE__*/React.createElement(OffthreadVideo, {
|
|
70
|
+
pauseWhenBuffering: true,
|
|
71
|
+
startFrom: clip.startVideoFrom,
|
|
72
|
+
src: clip.videoFile,
|
|
73
|
+
style: {
|
|
74
|
+
height: renderHeight,
|
|
75
|
+
objectFit: 'cover',
|
|
76
|
+
width: renderWidth,
|
|
77
|
+
borderRadius: '40px'
|
|
78
|
+
}
|
|
79
|
+
}));
|
|
80
|
+
};
|
|
81
|
+
export var MultiHandoff = function MultiHandoff(_ref2) {
|
|
82
|
+
var _compositionProps$out, _window, _window$screenplayPro, _window$screenplayPro2;
|
|
83
|
+
var _ref2$videos = _ref2.videos,
|
|
84
|
+
videos = _ref2$videos === void 0 ? [] : _ref2$videos,
|
|
85
|
+
_ref2$handoffOverlapS = _ref2.handoffOverlapSeconds,
|
|
86
|
+
handoffOverlapSeconds = _ref2$handoffOverlapS === void 0 ? [] : _ref2$handoffOverlapS,
|
|
87
|
+
noBackgroundVideoEffects = _ref2.noBackgroundVideoEffects,
|
|
88
|
+
children = _ref2.children;
|
|
89
|
+
var frame = useCurrentFrame();
|
|
90
|
+
var videoConfig = useVideoConfig();
|
|
91
|
+
var width = videoConfig.width,
|
|
92
|
+
height = videoConfig.height,
|
|
93
|
+
fps = videoConfig.fps,
|
|
94
|
+
_videoConfig$props = videoConfig.props,
|
|
95
|
+
compositionProps = _videoConfig$props === void 0 ? {} : _videoConfig$props;
|
|
96
|
+
var outputOrientation = (compositionProps === null || compositionProps === void 0 ? void 0 : (_compositionProps$out = compositionProps.output) === null || _compositionProps$out === void 0 ? void 0 : _compositionProps$out.orientation) || (typeof window !== 'undefined' ? (_window = window) === null || _window === void 0 ? void 0 : (_window$screenplayPro = _window.screenplayProps) === null || _window$screenplayPro === void 0 ? void 0 : (_window$screenplayPro2 = _window$screenplayPro.output) === null || _window$screenplayPro2 === void 0 ? void 0 : _window$screenplayPro2.orientation : undefined);
|
|
97
|
+
var _useTheme = useTheme(),
|
|
98
|
+
primaryColor = _useTheme.primaryColor;
|
|
99
|
+
var _useOrientationBased = useOrientationBased({
|
|
100
|
+
portrait: {
|
|
101
|
+
firstTargetVideoHeights: [height - TOTAL_Y_PADDING - GAP_BETWEEN_VIDEOS, height / 2 - TOTAL_Y_PADDING - GAP_BETWEEN_VIDEOS, height / 2 - TOTAL_Y_PADDING - GAP_BETWEEN_VIDEOS, 0],
|
|
102
|
+
secondTargetVideoHeights: [0, height / 2 - TOTAL_Y_PADDING - GAP_BETWEEN_VIDEOS, height / 2 - TOTAL_Y_PADDING - GAP_BETWEEN_VIDEOS, height - TOTAL_Y_PADDING - GAP_BETWEEN_VIDEOS],
|
|
103
|
+
firstTargetVideoWidths: [width - TOTAL_X_PADDING, width - TOTAL_X_PADDING, width - TOTAL_X_PADDING, width - TOTAL_X_PADDING],
|
|
104
|
+
secondTargetVideoWidths: [width - TOTAL_X_PADDING, width - TOTAL_X_PADDING, width - TOTAL_X_PADDING, width - TOTAL_X_PADDING]
|
|
105
|
+
},
|
|
106
|
+
landscape: {
|
|
107
|
+
firstTargetVideoHeights: [height - TOTAL_Y_PADDING, height - TOTAL_Y_PADDING, height - TOTAL_Y_PADDING, height - TOTAL_Y_PADDING],
|
|
108
|
+
secondTargetVideoHeights: [height - TOTAL_Y_PADDING, height - TOTAL_Y_PADDING, height - TOTAL_Y_PADDING, height - TOTAL_Y_PADDING],
|
|
109
|
+
firstTargetVideoWidths: [width - TOTAL_X_PADDING - GAP_BETWEEN_VIDEOS, width / 2 - TOTAL_X_PADDING - GAP_BETWEEN_VIDEOS, width / 2 - TOTAL_X_PADDING - GAP_BETWEEN_VIDEOS, 0],
|
|
110
|
+
secondTargetVideoWidths: [width / 2 - TOTAL_X_PADDING - GAP_BETWEEN_VIDEOS, width / 2 - TOTAL_X_PADDING - GAP_BETWEEN_VIDEOS, width / 2 - TOTAL_X_PADDING - GAP_BETWEEN_VIDEOS, width - TOTAL_X_PADDING - GAP_BETWEEN_VIDEOS]
|
|
111
|
+
},
|
|
112
|
+
square: {
|
|
113
|
+
firstTargetVideoHeights: [height - TOTAL_Y_PADDING, height - TOTAL_Y_PADDING, height - TOTAL_Y_PADDING, height - TOTAL_Y_PADDING],
|
|
114
|
+
secondTargetVideoHeights: [height - TOTAL_Y_PADDING, height - TOTAL_Y_PADDING, height - TOTAL_Y_PADDING, height - TOTAL_Y_PADDING],
|
|
115
|
+
firstTargetVideoWidths: [width - TOTAL_X_PADDING - GAP_BETWEEN_VIDEOS, width / 2 - TOTAL_X_PADDING - GAP_BETWEEN_VIDEOS, width / 2 - TOTAL_X_PADDING - GAP_BETWEEN_VIDEOS, 0],
|
|
116
|
+
secondTargetVideoWidths: [width / 2 - TOTAL_X_PADDING - GAP_BETWEEN_VIDEOS, width / 2 - TOTAL_X_PADDING - GAP_BETWEEN_VIDEOS, width / 2 - TOTAL_X_PADDING - GAP_BETWEEN_VIDEOS, width - TOTAL_X_PADDING - GAP_BETWEEN_VIDEOS]
|
|
117
|
+
}
|
|
118
|
+
}),
|
|
119
|
+
firstTargetVideoWidths = _useOrientationBased.firstTargetVideoWidths,
|
|
120
|
+
secondTargetVideoWidths = _useOrientationBased.secondTargetVideoWidths,
|
|
121
|
+
firstTargetVideoHeights = _useOrientationBased.firstTargetVideoHeights,
|
|
122
|
+
secondTargetVideoHeights = _useOrientationBased.secondTargetVideoHeights,
|
|
123
|
+
orientation = _useOrientationBased.orientation;
|
|
124
|
+
var _getTransitionMetrics = getTransitionMetrics(videos, handoffOverlapSeconds, fps),
|
|
125
|
+
transitions = _getTransitionMetrics.transitions,
|
|
126
|
+
startFrames = _getTransitionMetrics.startFrames;
|
|
127
|
+
var activeTransition = transitions.find(function (transition) {
|
|
128
|
+
return frame >= transition.startFrame && frame <= transition.endFrame;
|
|
129
|
+
}) || null;
|
|
130
|
+
var activeFullVideoIndex = startFrames.reduce(function (activeIndex, clipStartFrame, index) {
|
|
131
|
+
if (clipStartFrame <= frame) {
|
|
132
|
+
return index;
|
|
133
|
+
}
|
|
134
|
+
return activeIndex;
|
|
135
|
+
}, 0) || 0;
|
|
136
|
+
var getFullScreenDimensions = function getFullScreenDimensions() {
|
|
137
|
+
if (orientation === 'portrait') {
|
|
138
|
+
return {
|
|
139
|
+
width: width - TOTAL_X_PADDING,
|
|
140
|
+
height: height - TOTAL_Y_PADDING - GAP_BETWEEN_VIDEOS
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
return {
|
|
144
|
+
width: width - TOTAL_X_PADDING - GAP_BETWEEN_VIDEOS,
|
|
145
|
+
height: height - TOTAL_Y_PADDING
|
|
146
|
+
};
|
|
147
|
+
};
|
|
148
|
+
var getClipAnimationState = function getClipAnimationState(clipIndex) {
|
|
149
|
+
if (!activeTransition) {
|
|
150
|
+
if (clipIndex !== activeFullVideoIndex) {
|
|
151
|
+
return null;
|
|
152
|
+
}
|
|
153
|
+
var dimensions = getFullScreenDimensions();
|
|
154
|
+
var _clip = videos[clipIndex] || {};
|
|
155
|
+
var _useSquareInLandscape = Boolean(_clip.useSquareInLandscape) && outputOrientation === 'landscape';
|
|
156
|
+
var centeredOffsetX = _useSquareInLandscape ? Math.max(0, (width - TOTAL_X_PADDING - Math.min(dimensions.width, 1080)) / 2) : 0;
|
|
157
|
+
return {
|
|
158
|
+
videoWidth: dimensions.width,
|
|
159
|
+
videoHeight: dimensions.height,
|
|
160
|
+
translateX: centeredOffsetX,
|
|
161
|
+
useSquareInLandscape: _useSquareInLandscape
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
var clip = videos[clipIndex] || {};
|
|
165
|
+
var useSquareInLandscape = Boolean(clip.useSquareInLandscape) && outputOrientation === 'landscape';
|
|
166
|
+
var inputRange = activeTransition.inputRangeInSeconds;
|
|
167
|
+
var isHorizontal = orientation !== 'portrait';
|
|
168
|
+
var shouldUseDirectionalResponderToSeekerMotion = Boolean(activeTransition.isResponderToSeeker) && isHorizontal;
|
|
169
|
+
if (clipIndex === activeTransition.from) {
|
|
170
|
+
var rawWidth = timeInterpolate(inputRange, firstTargetVideoWidths, DEFAULT_TIME_INTERPOLATE_OPTIONS, fps, frame);
|
|
171
|
+
var rawHeight = timeInterpolate(inputRange, firstTargetVideoHeights, DEFAULT_TIME_INTERPOLATE_OPTIONS, fps, frame);
|
|
172
|
+
var renderWidth = useSquareInLandscape ? Math.min(rawWidth, 1080) : rawWidth;
|
|
173
|
+
var _centeredOffsetX = useSquareInLandscape ? Math.max(0, (width - TOTAL_X_PADDING - renderWidth) / 2) : 0;
|
|
174
|
+
var fullWidthInHorizontal = width - TOTAL_X_PADDING - GAP_BETWEEN_VIDEOS;
|
|
175
|
+
var directionalTranslateX = Math.max(0, fullWidthInHorizontal - rawWidth);
|
|
176
|
+
var defaultTranslateX = timeInterpolate(inputRange, [_centeredOffsetX, 0, 0, 0], DEFAULT_TIME_INTERPOLATE_OPTIONS, fps, frame);
|
|
177
|
+
return {
|
|
178
|
+
videoWidth: rawWidth,
|
|
179
|
+
videoHeight: rawHeight,
|
|
180
|
+
translateX: shouldUseDirectionalResponderToSeekerMotion ? directionalTranslateX : defaultTranslateX,
|
|
181
|
+
useSquareInLandscape: useSquareInLandscape
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
if (clipIndex === activeTransition.to) {
|
|
185
|
+
var _rawWidth = timeInterpolate(inputRange, secondTargetVideoWidths, DEFAULT_TIME_INTERPOLATE_OPTIONS, fps, frame);
|
|
186
|
+
var halfWidthInHorizontal = width / 2 - TOTAL_X_PADDING - GAP_BETWEEN_VIDEOS;
|
|
187
|
+
var _fullWidthInHorizontal = width - TOTAL_X_PADDING - GAP_BETWEEN_VIDEOS;
|
|
188
|
+
var directionalRawWidth = timeInterpolate(inputRange, [0, halfWidthInHorizontal, halfWidthInHorizontal, _fullWidthInHorizontal], DEFAULT_TIME_INTERPOLATE_OPTIONS, fps, frame);
|
|
189
|
+
var effectiveRawWidth = shouldUseDirectionalResponderToSeekerMotion ? directionalRawWidth : _rawWidth;
|
|
190
|
+
var _rawHeight = timeInterpolate(inputRange, secondTargetVideoHeights, DEFAULT_TIME_INTERPOLATE_OPTIONS, fps, frame);
|
|
191
|
+
var _renderWidth = useSquareInLandscape ? Math.min(effectiveRawWidth, 1080) : effectiveRawWidth;
|
|
192
|
+
var _centeredOffsetX2 = useSquareInLandscape ? Math.max(0, (width - TOTAL_X_PADDING - _renderWidth) / 2) : 0;
|
|
193
|
+
var _defaultTranslateX = timeInterpolate(inputRange, [_centeredOffsetX2, 0, 0, _centeredOffsetX2], DEFAULT_TIME_INTERPOLATE_OPTIONS, fps, frame);
|
|
194
|
+
var currentFromRawWidth = timeInterpolate(inputRange, firstTargetVideoWidths, DEFAULT_TIME_INTERPOLATE_OPTIONS, fps, frame);
|
|
195
|
+
var _directionalTranslateX = -currentFromRawWidth;
|
|
196
|
+
return {
|
|
197
|
+
videoWidth: effectiveRawWidth,
|
|
198
|
+
videoHeight: _rawHeight,
|
|
199
|
+
translateX: shouldUseDirectionalResponderToSeekerMotion ? _directionalTranslateX : _defaultTranslateX,
|
|
200
|
+
useSquareInLandscape: useSquareInLandscape
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
return null;
|
|
204
|
+
};
|
|
205
|
+
var clipStates = videos.map(function (_, index) {
|
|
206
|
+
return getClipAnimationState(index);
|
|
207
|
+
});
|
|
208
|
+
var shouldUseBlackBackgroundInLandscape = videos.some(function (video) {
|
|
209
|
+
return (video === null || video === void 0 ? void 0 : video.useSquareInLandscape) && outputOrientation === 'landscape';
|
|
210
|
+
});
|
|
211
|
+
var handoffBackgroundColor = shouldUseBlackBackgroundInLandscape ? '#000000' : primaryColor;
|
|
212
|
+
var activeGap = activeTransition && frame < activeTransition.startFrame + 2 * fps ? '10px' : '0px';
|
|
213
|
+
var hasAnyNoBackgroundVideo = videos.some(function (video) {
|
|
214
|
+
return video === null || video === void 0 ? void 0 : video.noBackgroundVideoUrl;
|
|
215
|
+
});
|
|
216
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(AbsoluteFill, {
|
|
217
|
+
style: {
|
|
218
|
+
width: width,
|
|
219
|
+
height: height,
|
|
220
|
+
backgroundColor: handoffBackgroundColor
|
|
221
|
+
}
|
|
222
|
+
}, /*#__PURE__*/React.createElement(AbsoluteFill, {
|
|
223
|
+
style: {
|
|
224
|
+
zIndex: 10
|
|
225
|
+
}
|
|
226
|
+
}, children), /*#__PURE__*/React.createElement("div", {
|
|
227
|
+
style: {
|
|
228
|
+
display: 'flex',
|
|
229
|
+
width: '100%',
|
|
230
|
+
height: '100%',
|
|
231
|
+
padding: '10px 10px',
|
|
232
|
+
gap: activeGap,
|
|
233
|
+
flexDirection: orientation === 'portrait' ? 'column' : 'row'
|
|
234
|
+
}
|
|
235
|
+
}, videos.map(function (clip, index) {
|
|
236
|
+
var state = clipStates[index];
|
|
237
|
+
if (!state) {
|
|
238
|
+
return null;
|
|
239
|
+
}
|
|
240
|
+
var clipStartFrame = startFrames[index] || 0;
|
|
241
|
+
var clipDurationFrames = ((clip === null || clip === void 0 ? void 0 : clip.videoDuration) || 0) * fps;
|
|
242
|
+
var freezeActive = frame >= clipStartFrame + clipDurationFrames;
|
|
243
|
+
return /*#__PURE__*/React.createElement(Sequence, {
|
|
244
|
+
key: index,
|
|
245
|
+
from: clipStartFrame,
|
|
246
|
+
layout: "none"
|
|
247
|
+
}, /*#__PURE__*/React.createElement(Freeze, {
|
|
248
|
+
frame: clipDurationFrames,
|
|
249
|
+
active: freezeActive
|
|
250
|
+
}, renderClip({
|
|
251
|
+
clip: clip,
|
|
252
|
+
useSquareInLandscape: state.useSquareInLandscape,
|
|
253
|
+
orientation: orientation,
|
|
254
|
+
videoWidth: state.videoWidth,
|
|
255
|
+
videoHeight: state.videoHeight,
|
|
256
|
+
translateX: state.translateX
|
|
257
|
+
})));
|
|
258
|
+
})), /*#__PURE__*/React.createElement(BlurOverlay, {
|
|
259
|
+
show: Boolean(noBackgroundVideoEffects === null || noBackgroundVideoEffects === void 0 ? void 0 : noBackgroundVideoEffects.backgroundBlur) && hasAnyNoBackgroundVideo,
|
|
260
|
+
width: width,
|
|
261
|
+
height: height,
|
|
262
|
+
zIndex: 1
|
|
263
|
+
})));
|
|
264
|
+
};
|
|
@@ -8,34 +8,34 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
|
|
|
8
8
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
9
9
|
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
|
|
10
10
|
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
|
|
11
|
-
/**
|
|
12
|
-
* Face-Centered Video Component
|
|
13
|
-
*
|
|
14
|
-
* A reusable component that wraps OffthreadVideo to ensure the video is always
|
|
15
|
-
* centered on a person's face within a flexible container.
|
|
16
|
-
*
|
|
17
|
-
* The video maintains its source dimensions and is positioned using translateX/translateY
|
|
18
|
-
* to center the face within the container, regardless of container size.
|
|
11
|
+
/**
|
|
12
|
+
* Face-Centered Video Component
|
|
13
|
+
*
|
|
14
|
+
* A reusable component that wraps OffthreadVideo to ensure the video is always
|
|
15
|
+
* centered on a person's face within a flexible container.
|
|
16
|
+
*
|
|
17
|
+
* The video maintains its source dimensions and is positioned using translateX/translateY
|
|
18
|
+
* to center the face within the container, regardless of container size.
|
|
19
19
|
*/
|
|
20
20
|
|
|
21
21
|
import React from "react";
|
|
22
22
|
import { OffthreadVideo, useCurrentFrame } from "remotion";
|
|
23
23
|
import { useOrientationBased } from "../../hooks/useOrientationBased.js";
|
|
24
24
|
|
|
25
|
-
/**
|
|
26
|
-
* Calculate face-centered translation for flexible container
|
|
27
|
-
* @param {Object} params - Configuration object
|
|
28
|
-
* @param {Object} params.faceMetadata - Face detection metadata
|
|
29
|
-
* @param {number} params.containerWidth - Container width in pixels
|
|
30
|
-
* @param {number} params.containerHeight - Container height in pixels
|
|
31
|
-
* @param {number} params.currentFrame - Current frame number (optional)
|
|
32
|
-
* @param {boolean} params.enableInterpolation - Whether to interpolate between frames
|
|
33
|
-
* @param {boolean} params.useAveragePosition - Whether to use average face position
|
|
34
|
-
* @param {boolean} params.centerHorizontally - Whether to only center horizontally
|
|
35
|
-
* @param {number} params.translateX - Additional translateX offset
|
|
36
|
-
* @param {number} params.translateY - Additional translateY offset
|
|
37
|
-
* @param {string} params.orientation - Viewport orientation (portrait, square, landscape)
|
|
38
|
-
* @returns {Object} Transform styles and debug info
|
|
25
|
+
/**
|
|
26
|
+
* Calculate face-centered translation for flexible container
|
|
27
|
+
* @param {Object} params - Configuration object
|
|
28
|
+
* @param {Object} params.faceMetadata - Face detection metadata
|
|
29
|
+
* @param {number} params.containerWidth - Container width in pixels
|
|
30
|
+
* @param {number} params.containerHeight - Container height in pixels
|
|
31
|
+
* @param {number} params.currentFrame - Current frame number (optional)
|
|
32
|
+
* @param {boolean} params.enableInterpolation - Whether to interpolate between frames
|
|
33
|
+
* @param {boolean} params.useAveragePosition - Whether to use average face position
|
|
34
|
+
* @param {boolean} params.centerHorizontally - Whether to only center horizontally
|
|
35
|
+
* @param {number} params.translateX - Additional translateX offset
|
|
36
|
+
* @param {number} params.translateY - Additional translateY offset
|
|
37
|
+
* @param {string} params.orientation - Viewport orientation (portrait, square, landscape)
|
|
38
|
+
* @returns {Object} Transform styles and debug info
|
|
39
39
|
*/
|
|
40
40
|
var calculateFaceCenteredTranslation = function calculateFaceCenteredTranslation(_ref) {
|
|
41
41
|
var _faceMetadata$metadat, _faceMetadata$metadat2;
|
|
@@ -214,8 +214,8 @@ var calculateFaceCenteredTranslation = function calculateFaceCenteredTranslation
|
|
|
214
214
|
};
|
|
215
215
|
};
|
|
216
216
|
|
|
217
|
-
/**
|
|
218
|
-
* Get face data for a specific frame with optional interpolation
|
|
217
|
+
/**
|
|
218
|
+
* Get face data for a specific frame with optional interpolation
|
|
219
219
|
*/
|
|
220
220
|
function getFaceDataForFrame(frames, frameIndex, enableInterpolation) {
|
|
221
221
|
var _prevFrame, _nextFrame;
|
|
@@ -274,8 +274,8 @@ function getFaceDataForFrame(frames, frameIndex, enableInterpolation) {
|
|
|
274
274
|
return ((_prevFrame = prevFrame) === null || _prevFrame === void 0 ? void 0 : _prevFrame.data) || ((_nextFrame = nextFrame) === null || _nextFrame === void 0 ? void 0 : _nextFrame.data) || null;
|
|
275
275
|
}
|
|
276
276
|
|
|
277
|
-
/**
|
|
278
|
-
* Calculate average face position from all frames with face data
|
|
277
|
+
/**
|
|
278
|
+
* Calculate average face position from all frames with face data
|
|
279
279
|
*/
|
|
280
280
|
function getAverageFaceData(frames) {
|
|
281
281
|
if (!frames || frames.length === 0) return null;
|
|
@@ -310,14 +310,14 @@ function getAverageFaceData(frames) {
|
|
|
310
310
|
};
|
|
311
311
|
}
|
|
312
312
|
|
|
313
|
-
/**
|
|
314
|
-
* Calculate the negative space offset when face-centering a video
|
|
315
|
-
*
|
|
316
|
-
* @param {Object} faceMetadata - Face detection metadata object
|
|
317
|
-
* @param {number} containerWidth - Container width in pixels
|
|
318
|
-
* @param {number} containerHeight - Container height in pixels
|
|
319
|
-
* @param {number} scale - Scale factor applied to the video
|
|
320
|
-
* @returns {Object} Object containing horizontal and vertical offsets and which side has negative space
|
|
313
|
+
/**
|
|
314
|
+
* Calculate the negative space offset when face-centering a video
|
|
315
|
+
*
|
|
316
|
+
* @param {Object} faceMetadata - Face detection metadata object
|
|
317
|
+
* @param {number} containerWidth - Container width in pixels
|
|
318
|
+
* @param {number} containerHeight - Container height in pixels
|
|
319
|
+
* @param {number} scale - Scale factor applied to the video
|
|
320
|
+
* @returns {Object} Object containing horizontal and vertical offsets and which side has negative space
|
|
321
321
|
*/
|
|
322
322
|
export var calculateNegativeSpaceOffset = function calculateNegativeSpaceOffset(faceMetadata, containerWidth, containerHeight) {
|
|
323
323
|
var _faceMetadata$metadat4, _faceMetadata$metadat5;
|
|
@@ -415,22 +415,22 @@ export var calculateNegativeSpaceOffset = function calculateNegativeSpaceOffset(
|
|
|
415
415
|
};
|
|
416
416
|
};
|
|
417
417
|
|
|
418
|
-
/**
|
|
419
|
-
* FaceCenteredVideo Component
|
|
420
|
-
* @param {Object} props - Component props
|
|
421
|
-
* @param {string} props.src - Video source URL
|
|
422
|
-
* @param {Object} props.faceMetadata - Face detection metadata
|
|
423
|
-
* @param {number} props.containerWidth - Container width in pixels (required)
|
|
424
|
-
* @param {number} props.containerHeight - Container height in pixels (required)
|
|
425
|
-
* @param {boolean} props.enableInterpolation - Whether to interpolate between frames
|
|
426
|
-
* @param {boolean} props.useAveragePosition - Whether to use average face position for entire video duration
|
|
427
|
-
* @param {boolean} props.centerHorizontally - Whether to only center horizontally (X axis), not vertically (Y axis)
|
|
428
|
-
* @param {number} props.translateX - Additional translateX offset (optional)
|
|
429
|
-
* @param {number} props.translateY - Additional translateY offset (optional)
|
|
430
|
-
* @param {boolean} props.showDebugInfo - Whether to show debug information
|
|
431
|
-
* @param {Object} props.style - Additional styles to apply to video
|
|
432
|
-
* @param {string} props.className - CSS class name
|
|
433
|
-
* @param {...Object} props.otherProps - Other props to pass to OffthreadVideo
|
|
418
|
+
/**
|
|
419
|
+
* FaceCenteredVideo Component
|
|
420
|
+
* @param {Object} props - Component props
|
|
421
|
+
* @param {string} props.src - Video source URL
|
|
422
|
+
* @param {Object} props.faceMetadata - Face detection metadata
|
|
423
|
+
* @param {number} props.containerWidth - Container width in pixels (required)
|
|
424
|
+
* @param {number} props.containerHeight - Container height in pixels (required)
|
|
425
|
+
* @param {boolean} props.enableInterpolation - Whether to interpolate between frames
|
|
426
|
+
* @param {boolean} props.useAveragePosition - Whether to use average face position for entire video duration
|
|
427
|
+
* @param {boolean} props.centerHorizontally - Whether to only center horizontally (X axis), not vertically (Y axis)
|
|
428
|
+
* @param {number} props.translateX - Additional translateX offset (optional)
|
|
429
|
+
* @param {number} props.translateY - Additional translateY offset (optional)
|
|
430
|
+
* @param {boolean} props.showDebugInfo - Whether to show debug information
|
|
431
|
+
* @param {Object} props.style - Additional styles to apply to video
|
|
432
|
+
* @param {string} props.className - CSS class name
|
|
433
|
+
* @param {...Object} props.otherProps - Other props to pass to OffthreadVideo
|
|
434
434
|
*/
|
|
435
435
|
export var FaceCenteredVideo = function FaceCenteredVideo(_ref2) {
|
|
436
436
|
var _faceMetadata$metadat7, _faceMetadata$metadat8, _faceMetadata$metadat9, _faceMetadata$metadat10;
|
|
@@ -15,10 +15,10 @@ function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t =
|
|
|
15
15
|
import React, { useEffect, useState } from "react";
|
|
16
16
|
import { Img, delayRender, continueRender } from "remotion";
|
|
17
17
|
|
|
18
|
-
/**
|
|
19
|
-
* PausableImg component that extends Remotion's Img with fetch validation.
|
|
20
|
-
* It delays rendering until the image source can be successfully fetched.
|
|
21
|
-
* If there's an error fetching the image, it renders nothing.
|
|
18
|
+
/**
|
|
19
|
+
* PausableImg component that extends Remotion's Img with fetch validation.
|
|
20
|
+
* It delays rendering until the image source can be successfully fetched.
|
|
21
|
+
* If there's an error fetching the image, it renders nothing.
|
|
22
22
|
*/
|
|
23
23
|
export var PausableImg = /*#__PURE__*/React.memo(function (_ref) {
|
|
24
24
|
var src = _ref.src,
|