@remotion/media 4.0.491 → 4.0.493
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/esm/index.mjs
CHANGED
|
@@ -4876,6 +4876,12 @@ var AudioForRendering = ({
|
|
|
4876
4876
|
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
4877
4877
|
var { validateMediaProps } = Internals17;
|
|
4878
4878
|
var audioSchema = {
|
|
4879
|
+
src: {
|
|
4880
|
+
type: "asset",
|
|
4881
|
+
default: undefined,
|
|
4882
|
+
description: "Source",
|
|
4883
|
+
keyframable: false
|
|
4884
|
+
},
|
|
4879
4885
|
...Internals17.baseSchema,
|
|
4880
4886
|
volume: {
|
|
4881
4887
|
type: "number",
|
|
@@ -4990,13 +4996,34 @@ var Audio = Interactive.withSchema({
|
|
|
4990
4996
|
// src/video/video.tsx
|
|
4991
4997
|
import React6, { useMemo as useMemo6, useState as useState6 } from "react";
|
|
4992
4998
|
import {
|
|
4993
|
-
Internals as
|
|
4999
|
+
Internals as Internals22,
|
|
4994
5000
|
Interactive as Interactive2,
|
|
4995
5001
|
Sequence as Sequence2,
|
|
4996
5002
|
useRemotionEnvironment as useRemotionEnvironment4,
|
|
4997
5003
|
useVideoConfig as useVideoConfig5
|
|
4998
5004
|
} from "remotion";
|
|
4999
5005
|
|
|
5006
|
+
// src/video/get-video-sequence-duration.ts
|
|
5007
|
+
import { Internals as Internals18 } from "remotion";
|
|
5008
|
+
var getVideoSequenceDuration = ({
|
|
5009
|
+
durationInFrames,
|
|
5010
|
+
loop,
|
|
5011
|
+
playbackRate,
|
|
5012
|
+
trimAfter,
|
|
5013
|
+
trimBefore
|
|
5014
|
+
}) => {
|
|
5015
|
+
if (loop || trimAfter === undefined) {
|
|
5016
|
+
return durationInFrames;
|
|
5017
|
+
}
|
|
5018
|
+
const trimmedDuration = Internals18.calculateMediaDuration({
|
|
5019
|
+
trimAfter,
|
|
5020
|
+
trimBefore,
|
|
5021
|
+
playbackRate,
|
|
5022
|
+
mediaDurationInFrames: Infinity
|
|
5023
|
+
});
|
|
5024
|
+
return Math.min(durationInFrames ?? Infinity, trimmedDuration);
|
|
5025
|
+
};
|
|
5026
|
+
|
|
5000
5027
|
// src/video/video-for-preview.tsx
|
|
5001
5028
|
import {
|
|
5002
5029
|
useCallback,
|
|
@@ -5009,7 +5036,7 @@ import {
|
|
|
5009
5036
|
} from "react";
|
|
5010
5037
|
import {
|
|
5011
5038
|
Html5Video,
|
|
5012
|
-
Internals as
|
|
5039
|
+
Internals as Internals20,
|
|
5013
5040
|
useBufferState as useBufferState2,
|
|
5014
5041
|
useCurrentFrame as useCurrentFrame3,
|
|
5015
5042
|
useVideoConfig as useVideoConfig3
|
|
@@ -5052,7 +5079,7 @@ var getCachedVideoFrame = (src) => {
|
|
|
5052
5079
|
};
|
|
5053
5080
|
|
|
5054
5081
|
// src/video/warn-object-fit-css.ts
|
|
5055
|
-
import { Internals as
|
|
5082
|
+
import { Internals as Internals19 } from "remotion";
|
|
5056
5083
|
var OBJECT_FIT_CLASS_PATTERN = /\bobject-(contain|cover|fill|none|scale-down)\b/;
|
|
5057
5084
|
var warnedStyle = false;
|
|
5058
5085
|
var warnedClassName = false;
|
|
@@ -5063,11 +5090,11 @@ var warnAboutObjectFitInStyleOrClassName = ({
|
|
|
5063
5090
|
}) => {
|
|
5064
5091
|
if (!warnedStyle && style?.objectFit) {
|
|
5065
5092
|
warnedStyle = true;
|
|
5066
|
-
|
|
5093
|
+
Internals19.Log.warn({ logLevel, tag: "@remotion/media" }, "Use the `objectFit` prop instead of the `style` prop.");
|
|
5067
5094
|
}
|
|
5068
5095
|
if (!warnedClassName && className && OBJECT_FIT_CLASS_PATTERN.test(className)) {
|
|
5069
5096
|
warnedClassName = true;
|
|
5070
|
-
|
|
5097
|
+
Internals19.Log.warn({ logLevel, tag: "@remotion/media" }, "Use the `objectFit` prop instead of `object-*` CSS class names.");
|
|
5071
5098
|
}
|
|
5072
5099
|
};
|
|
5073
5100
|
|
|
@@ -5085,7 +5112,7 @@ var {
|
|
|
5085
5112
|
usePreload: usePreload2,
|
|
5086
5113
|
SequenceContext: SequenceContext2,
|
|
5087
5114
|
useEffectChainState
|
|
5088
|
-
} =
|
|
5115
|
+
} = Internals20;
|
|
5089
5116
|
var VideoForPreviewAssertedShowing = ({
|
|
5090
5117
|
src: unpreloadedSrc,
|
|
5091
5118
|
style,
|
|
@@ -5128,7 +5155,7 @@ var VideoForPreviewAssertedShowing = ({
|
|
|
5128
5155
|
const [mediaPlayerReady, setMediaPlayerReady] = useState4(false);
|
|
5129
5156
|
const [shouldFallbackToNativeVideo, setShouldFallbackToNativeVideo] = useState4(false);
|
|
5130
5157
|
const [playing] = Timeline2.usePlayingState();
|
|
5131
|
-
const { playbackRate: globalPlaybackRate } =
|
|
5158
|
+
const { playbackRate: globalPlaybackRate } = Internals20.usePlaybackRate();
|
|
5132
5159
|
const sharedAudioContext = useContext4(SharedAudioContext2);
|
|
5133
5160
|
const buffer = useBufferState2();
|
|
5134
5161
|
const canvasRefCallback = useCallback((canvas) => {
|
|
@@ -5165,12 +5192,12 @@ var VideoForPreviewAssertedShowing = ({
|
|
|
5165
5192
|
const currentTimeRef = useRef2(currentTime);
|
|
5166
5193
|
currentTimeRef.current = currentTime;
|
|
5167
5194
|
const preloadedSrc = usePreload2(src);
|
|
5168
|
-
const buffering = useContext4(
|
|
5195
|
+
const buffering = useContext4(Internals20.BufferingContextReact);
|
|
5169
5196
|
if (!buffering) {
|
|
5170
5197
|
throw new Error("useMediaPlayback must be used inside a <BufferingContext>");
|
|
5171
5198
|
}
|
|
5172
5199
|
const effectiveMuted = muted || playerMuted || userPreferredVolume <= 0;
|
|
5173
|
-
const isPlayerBuffering =
|
|
5200
|
+
const isPlayerBuffering = Internals20.useIsPlayerBuffering(buffering);
|
|
5174
5201
|
const initialPlaying = useRef2(playing && !isPlayerBuffering);
|
|
5175
5202
|
const initialIsPremounting = useRef2(isPremounting);
|
|
5176
5203
|
const initialIsPostmounting = useRef2(isPostmounting);
|
|
@@ -5268,7 +5295,7 @@ var VideoForPreviewAssertedShowing = ({
|
|
|
5268
5295
|
if (action === "fail") {
|
|
5269
5296
|
throw errorToUse;
|
|
5270
5297
|
}
|
|
5271
|
-
|
|
5298
|
+
Internals20.Log.warn({ logLevel, tag: "@remotion/media" }, fallbackMessage);
|
|
5272
5299
|
setShouldFallbackToNativeVideo(true);
|
|
5273
5300
|
};
|
|
5274
5301
|
if (result.type === "unknown-container-format") {
|
|
@@ -5310,7 +5337,7 @@ var VideoForPreviewAssertedShowing = ({
|
|
|
5310
5337
|
if (action === "fail") {
|
|
5311
5338
|
throw errorToUse;
|
|
5312
5339
|
}
|
|
5313
|
-
|
|
5340
|
+
Internals20.Log.error({ logLevel, tag: "@remotion/media" }, "[VideoForPreview] Failed to initialize MediaPlayer", errorToUse);
|
|
5314
5341
|
setShouldFallbackToNativeVideo(true);
|
|
5315
5342
|
});
|
|
5316
5343
|
} catch (error) {
|
|
@@ -5324,12 +5351,12 @@ var VideoForPreviewAssertedShowing = ({
|
|
|
5324
5351
|
if (action === "fail") {
|
|
5325
5352
|
throw errorToUse;
|
|
5326
5353
|
}
|
|
5327
|
-
|
|
5354
|
+
Internals20.Log.error({ logLevel, tag: "@remotion/media" }, "[VideoForPreview] MediaPlayer initialization failed", errorToUse);
|
|
5328
5355
|
setShouldFallbackToNativeVideo(true);
|
|
5329
5356
|
}
|
|
5330
5357
|
return () => {
|
|
5331
5358
|
if (mediaPlayerRef.current) {
|
|
5332
|
-
|
|
5359
|
+
Internals20.Log.trace({ logLevel, tag: "@remotion/media" }, `[VideoForPreview] Disposing MediaPlayer`);
|
|
5333
5360
|
mediaPlayerRef.current.dispose();
|
|
5334
5361
|
mediaPlayerRef.current = null;
|
|
5335
5362
|
}
|
|
@@ -5353,7 +5380,7 @@ var VideoForPreviewAssertedShowing = ({
|
|
|
5353
5380
|
]);
|
|
5354
5381
|
warnAboutObjectFitInStyleOrClassName({ style, className, logLevel });
|
|
5355
5382
|
const classNameValue = useMemo4(() => {
|
|
5356
|
-
return [
|
|
5383
|
+
return [Internals20.OBJECTFIT_CONTAIN_CLASS_NAME, className].filter(Internals20.truthy).join(" ");
|
|
5357
5384
|
}, [className]);
|
|
5358
5385
|
useCommonEffects({
|
|
5359
5386
|
mediaPlayerRef,
|
|
@@ -5477,7 +5504,7 @@ import {
|
|
|
5477
5504
|
useState as useState5
|
|
5478
5505
|
} from "react";
|
|
5479
5506
|
import {
|
|
5480
|
-
Internals as
|
|
5507
|
+
Internals as Internals21,
|
|
5481
5508
|
Loop,
|
|
5482
5509
|
random as random2,
|
|
5483
5510
|
useCurrentFrame as useCurrentFrame4,
|
|
@@ -5518,11 +5545,11 @@ var VideoForRendering = ({
|
|
|
5518
5545
|
throw new TypeError("No `src` was passed to <Video>.");
|
|
5519
5546
|
}
|
|
5520
5547
|
const frame = useCurrentFrame4();
|
|
5521
|
-
const absoluteFrame =
|
|
5548
|
+
const absoluteFrame = Internals21.useTimelinePosition();
|
|
5522
5549
|
const { fps } = useVideoConfig4();
|
|
5523
|
-
const { registerRenderAsset, unregisterRenderAsset } = useContext5(
|
|
5524
|
-
const startsAt =
|
|
5525
|
-
const sequenceContext = useContext5(
|
|
5550
|
+
const { registerRenderAsset, unregisterRenderAsset } = useContext5(Internals21.RenderAssetManager);
|
|
5551
|
+
const startsAt = Internals21.useMediaStartsAt();
|
|
5552
|
+
const sequenceContext = useContext5(Internals21.SequenceContext);
|
|
5526
5553
|
const id = useMemo5(() => `media-video-${random2(src)}-${sequenceContext?.cumulatedFrom}-${sequenceContext?.relativeFrom}-${sequenceContext?.durationInFrames}`, [
|
|
5527
5554
|
src,
|
|
5528
5555
|
sequenceContext?.cumulatedFrom,
|
|
@@ -5534,10 +5561,10 @@ var VideoForRendering = ({
|
|
|
5534
5561
|
const canvasRef = useRef3(null);
|
|
5535
5562
|
const [replaceWithOffthreadVideo, setReplaceWithOffthreadVideo] = useState5(false);
|
|
5536
5563
|
const [initialRequestInit] = useState5(requestInit);
|
|
5537
|
-
const audioEnabled =
|
|
5538
|
-
const videoEnabled =
|
|
5564
|
+
const audioEnabled = Internals21.useAudioEnabled();
|
|
5565
|
+
const videoEnabled = Internals21.useVideoEnabled();
|
|
5539
5566
|
const maxCacheSize = useMaxMediaCacheSize(logLevel);
|
|
5540
|
-
const effectChainState =
|
|
5567
|
+
const effectChainState = Internals21.useEffectChainState();
|
|
5541
5568
|
const [error, setError] = useState5(null);
|
|
5542
5569
|
if (error) {
|
|
5543
5570
|
throw error;
|
|
@@ -5602,7 +5629,7 @@ var VideoForRendering = ({
|
|
|
5602
5629
|
return;
|
|
5603
5630
|
}
|
|
5604
5631
|
if (window.remotion_isMainTab) {
|
|
5605
|
-
|
|
5632
|
+
Internals21.Log.warn({ logLevel, tag: "@remotion/media" }, fallbackMessage);
|
|
5606
5633
|
}
|
|
5607
5634
|
setReplaceWithOffthreadVideo({
|
|
5608
5635
|
durationInSeconds: mediaDurationInSeconds
|
|
@@ -5646,7 +5673,7 @@ var VideoForRendering = ({
|
|
|
5646
5673
|
context.canvas.style.aspectRatio = `${context.canvas.width} / ${context.canvas.height}`;
|
|
5647
5674
|
context.drawImage(imageBitmap, 0, 0);
|
|
5648
5675
|
if (effects.length > 0) {
|
|
5649
|
-
const completed = await
|
|
5676
|
+
const completed = await Internals21.runEffectChain({
|
|
5650
5677
|
state: effectChainState.get(imageBitmap.width, imageBitmap.height),
|
|
5651
5678
|
source: context.canvas,
|
|
5652
5679
|
effects,
|
|
@@ -5677,12 +5704,12 @@ var VideoForRendering = ({
|
|
|
5677
5704
|
frame,
|
|
5678
5705
|
startsAt
|
|
5679
5706
|
});
|
|
5680
|
-
const volume =
|
|
5707
|
+
const volume = Internals21.evaluateVolume({
|
|
5681
5708
|
volume: volumeProp,
|
|
5682
5709
|
frame: volumePropsFrame,
|
|
5683
5710
|
mediaVolume: 1
|
|
5684
5711
|
});
|
|
5685
|
-
|
|
5712
|
+
Internals21.warnAboutTooHighVolume(volume);
|
|
5686
5713
|
if (audio && volume > 0) {
|
|
5687
5714
|
applyVolume(audio.data, volume);
|
|
5688
5715
|
registerRenderAsset({
|
|
@@ -5743,7 +5770,7 @@ var VideoForRendering = ({
|
|
|
5743
5770
|
]);
|
|
5744
5771
|
warnAboutObjectFitInStyleOrClassName({ style, className, logLevel });
|
|
5745
5772
|
const classNameValue = useMemo5(() => {
|
|
5746
|
-
return [
|
|
5773
|
+
return [Internals21.OBJECTFIT_CONTAIN_CLASS_NAME, className].filter(Internals21.truthy).join(" ");
|
|
5747
5774
|
}, [className]);
|
|
5748
5775
|
const styleWithObjectFit = useMemo5(() => {
|
|
5749
5776
|
return {
|
|
@@ -5752,7 +5779,7 @@ var VideoForRendering = ({
|
|
|
5752
5779
|
};
|
|
5753
5780
|
}, [objectFitProp, style]);
|
|
5754
5781
|
if (replaceWithOffthreadVideo) {
|
|
5755
|
-
const fallback = /* @__PURE__ */ jsx5(
|
|
5782
|
+
const fallback = /* @__PURE__ */ jsx5(Internals21.InnerOffthreadVideo, {
|
|
5756
5783
|
...props,
|
|
5757
5784
|
src,
|
|
5758
5785
|
playbackRate: playbackRate ?? 1,
|
|
@@ -5794,7 +5821,7 @@ var VideoForRendering = ({
|
|
|
5794
5821
|
}
|
|
5795
5822
|
return /* @__PURE__ */ jsx5(Loop, {
|
|
5796
5823
|
layout: "none",
|
|
5797
|
-
durationInFrames:
|
|
5824
|
+
durationInFrames: Internals21.calculateMediaDuration({
|
|
5798
5825
|
trimAfter: trimAfterValue,
|
|
5799
5826
|
mediaDurationInFrames: replaceWithOffthreadVideo.durationInSeconds * fps,
|
|
5800
5827
|
playbackRate,
|
|
@@ -5818,9 +5845,15 @@ var VideoForRendering = ({
|
|
|
5818
5845
|
|
|
5819
5846
|
// src/video/video.tsx
|
|
5820
5847
|
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
5821
|
-
var { validateMediaTrimProps, resolveTrimProps, validateMediaProps: validateMediaProps2 } =
|
|
5848
|
+
var { validateMediaTrimProps, resolveTrimProps, validateMediaProps: validateMediaProps2 } = Internals22;
|
|
5822
5849
|
var videoSchema = {
|
|
5823
|
-
|
|
5850
|
+
src: {
|
|
5851
|
+
type: "asset",
|
|
5852
|
+
default: undefined,
|
|
5853
|
+
description: "Source",
|
|
5854
|
+
keyframable: false
|
|
5855
|
+
},
|
|
5856
|
+
...Internals22.baseSchema,
|
|
5824
5857
|
volume: {
|
|
5825
5858
|
type: "number",
|
|
5826
5859
|
min: 0,
|
|
@@ -5839,8 +5872,9 @@ var videoSchema = {
|
|
|
5839
5872
|
hiddenFromList: false,
|
|
5840
5873
|
keyframable: false
|
|
5841
5874
|
},
|
|
5875
|
+
muted: { type: "boolean", default: false, description: "Muted" },
|
|
5842
5876
|
loop: { type: "boolean", default: false, description: "Loop" },
|
|
5843
|
-
...
|
|
5877
|
+
...Internals22.transformSchema
|
|
5844
5878
|
};
|
|
5845
5879
|
var InnerVideo = ({
|
|
5846
5880
|
src,
|
|
@@ -5992,12 +6026,19 @@ var VideoInner = ({
|
|
|
5992
6026
|
hidden,
|
|
5993
6027
|
...props
|
|
5994
6028
|
}) => {
|
|
5995
|
-
const fallbackLogLevel =
|
|
5996
|
-
const [mediaVolume] =
|
|
5997
|
-
const mediaStartsAt =
|
|
6029
|
+
const fallbackLogLevel = Internals22.useLogLevel();
|
|
6030
|
+
const [mediaVolume] = Internals22.useMediaVolumeState();
|
|
6031
|
+
const mediaStartsAt = Internals22.useMediaStartsAt();
|
|
5998
6032
|
const videoConfig = useVideoConfig5();
|
|
5999
6033
|
const sequenceDurationInFrames = Math.min(durationInFrames ?? Infinity, Math.max(0, videoConfig.durationInFrames - (from ?? 0)));
|
|
6000
|
-
const
|
|
6034
|
+
const videoSequenceDuration = getVideoSequenceDuration({
|
|
6035
|
+
durationInFrames,
|
|
6036
|
+
loop: loop ?? false,
|
|
6037
|
+
playbackRate: playbackRate ?? 1,
|
|
6038
|
+
trimAfter,
|
|
6039
|
+
trimBefore
|
|
6040
|
+
});
|
|
6041
|
+
const basicInfo = Internals22.useBasicMediaInTimeline({
|
|
6001
6042
|
src,
|
|
6002
6043
|
volume,
|
|
6003
6044
|
playbackRate: playbackRate ?? 1,
|
|
@@ -6032,11 +6073,11 @@ var VideoInner = ({
|
|
|
6032
6073
|
type: "video",
|
|
6033
6074
|
data: basicInfo
|
|
6034
6075
|
}), [basicInfo]);
|
|
6035
|
-
const memoizedEffects =
|
|
6076
|
+
const memoizedEffects = Internals22.useMemoizedEffects({
|
|
6036
6077
|
effects: effects ?? [],
|
|
6037
6078
|
overrideId: controls?.overrideId ?? null
|
|
6038
6079
|
});
|
|
6039
|
-
const memoizedEffectDefinitions =
|
|
6080
|
+
const memoizedEffectDefinitions = Internals22.useMemoizedEffectDefinitions(effects ?? []);
|
|
6040
6081
|
const refForOutline = React6.useRef(null);
|
|
6041
6082
|
if (sequenceDurationInFrames === 0) {
|
|
6042
6083
|
return null;
|
|
@@ -6044,7 +6085,7 @@ var VideoInner = ({
|
|
|
6044
6085
|
return /* @__PURE__ */ jsx6(Sequence2, {
|
|
6045
6086
|
layout: "none",
|
|
6046
6087
|
from: from ?? 0,
|
|
6047
|
-
durationInFrames:
|
|
6088
|
+
durationInFrames: videoSequenceDuration,
|
|
6048
6089
|
freeze,
|
|
6049
6090
|
_remotionInternalStack: stack,
|
|
6050
6091
|
_remotionInternalIsMedia: isMedia,
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const getVideoSequenceDuration: ({ durationInFrames, loop, playbackRate, trimAfter, trimBefore, }: {
|
|
2
|
+
readonly durationInFrames: number | undefined;
|
|
3
|
+
readonly loop: boolean;
|
|
4
|
+
readonly playbackRate: number;
|
|
5
|
+
readonly trimAfter: number | undefined;
|
|
6
|
+
readonly trimBefore: number | undefined;
|
|
7
|
+
}) => number | undefined;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@remotion/media",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.493",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"module": "dist/esm/index.mjs",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"mediabunny": "1.50.8",
|
|
26
|
-
"remotion": "4.0.
|
|
26
|
+
"remotion": "4.0.493",
|
|
27
27
|
"zod": "4.3.6"
|
|
28
28
|
},
|
|
29
29
|
"peerDependencies": {
|
|
@@ -31,8 +31,8 @@
|
|
|
31
31
|
"react-dom": ">=16.8.0"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@remotion/eslint-config-internal": "4.0.
|
|
35
|
-
"@remotion/player": "4.0.
|
|
34
|
+
"@remotion/eslint-config-internal": "4.0.493",
|
|
35
|
+
"@remotion/player": "4.0.493",
|
|
36
36
|
"@vitest/browser-webdriverio": "4.0.9",
|
|
37
37
|
"eslint": "9.19.0",
|
|
38
38
|
"react": "19.2.3",
|