remotion 4.0.318 → 4.0.320
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/cjs/audio/Audio.js +13 -8
- package/dist/cjs/audio/props.d.ts +14 -0
- package/dist/cjs/validate-start-from-props.d.ts +16 -0
- package/dist/cjs/validate-start-from-props.js +56 -1
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/cjs/video/OffthreadVideo.js +11 -6
- package/dist/cjs/video/Video.js +13 -8
- package/dist/cjs/video/props.d.ts +14 -0
- package/dist/esm/index.mjs +98 -23
- package/dist/esm/version.mjs +1 -1
- package/package.json +3 -3
package/dist/cjs/audio/Audio.js
CHANGED
|
@@ -22,7 +22,7 @@ const shared_audio_tags_js_1 = require("./shared-audio-tags.js");
|
|
|
22
22
|
const AudioRefForwardingFunction = (props, ref) => {
|
|
23
23
|
var _a, _b, _c;
|
|
24
24
|
const audioContext = (0, react_1.useContext)(shared_audio_tags_js_1.SharedAudioContext);
|
|
25
|
-
const { startFrom, endAt, name, stack, pauseWhenBuffering, showInTimeline, ...otherProps } = props;
|
|
25
|
+
const { startFrom, endAt, trimBefore, trimAfter, name, stack, pauseWhenBuffering, showInTimeline, ...otherProps } = props;
|
|
26
26
|
const { loop, ...propsOtherThanLoop } = props;
|
|
27
27
|
const { fps } = (0, use_video_config_js_1.useVideoConfig)();
|
|
28
28
|
const environment = (0, get_remotion_environment_js_1.getRemotionEnvironment)();
|
|
@@ -49,23 +49,28 @@ const AudioRefForwardingFunction = (props, ref) => {
|
|
|
49
49
|
setDurations({ type: 'got-duration', durationInSeconds, src });
|
|
50
50
|
}, [setDurations]);
|
|
51
51
|
const durationFetched = (_a = durations[(0, absolute_src_js_1.getAbsoluteSrc)(preloadedSrc)]) !== null && _a !== void 0 ? _a : durations[(0, absolute_src_js_1.getAbsoluteSrc)(props.src)];
|
|
52
|
+
(0, validate_start_from_props_js_1.validateMediaTrimProps)({ startFrom, endAt, trimBefore, trimAfter });
|
|
53
|
+
const { trimBeforeValue, trimAfterValue } = (0, validate_start_from_props_js_1.resolveTrimProps)({
|
|
54
|
+
startFrom,
|
|
55
|
+
endAt,
|
|
56
|
+
trimBefore,
|
|
57
|
+
trimAfter,
|
|
58
|
+
});
|
|
52
59
|
if (loop && durationFetched !== undefined) {
|
|
53
60
|
if (!Number.isFinite(durationFetched)) {
|
|
54
61
|
return ((0, jsx_runtime_1.jsx)(exports.Audio, { ...propsOtherThanLoop, ref: ref, _remotionInternalNativeLoopPassed: true }));
|
|
55
62
|
}
|
|
56
63
|
const duration = durationFetched * fps;
|
|
57
64
|
return ((0, jsx_runtime_1.jsx)(index_js_1.Loop, { layout: "none", durationInFrames: (0, calculate_loop_js_1.calculateLoopDuration)({
|
|
58
|
-
endAt,
|
|
65
|
+
endAt: trimAfterValue !== null && trimAfterValue !== void 0 ? trimAfterValue : endAt,
|
|
59
66
|
mediaDuration: duration,
|
|
60
67
|
playbackRate: (_b = props.playbackRate) !== null && _b !== void 0 ? _b : 1,
|
|
61
|
-
startFrom,
|
|
68
|
+
startFrom: trimBeforeValue !== null && trimBeforeValue !== void 0 ? trimBeforeValue : startFrom,
|
|
62
69
|
}), children: (0, jsx_runtime_1.jsx)(exports.Audio, { ...propsOtherThanLoop, ref: ref, _remotionInternalNativeLoopPassed: true }) }));
|
|
63
70
|
}
|
|
64
|
-
if (typeof
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
const endAtFrameNo = endAt !== null && endAt !== void 0 ? endAt : Infinity;
|
|
68
|
-
return ((0, jsx_runtime_1.jsx)(Sequence_js_1.Sequence, { layout: "none", from: 0 - startFromFrameNo, showInTimeline: false, durationInFrames: endAtFrameNo, name: name, children: (0, jsx_runtime_1.jsx)(exports.Audio, { _remotionInternalNeedsDurationCalculation: Boolean(loop), pauseWhenBuffering: pauseWhenBuffering !== null && pauseWhenBuffering !== void 0 ? pauseWhenBuffering : false, ...otherProps, ref: ref }) }));
|
|
71
|
+
if (typeof trimBeforeValue !== 'undefined' ||
|
|
72
|
+
typeof trimAfterValue !== 'undefined') {
|
|
73
|
+
return ((0, jsx_runtime_1.jsx)(Sequence_js_1.Sequence, { layout: "none", from: 0 - (trimBeforeValue !== null && trimBeforeValue !== void 0 ? trimBeforeValue : 0), showInTimeline: false, durationInFrames: trimAfterValue, name: name, children: (0, jsx_runtime_1.jsx)(exports.Audio, { _remotionInternalNeedsDurationCalculation: Boolean(loop), pauseWhenBuffering: pauseWhenBuffering !== null && pauseWhenBuffering !== void 0 ? pauseWhenBuffering : false, ...otherProps, ref: ref }) }));
|
|
69
74
|
}
|
|
70
75
|
(0, validate_media_props_js_1.validateMediaProps)(props, 'Audio');
|
|
71
76
|
if (environment.isRendering) {
|
|
@@ -1,8 +1,22 @@
|
|
|
1
1
|
import type { VolumeProp } from '../volume-prop.js';
|
|
2
2
|
import type { LoopVolumeCurveBehavior } from './use-audio-frame.js';
|
|
3
3
|
export type RemotionMainAudioProps = {
|
|
4
|
+
/**
|
|
5
|
+
* @deprecated `startFrom` was renamed to `trimBefore`
|
|
6
|
+
*/
|
|
4
7
|
startFrom?: number;
|
|
8
|
+
/**
|
|
9
|
+
* @deprecated `endAt` was renamed to `trimAfter`
|
|
10
|
+
*/
|
|
5
11
|
endAt?: number;
|
|
12
|
+
/**
|
|
13
|
+
* Trim of the audio from the left (start) in frames.
|
|
14
|
+
*/
|
|
15
|
+
trimBefore?: number;
|
|
16
|
+
/**
|
|
17
|
+
* Trim of the audio from the right (end) in frames.
|
|
18
|
+
*/
|
|
19
|
+
trimAfter?: number;
|
|
6
20
|
};
|
|
7
21
|
export type NativeAudioProps = Omit<React.DetailedHTMLProps<React.AudioHTMLAttributes<HTMLAudioElement>, HTMLAudioElement>, 'autoPlay' | 'controls' | 'onEnded' | 'nonce' | 'onResize' | 'onResizeCapture'>;
|
|
8
22
|
export type RemotionAudioProps = NativeAudioProps & {
|
|
@@ -1 +1,17 @@
|
|
|
1
1
|
export declare const validateStartFromProps: (startFrom: number | undefined, endAt: number | undefined) => void;
|
|
2
|
+
export declare const validateTrimProps: (trimBefore: number | undefined, trimAfter: number | undefined) => void;
|
|
3
|
+
export declare const validateMediaTrimProps: ({ startFrom, endAt, trimBefore, trimAfter, }: {
|
|
4
|
+
startFrom: number | undefined;
|
|
5
|
+
endAt: number | undefined;
|
|
6
|
+
trimBefore: number | undefined;
|
|
7
|
+
trimAfter: number | undefined;
|
|
8
|
+
}) => void;
|
|
9
|
+
export declare const resolveTrimProps: ({ startFrom, endAt, trimBefore, trimAfter, }: {
|
|
10
|
+
startFrom: number | undefined;
|
|
11
|
+
endAt: number | undefined;
|
|
12
|
+
trimBefore: number | undefined;
|
|
13
|
+
trimAfter: number | undefined;
|
|
14
|
+
}) => {
|
|
15
|
+
trimBeforeValue: number | undefined;
|
|
16
|
+
trimAfterValue: number | undefined;
|
|
17
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.validateStartFromProps = void 0;
|
|
3
|
+
exports.resolveTrimProps = exports.validateMediaTrimProps = exports.validateTrimProps = exports.validateStartFromProps = void 0;
|
|
4
4
|
const validateStartFromProps = (startFrom, endAt) => {
|
|
5
5
|
if (typeof startFrom !== 'undefined') {
|
|
6
6
|
if (typeof startFrom !== 'number') {
|
|
@@ -29,3 +29,58 @@ const validateStartFromProps = (startFrom, endAt) => {
|
|
|
29
29
|
}
|
|
30
30
|
};
|
|
31
31
|
exports.validateStartFromProps = validateStartFromProps;
|
|
32
|
+
const validateTrimProps = (trimBefore, trimAfter) => {
|
|
33
|
+
if (typeof trimBefore !== 'undefined') {
|
|
34
|
+
if (typeof trimBefore !== 'number') {
|
|
35
|
+
throw new TypeError(`type of trimBefore prop must be a number, instead got type ${typeof trimBefore}.`);
|
|
36
|
+
}
|
|
37
|
+
if (isNaN(trimBefore) || trimBefore === Infinity) {
|
|
38
|
+
throw new TypeError('trimBefore prop can not be NaN or Infinity.');
|
|
39
|
+
}
|
|
40
|
+
if (trimBefore < 0) {
|
|
41
|
+
throw new TypeError(`trimBefore must be greater than equal to 0 instead got ${trimBefore}.`);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
if (typeof trimAfter !== 'undefined') {
|
|
45
|
+
if (typeof trimAfter !== 'number') {
|
|
46
|
+
throw new TypeError(`type of trimAfter prop must be a number, instead got type ${typeof trimAfter}.`);
|
|
47
|
+
}
|
|
48
|
+
if (isNaN(trimAfter)) {
|
|
49
|
+
throw new TypeError('trimAfter prop can not be NaN.');
|
|
50
|
+
}
|
|
51
|
+
if (trimAfter <= 0) {
|
|
52
|
+
throw new TypeError(`trimAfter must be a positive number, instead got ${trimAfter}.`);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
if (trimAfter < trimBefore) {
|
|
56
|
+
throw new TypeError('trimAfter prop must be greater than trimBefore prop.');
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
exports.validateTrimProps = validateTrimProps;
|
|
60
|
+
const validateMediaTrimProps = ({ startFrom, endAt, trimBefore, trimAfter, }) => {
|
|
61
|
+
// Check for conflicting props
|
|
62
|
+
if (typeof startFrom !== 'undefined' && typeof trimBefore !== 'undefined') {
|
|
63
|
+
throw new TypeError('Cannot use both startFrom and trimBefore props. Use trimBefore instead as startFrom is deprecated.');
|
|
64
|
+
}
|
|
65
|
+
if (typeof endAt !== 'undefined' && typeof trimAfter !== 'undefined') {
|
|
66
|
+
throw new TypeError('Cannot use both endAt and trimAfter props. Use trimAfter instead as endAt is deprecated.');
|
|
67
|
+
}
|
|
68
|
+
// Validate using the appropriate validation function
|
|
69
|
+
const hasNewProps = typeof trimBefore !== 'undefined' || typeof trimAfter !== 'undefined';
|
|
70
|
+
const hasOldProps = typeof startFrom !== 'undefined' || typeof endAt !== 'undefined';
|
|
71
|
+
if (hasNewProps) {
|
|
72
|
+
(0, exports.validateTrimProps)(trimBefore, trimAfter);
|
|
73
|
+
}
|
|
74
|
+
else if (hasOldProps) {
|
|
75
|
+
(0, exports.validateStartFromProps)(startFrom, endAt);
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
exports.validateMediaTrimProps = validateMediaTrimProps;
|
|
79
|
+
const resolveTrimProps = ({ startFrom, endAt, trimBefore, trimAfter, }) => {
|
|
80
|
+
var _a, _b;
|
|
81
|
+
// Use new props if available, otherwise fall back to old props
|
|
82
|
+
const trimBeforeValue = (_a = trimBefore !== null && trimBefore !== void 0 ? trimBefore : startFrom) !== null && _a !== void 0 ? _a : undefined;
|
|
83
|
+
const trimAfterValue = (_b = trimAfter !== null && trimAfter !== void 0 ? trimAfter : endAt) !== null && _b !== void 0 ? _b : undefined;
|
|
84
|
+
return { trimBeforeValue, trimAfterValue };
|
|
85
|
+
};
|
|
86
|
+
exports.resolveTrimProps = resolveTrimProps;
|
package/dist/cjs/version.d.ts
CHANGED
package/dist/cjs/version.js
CHANGED
|
@@ -16,7 +16,7 @@ const VideoForPreview_js_1 = require("./VideoForPreview.js");
|
|
|
16
16
|
const OffthreadVideo = (props) => {
|
|
17
17
|
// Should only destruct `startFrom` and `endAt` from props,
|
|
18
18
|
// rest gets drilled down
|
|
19
|
-
const { startFrom, endAt, name, pauseWhenBuffering, stack, showInTimeline, ...otherProps } = props;
|
|
19
|
+
const { startFrom, endAt, trimBefore, trimAfter, name, pauseWhenBuffering, stack, showInTimeline, ...otherProps } = props;
|
|
20
20
|
const environment = (0, get_remotion_environment_js_1.getRemotionEnvironment)();
|
|
21
21
|
const onDuration = (0, react_1.useCallback)(() => undefined, []);
|
|
22
22
|
if (typeof props.src !== 'string') {
|
|
@@ -25,11 +25,16 @@ const OffthreadVideo = (props) => {
|
|
|
25
25
|
if (props.imageFormat) {
|
|
26
26
|
throw new TypeError(`The \`<OffthreadVideo>\` tag does no longer accept \`imageFormat\`. Use the \`transparent\` prop if you want to render a transparent video.`);
|
|
27
27
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
28
|
+
(0, validate_start_from_props_js_1.validateMediaTrimProps)({ startFrom, endAt, trimBefore, trimAfter });
|
|
29
|
+
const { trimBeforeValue, trimAfterValue } = (0, validate_start_from_props_js_1.resolveTrimProps)({
|
|
30
|
+
startFrom,
|
|
31
|
+
endAt,
|
|
32
|
+
trimBefore,
|
|
33
|
+
trimAfter,
|
|
34
|
+
});
|
|
35
|
+
if (typeof trimBeforeValue !== 'undefined' ||
|
|
36
|
+
typeof trimAfterValue !== 'undefined') {
|
|
37
|
+
return ((0, jsx_runtime_1.jsx)(Sequence_js_1.Sequence, { layout: "none", from: 0 - (trimBeforeValue !== null && trimBeforeValue !== void 0 ? trimBeforeValue : 0), showInTimeline: false, durationInFrames: trimAfterValue, name: name, children: (0, jsx_runtime_1.jsx)(exports.OffthreadVideo, { pauseWhenBuffering: pauseWhenBuffering !== null && pauseWhenBuffering !== void 0 ? pauseWhenBuffering : false, ...otherProps }) }));
|
|
33
38
|
}
|
|
34
39
|
(0, validate_media_props_js_1.validateMediaProps)(props, 'Video');
|
|
35
40
|
if (environment.isRendering) {
|
package/dist/cjs/video/Video.js
CHANGED
|
@@ -19,7 +19,7 @@ const VideoForRendering_js_1 = require("./VideoForRendering.js");
|
|
|
19
19
|
const duration_state_js_1 = require("./duration-state.js");
|
|
20
20
|
const VideoForwardingFunction = (props, ref) => {
|
|
21
21
|
var _a, _b;
|
|
22
|
-
const { startFrom, endAt, name, pauseWhenBuffering, stack, _remotionInternalNativeLoopPassed, showInTimeline, onAutoPlayError, ...otherProps } = props;
|
|
22
|
+
const { startFrom, endAt, trimBefore, trimAfter, name, pauseWhenBuffering, stack, _remotionInternalNativeLoopPassed, showInTimeline, onAutoPlayError, ...otherProps } = props;
|
|
23
23
|
const { loop, ...propsOtherThanLoop } = props;
|
|
24
24
|
const { fps } = (0, use_video_config_js_1.useVideoConfig)();
|
|
25
25
|
const environment = (0, get_remotion_environment_js_1.getRemotionEnvironment)();
|
|
@@ -36,23 +36,28 @@ const VideoForwardingFunction = (props, ref) => {
|
|
|
36
36
|
}, [setDurations]);
|
|
37
37
|
const onVideoFrame = (0, react_1.useCallback)(() => { }, []);
|
|
38
38
|
const durationFetched = (_a = durations[(0, absolute_src_js_1.getAbsoluteSrc)(preloadedSrc)]) !== null && _a !== void 0 ? _a : durations[(0, absolute_src_js_1.getAbsoluteSrc)(props.src)];
|
|
39
|
+
(0, validate_start_from_props_js_1.validateMediaTrimProps)({ startFrom, endAt, trimBefore, trimAfter });
|
|
40
|
+
const { trimBeforeValue, trimAfterValue } = (0, validate_start_from_props_js_1.resolveTrimProps)({
|
|
41
|
+
startFrom,
|
|
42
|
+
endAt,
|
|
43
|
+
trimBefore,
|
|
44
|
+
trimAfter,
|
|
45
|
+
});
|
|
39
46
|
if (loop && durationFetched !== undefined) {
|
|
40
47
|
if (!Number.isFinite(durationFetched)) {
|
|
41
48
|
return ((0, jsx_runtime_1.jsx)(exports.Video, { ...propsOtherThanLoop, ref: ref, _remotionInternalNativeLoopPassed: true }));
|
|
42
49
|
}
|
|
43
50
|
const mediaDuration = durationFetched * fps;
|
|
44
51
|
return ((0, jsx_runtime_1.jsx)(index_js_1.Loop, { durationInFrames: (0, calculate_loop_js_1.calculateLoopDuration)({
|
|
45
|
-
endAt,
|
|
52
|
+
endAt: trimAfterValue !== null && trimAfterValue !== void 0 ? trimAfterValue : undefined,
|
|
46
53
|
mediaDuration,
|
|
47
54
|
playbackRate: (_b = props.playbackRate) !== null && _b !== void 0 ? _b : 1,
|
|
48
|
-
startFrom,
|
|
55
|
+
startFrom: trimBeforeValue !== null && trimBeforeValue !== void 0 ? trimBeforeValue : undefined,
|
|
49
56
|
}), layout: "none", name: name, children: (0, jsx_runtime_1.jsx)(exports.Video, { ...propsOtherThanLoop, ref: ref, _remotionInternalNativeLoopPassed: true }) }));
|
|
50
57
|
}
|
|
51
|
-
if (typeof
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
const endAtFrameNo = endAt !== null && endAt !== void 0 ? endAt : Infinity;
|
|
55
|
-
return ((0, jsx_runtime_1.jsx)(Sequence_js_1.Sequence, { layout: "none", from: 0 - startFromFrameNo, showInTimeline: false, durationInFrames: endAtFrameNo, name: name, children: (0, jsx_runtime_1.jsx)(exports.Video, { pauseWhenBuffering: pauseWhenBuffering !== null && pauseWhenBuffering !== void 0 ? pauseWhenBuffering : false, ...otherProps, ref: ref }) }));
|
|
58
|
+
if (typeof trimBeforeValue !== 'undefined' ||
|
|
59
|
+
typeof trimAfterValue !== 'undefined') {
|
|
60
|
+
return ((0, jsx_runtime_1.jsx)(Sequence_js_1.Sequence, { layout: "none", from: 0 - (trimBeforeValue !== null && trimBeforeValue !== void 0 ? trimBeforeValue : 0), showInTimeline: false, durationInFrames: trimAfterValue, name: name, children: (0, jsx_runtime_1.jsx)(exports.Video, { pauseWhenBuffering: pauseWhenBuffering !== null && pauseWhenBuffering !== void 0 ? pauseWhenBuffering : false, ...otherProps, ref: ref }) }));
|
|
56
61
|
}
|
|
57
62
|
(0, validate_media_props_js_1.validateMediaProps)(props, 'Video');
|
|
58
63
|
if (environment.isRendering) {
|
|
@@ -2,8 +2,22 @@ import type React from 'react';
|
|
|
2
2
|
import type { LoopVolumeCurveBehavior } from '../audio/use-audio-frame.js';
|
|
3
3
|
import type { VolumeProp } from '../volume-prop.js';
|
|
4
4
|
export type RemotionMainVideoProps = {
|
|
5
|
+
/**
|
|
6
|
+
* @deprecated `startFrom` was renamed to `trimBefore`
|
|
7
|
+
*/
|
|
5
8
|
startFrom?: number;
|
|
9
|
+
/**
|
|
10
|
+
* @deprecated `endAt` was renamed to `trimAfter`
|
|
11
|
+
*/
|
|
6
12
|
endAt?: number;
|
|
13
|
+
/**
|
|
14
|
+
* Trim of th e video from the left (start) in frames.
|
|
15
|
+
*/
|
|
16
|
+
trimBefore?: number;
|
|
17
|
+
/**
|
|
18
|
+
* Trim of the video from the right (end) in frames.
|
|
19
|
+
*/
|
|
20
|
+
trimAfter?: number;
|
|
7
21
|
/**
|
|
8
22
|
* @deprecated Only for internal `transparent` use
|
|
9
23
|
*/
|
package/dist/esm/index.mjs
CHANGED
|
@@ -104,7 +104,7 @@ function truthy(value) {
|
|
|
104
104
|
}
|
|
105
105
|
|
|
106
106
|
// src/version.ts
|
|
107
|
-
var VERSION = "4.0.
|
|
107
|
+
var VERSION = "4.0.320";
|
|
108
108
|
|
|
109
109
|
// src/multiple-versions-warning.ts
|
|
110
110
|
var checkMultipleRemotionVersions = () => {
|
|
@@ -2515,6 +2515,63 @@ var validateStartFromProps = (startFrom, endAt) => {
|
|
|
2515
2515
|
throw new TypeError("endAt prop must be greater than startFrom prop.");
|
|
2516
2516
|
}
|
|
2517
2517
|
};
|
|
2518
|
+
var validateTrimProps = (trimBefore, trimAfter) => {
|
|
2519
|
+
if (typeof trimBefore !== "undefined") {
|
|
2520
|
+
if (typeof trimBefore !== "number") {
|
|
2521
|
+
throw new TypeError(`type of trimBefore prop must be a number, instead got type ${typeof trimBefore}.`);
|
|
2522
|
+
}
|
|
2523
|
+
if (isNaN(trimBefore) || trimBefore === Infinity) {
|
|
2524
|
+
throw new TypeError("trimBefore prop can not be NaN or Infinity.");
|
|
2525
|
+
}
|
|
2526
|
+
if (trimBefore < 0) {
|
|
2527
|
+
throw new TypeError(`trimBefore must be greater than equal to 0 instead got ${trimBefore}.`);
|
|
2528
|
+
}
|
|
2529
|
+
}
|
|
2530
|
+
if (typeof trimAfter !== "undefined") {
|
|
2531
|
+
if (typeof trimAfter !== "number") {
|
|
2532
|
+
throw new TypeError(`type of trimAfter prop must be a number, instead got type ${typeof trimAfter}.`);
|
|
2533
|
+
}
|
|
2534
|
+
if (isNaN(trimAfter)) {
|
|
2535
|
+
throw new TypeError("trimAfter prop can not be NaN.");
|
|
2536
|
+
}
|
|
2537
|
+
if (trimAfter <= 0) {
|
|
2538
|
+
throw new TypeError(`trimAfter must be a positive number, instead got ${trimAfter}.`);
|
|
2539
|
+
}
|
|
2540
|
+
}
|
|
2541
|
+
if (trimAfter < trimBefore) {
|
|
2542
|
+
throw new TypeError("trimAfter prop must be greater than trimBefore prop.");
|
|
2543
|
+
}
|
|
2544
|
+
};
|
|
2545
|
+
var validateMediaTrimProps = ({
|
|
2546
|
+
startFrom,
|
|
2547
|
+
endAt,
|
|
2548
|
+
trimBefore,
|
|
2549
|
+
trimAfter
|
|
2550
|
+
}) => {
|
|
2551
|
+
if (typeof startFrom !== "undefined" && typeof trimBefore !== "undefined") {
|
|
2552
|
+
throw new TypeError("Cannot use both startFrom and trimBefore props. Use trimBefore instead as startFrom is deprecated.");
|
|
2553
|
+
}
|
|
2554
|
+
if (typeof endAt !== "undefined" && typeof trimAfter !== "undefined") {
|
|
2555
|
+
throw new TypeError("Cannot use both endAt and trimAfter props. Use trimAfter instead as endAt is deprecated.");
|
|
2556
|
+
}
|
|
2557
|
+
const hasNewProps = typeof trimBefore !== "undefined" || typeof trimAfter !== "undefined";
|
|
2558
|
+
const hasOldProps = typeof startFrom !== "undefined" || typeof endAt !== "undefined";
|
|
2559
|
+
if (hasNewProps) {
|
|
2560
|
+
validateTrimProps(trimBefore, trimAfter);
|
|
2561
|
+
} else if (hasOldProps) {
|
|
2562
|
+
validateStartFromProps(startFrom, endAt);
|
|
2563
|
+
}
|
|
2564
|
+
};
|
|
2565
|
+
var resolveTrimProps = ({
|
|
2566
|
+
startFrom,
|
|
2567
|
+
endAt,
|
|
2568
|
+
trimBefore,
|
|
2569
|
+
trimAfter
|
|
2570
|
+
}) => {
|
|
2571
|
+
const trimBeforeValue = trimBefore ?? startFrom ?? undefined;
|
|
2572
|
+
const trimAfterValue = trimAfter ?? endAt ?? undefined;
|
|
2573
|
+
return { trimBeforeValue, trimAfterValue };
|
|
2574
|
+
};
|
|
2518
2575
|
|
|
2519
2576
|
// src/video/duration-state.tsx
|
|
2520
2577
|
import { createContext as createContext13, useMemo as useMemo12, useReducer } from "react";
|
|
@@ -4573,6 +4630,8 @@ var AudioRefForwardingFunction = (props, ref) => {
|
|
|
4573
4630
|
const {
|
|
4574
4631
|
startFrom,
|
|
4575
4632
|
endAt,
|
|
4633
|
+
trimBefore,
|
|
4634
|
+
trimAfter,
|
|
4576
4635
|
name,
|
|
4577
4636
|
stack,
|
|
4578
4637
|
pauseWhenBuffering,
|
|
@@ -4600,6 +4659,13 @@ var AudioRefForwardingFunction = (props, ref) => {
|
|
|
4600
4659
|
setDurations({ type: "got-duration", durationInSeconds, src });
|
|
4601
4660
|
}, [setDurations]);
|
|
4602
4661
|
const durationFetched = durations[getAbsoluteSrc(preloadedSrc)] ?? durations[getAbsoluteSrc(props.src)];
|
|
4662
|
+
validateMediaTrimProps({ startFrom, endAt, trimBefore, trimAfter });
|
|
4663
|
+
const { trimBeforeValue, trimAfterValue } = resolveTrimProps({
|
|
4664
|
+
startFrom,
|
|
4665
|
+
endAt,
|
|
4666
|
+
trimBefore,
|
|
4667
|
+
trimAfter
|
|
4668
|
+
});
|
|
4603
4669
|
if (loop && durationFetched !== undefined) {
|
|
4604
4670
|
if (!Number.isFinite(durationFetched)) {
|
|
4605
4671
|
return /* @__PURE__ */ jsx19(Audio, {
|
|
@@ -4612,10 +4678,10 @@ var AudioRefForwardingFunction = (props, ref) => {
|
|
|
4612
4678
|
return /* @__PURE__ */ jsx19(Loop, {
|
|
4613
4679
|
layout: "none",
|
|
4614
4680
|
durationInFrames: calculateLoopDuration({
|
|
4615
|
-
endAt,
|
|
4681
|
+
endAt: trimAfterValue ?? endAt,
|
|
4616
4682
|
mediaDuration: duration,
|
|
4617
4683
|
playbackRate: props.playbackRate ?? 1,
|
|
4618
|
-
startFrom
|
|
4684
|
+
startFrom: trimBeforeValue ?? startFrom
|
|
4619
4685
|
}),
|
|
4620
4686
|
children: /* @__PURE__ */ jsx19(Audio, {
|
|
4621
4687
|
...propsOtherThanLoop,
|
|
@@ -4624,15 +4690,12 @@ var AudioRefForwardingFunction = (props, ref) => {
|
|
|
4624
4690
|
})
|
|
4625
4691
|
});
|
|
4626
4692
|
}
|
|
4627
|
-
if (typeof
|
|
4628
|
-
validateStartFromProps(startFrom, endAt);
|
|
4629
|
-
const startFromFrameNo = startFrom ?? 0;
|
|
4630
|
-
const endAtFrameNo = endAt ?? Infinity;
|
|
4693
|
+
if (typeof trimBeforeValue !== "undefined" || typeof trimAfterValue !== "undefined") {
|
|
4631
4694
|
return /* @__PURE__ */ jsx19(Sequence, {
|
|
4632
4695
|
layout: "none",
|
|
4633
|
-
from: 0 -
|
|
4696
|
+
from: 0 - (trimBeforeValue ?? 0),
|
|
4634
4697
|
showInTimeline: false,
|
|
4635
|
-
durationInFrames:
|
|
4698
|
+
durationInFrames: trimAfterValue,
|
|
4636
4699
|
name,
|
|
4637
4700
|
children: /* @__PURE__ */ jsx19(Audio, {
|
|
4638
4701
|
_remotionInternalNeedsDurationCalculation: Boolean(loop),
|
|
@@ -7282,6 +7345,8 @@ var OffthreadVideo = (props2) => {
|
|
|
7282
7345
|
const {
|
|
7283
7346
|
startFrom,
|
|
7284
7347
|
endAt,
|
|
7348
|
+
trimBefore,
|
|
7349
|
+
trimAfter,
|
|
7285
7350
|
name,
|
|
7286
7351
|
pauseWhenBuffering,
|
|
7287
7352
|
stack,
|
|
@@ -7298,15 +7363,19 @@ var OffthreadVideo = (props2) => {
|
|
|
7298
7363
|
if (props2.imageFormat) {
|
|
7299
7364
|
throw new TypeError(`The \`<OffthreadVideo>\` tag does no longer accept \`imageFormat\`. Use the \`transparent\` prop if you want to render a transparent video.`);
|
|
7300
7365
|
}
|
|
7301
|
-
|
|
7302
|
-
|
|
7303
|
-
|
|
7304
|
-
|
|
7366
|
+
validateMediaTrimProps({ startFrom, endAt, trimBefore, trimAfter });
|
|
7367
|
+
const { trimBeforeValue, trimAfterValue } = resolveTrimProps({
|
|
7368
|
+
startFrom,
|
|
7369
|
+
endAt,
|
|
7370
|
+
trimBefore,
|
|
7371
|
+
trimAfter
|
|
7372
|
+
});
|
|
7373
|
+
if (typeof trimBeforeValue !== "undefined" || typeof trimAfterValue !== "undefined") {
|
|
7305
7374
|
return /* @__PURE__ */ jsx32(Sequence, {
|
|
7306
7375
|
layout: "none",
|
|
7307
|
-
from: 0 -
|
|
7376
|
+
from: 0 - (trimBeforeValue ?? 0),
|
|
7308
7377
|
showInTimeline: false,
|
|
7309
|
-
durationInFrames:
|
|
7378
|
+
durationInFrames: trimAfterValue,
|
|
7310
7379
|
name,
|
|
7311
7380
|
children: /* @__PURE__ */ jsx32(OffthreadVideo, {
|
|
7312
7381
|
pauseWhenBuffering: pauseWhenBuffering ?? false,
|
|
@@ -7686,6 +7755,8 @@ var VideoForwardingFunction = (props2, ref) => {
|
|
|
7686
7755
|
const {
|
|
7687
7756
|
startFrom,
|
|
7688
7757
|
endAt,
|
|
7758
|
+
trimBefore,
|
|
7759
|
+
trimAfter,
|
|
7689
7760
|
name,
|
|
7690
7761
|
pauseWhenBuffering,
|
|
7691
7762
|
stack,
|
|
@@ -7710,6 +7781,13 @@ var VideoForwardingFunction = (props2, ref) => {
|
|
|
7710
7781
|
}, [setDurations]);
|
|
7711
7782
|
const onVideoFrame = useCallback16(() => {}, []);
|
|
7712
7783
|
const durationFetched = durations[getAbsoluteSrc(preloadedSrc)] ?? durations[getAbsoluteSrc(props2.src)];
|
|
7784
|
+
validateMediaTrimProps({ startFrom, endAt, trimBefore, trimAfter });
|
|
7785
|
+
const { trimBeforeValue, trimAfterValue } = resolveTrimProps({
|
|
7786
|
+
startFrom,
|
|
7787
|
+
endAt,
|
|
7788
|
+
trimBefore,
|
|
7789
|
+
trimAfter
|
|
7790
|
+
});
|
|
7713
7791
|
if (loop && durationFetched !== undefined) {
|
|
7714
7792
|
if (!Number.isFinite(durationFetched)) {
|
|
7715
7793
|
return /* @__PURE__ */ jsx34(Video, {
|
|
@@ -7721,10 +7799,10 @@ var VideoForwardingFunction = (props2, ref) => {
|
|
|
7721
7799
|
const mediaDuration = durationFetched * fps;
|
|
7722
7800
|
return /* @__PURE__ */ jsx34(Loop, {
|
|
7723
7801
|
durationInFrames: calculateLoopDuration({
|
|
7724
|
-
endAt,
|
|
7802
|
+
endAt: trimAfterValue ?? undefined,
|
|
7725
7803
|
mediaDuration,
|
|
7726
7804
|
playbackRate: props2.playbackRate ?? 1,
|
|
7727
|
-
startFrom
|
|
7805
|
+
startFrom: trimBeforeValue ?? undefined
|
|
7728
7806
|
}),
|
|
7729
7807
|
layout: "none",
|
|
7730
7808
|
name,
|
|
@@ -7735,15 +7813,12 @@ var VideoForwardingFunction = (props2, ref) => {
|
|
|
7735
7813
|
})
|
|
7736
7814
|
});
|
|
7737
7815
|
}
|
|
7738
|
-
if (typeof
|
|
7739
|
-
validateStartFromProps(startFrom, endAt);
|
|
7740
|
-
const startFromFrameNo = startFrom ?? 0;
|
|
7741
|
-
const endAtFrameNo = endAt ?? Infinity;
|
|
7816
|
+
if (typeof trimBeforeValue !== "undefined" || typeof trimAfterValue !== "undefined") {
|
|
7742
7817
|
return /* @__PURE__ */ jsx34(Sequence, {
|
|
7743
7818
|
layout: "none",
|
|
7744
|
-
from: 0 -
|
|
7819
|
+
from: 0 - (trimBeforeValue ?? 0),
|
|
7745
7820
|
showInTimeline: false,
|
|
7746
|
-
durationInFrames:
|
|
7821
|
+
durationInFrames: trimAfterValue,
|
|
7747
7822
|
name,
|
|
7748
7823
|
children: /* @__PURE__ */ jsx34(Video, {
|
|
7749
7824
|
pauseWhenBuffering: pauseWhenBuffering ?? false,
|
package/dist/esm/version.mjs
CHANGED
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"url": "https://github.com/remotion-dev/remotion/tree/main/packages/core"
|
|
4
4
|
},
|
|
5
5
|
"name": "remotion",
|
|
6
|
-
"version": "4.0.
|
|
6
|
+
"version": "4.0.320",
|
|
7
7
|
"description": "Make videos programmatically",
|
|
8
8
|
"main": "dist/cjs/index.js",
|
|
9
9
|
"types": "dist/cjs/index.d.ts",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"webpack": "5.96.1",
|
|
29
29
|
"zod": "3.22.3",
|
|
30
30
|
"eslint": "9.19.0",
|
|
31
|
-
"@remotion/eslint-config-internal": "4.0.
|
|
31
|
+
"@remotion/eslint-config-internal": "4.0.320"
|
|
32
32
|
},
|
|
33
33
|
"keywords": [
|
|
34
34
|
"remotion",
|
|
@@ -73,7 +73,7 @@
|
|
|
73
73
|
},
|
|
74
74
|
"homepage": "https://www.remotion.dev/docs/remotion",
|
|
75
75
|
"scripts": {
|
|
76
|
-
"formatting": "prettier src --check",
|
|
76
|
+
"formatting": "prettier --experimental-cli src --check",
|
|
77
77
|
"lint": "eslint src",
|
|
78
78
|
"test": "bun test src/test",
|
|
79
79
|
"make": "tsc -d && bun --env-file=../.env.bundle bundle.ts"
|