@remotion/media 4.0.378 → 4.0.380
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/audio/audio-for-preview.js +1 -1
- package/dist/audio/audio-preview-iterator.js +27 -4
- package/dist/audio/props.d.ts +1 -0
- package/dist/audio-extraction/extract-audio.d.ts +1 -1
- package/dist/audio-extraction/extract-audio.js +3 -0
- package/dist/audio-for-rendering.d.ts +3 -0
- package/dist/audio-for-rendering.js +94 -0
- package/dist/audio.d.ts +3 -0
- package/dist/audio.js +60 -0
- package/dist/audiodata-to-array.d.ts +0 -0
- package/dist/audiodata-to-array.js +1 -0
- package/dist/convert-audiodata/data-types.d.ts +1 -0
- package/dist/convert-audiodata/data-types.js +22 -0
- package/dist/convert-audiodata/is-planar-format.d.ts +1 -0
- package/dist/convert-audiodata/is-planar-format.js +3 -0
- package/dist/convert-audiodata/log-audiodata.d.ts +1 -0
- package/dist/convert-audiodata/log-audiodata.js +8 -0
- package/dist/convert-audiodata/trim-audiodata.d.ts +0 -0
- package/dist/convert-audiodata/trim-audiodata.js +1 -0
- package/dist/deserialized-audiodata.d.ts +15 -0
- package/dist/deserialized-audiodata.js +26 -0
- package/dist/esm/index.mjs +56 -8
- package/dist/extract-audio.d.ts +7 -0
- package/dist/extract-audio.js +98 -0
- package/dist/extract-frame-and-audio.js +9 -0
- package/dist/extract-frame-via-broadcast-channel.d.ts +15 -0
- package/dist/extract-frame-via-broadcast-channel.js +104 -0
- package/dist/extract-frame.d.ts +27 -0
- package/dist/extract-frame.js +21 -0
- package/dist/extrct-audio.d.ts +7 -0
- package/dist/extrct-audio.js +94 -0
- package/dist/get-frames-since-keyframe.d.ts +22 -0
- package/dist/get-frames-since-keyframe.js +41 -0
- package/dist/keyframe-bank.d.ts +25 -0
- package/dist/keyframe-bank.js +120 -0
- package/dist/keyframe-manager.d.ts +23 -0
- package/dist/keyframe-manager.js +170 -0
- package/dist/log.d.ts +10 -0
- package/dist/log.js +33 -0
- package/dist/new-video-for-rendering.d.ts +3 -0
- package/dist/new-video-for-rendering.js +108 -0
- package/dist/new-video.d.ts +3 -0
- package/dist/new-video.js +37 -0
- package/dist/props.d.ts +29 -0
- package/dist/props.js +1 -0
- package/dist/remember-actual-matroska-timestamps.d.ts +4 -0
- package/dist/remember-actual-matroska-timestamps.js +19 -0
- package/dist/serialize-videoframe.d.ts +0 -0
- package/dist/serialize-videoframe.js +1 -0
- package/dist/video/media-player.d.ts +62 -0
- package/dist/video/media-player.js +361 -0
- package/dist/video/new-video-for-preview.d.ts +10 -0
- package/dist/video/new-video-for-preview.js +108 -0
- package/dist/video/props.d.ts +1 -0
- package/dist/video/timeout-utils.d.ts +2 -0
- package/dist/video/timeout-utils.js +18 -0
- package/dist/video/video-for-rendering.js +1 -1
- package/dist/video-extraction/extract-frame.d.ts +2 -0
- package/dist/video-extraction/extract-frame.js +3 -0
- package/dist/video-extraction/get-frames-since-keyframe.d.ts +2 -2
- package/dist/video-extraction/get-frames-since-keyframe.js +13 -3
- package/dist/video-extraction/media-player.d.ts +64 -0
- package/dist/video-extraction/media-player.js +501 -0
- package/dist/video-extraction/new-video-for-preview.d.ts +10 -0
- package/dist/video-extraction/new-video-for-preview.js +114 -0
- package/dist/video-for-rendering.d.ts +3 -0
- package/dist/video-for-rendering.js +108 -0
- package/dist/video.d.ts +3 -0
- package/dist/video.js +37 -0
- package/package.json +3 -3
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useContext, useLayoutEffect, useMemo, useRef, useState, } from 'react';
|
|
3
|
+
import { cancelRender, Internals, useCurrentFrame, useDelayRender, useRemotionEnvironment, } from 'remotion';
|
|
4
|
+
import { extractFrameViaBroadcastChannel } from './extract-frame-via-broadcast-channel';
|
|
5
|
+
export const VideoForRendering = ({ volume: volumeProp, playbackRate, src, muted, loopVolumeCurveBehavior, delayRenderRetries, delayRenderTimeoutInMilliseconds,
|
|
6
|
+
// call when a frame of the video, i.e. frame drawn on canvas
|
|
7
|
+
onVideoFrame, logLevel = window.remotion_logLevel, }) => {
|
|
8
|
+
const absoluteFrame = Internals.useTimelinePosition();
|
|
9
|
+
const videoConfig = Internals.useUnsafeVideoConfig();
|
|
10
|
+
const canvasRef = useRef(null);
|
|
11
|
+
const { registerRenderAsset, unregisterRenderAsset } = useContext(Internals.RenderAssetManager);
|
|
12
|
+
const frame = useCurrentFrame();
|
|
13
|
+
const volumePropsFrame = Internals.useFrameForVolumeProp(loopVolumeCurveBehavior ?? 'repeat');
|
|
14
|
+
const environment = useRemotionEnvironment();
|
|
15
|
+
const [id] = useState(() => `${Math.random()}`.replace('0.', ''));
|
|
16
|
+
if (!videoConfig) {
|
|
17
|
+
throw new Error('No video config found');
|
|
18
|
+
}
|
|
19
|
+
if (!src) {
|
|
20
|
+
throw new TypeError('No `src` was passed to <Video>.');
|
|
21
|
+
}
|
|
22
|
+
const volume = Internals.evaluateVolume({
|
|
23
|
+
volume: volumeProp,
|
|
24
|
+
frame: volumePropsFrame,
|
|
25
|
+
mediaVolume: 1,
|
|
26
|
+
});
|
|
27
|
+
Internals.warnAboutTooHighVolume(volume);
|
|
28
|
+
const shouldRenderAudio = useMemo(() => {
|
|
29
|
+
if (!window.remotion_audioEnabled) {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
if (muted) {
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
if (volume <= 0) {
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
return true;
|
|
39
|
+
}, [muted, volume]);
|
|
40
|
+
const { fps } = videoConfig;
|
|
41
|
+
const { delayRender, continueRender } = useDelayRender();
|
|
42
|
+
useLayoutEffect(() => {
|
|
43
|
+
if (!canvasRef.current) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
const actualFps = playbackRate ? fps / playbackRate : fps;
|
|
47
|
+
const timestamp = frame / actualFps;
|
|
48
|
+
const durationInSeconds = 1 / actualFps;
|
|
49
|
+
const newHandle = delayRender(`Extracting frame number ${frame}`, {
|
|
50
|
+
retries: delayRenderRetries ?? undefined,
|
|
51
|
+
timeoutInMilliseconds: delayRenderTimeoutInMilliseconds ?? undefined,
|
|
52
|
+
});
|
|
53
|
+
extractFrameViaBroadcastChannel({
|
|
54
|
+
src,
|
|
55
|
+
timeInSeconds: timestamp,
|
|
56
|
+
durationInSeconds,
|
|
57
|
+
logLevel: logLevel ?? 'info',
|
|
58
|
+
shouldRenderAudio,
|
|
59
|
+
isClientSideRendering: environment.isClientSideRendering,
|
|
60
|
+
})
|
|
61
|
+
.then(({ frame: imageBitmap, audio }) => {
|
|
62
|
+
if (!imageBitmap) {
|
|
63
|
+
cancelRender(new Error('No video frame found'));
|
|
64
|
+
}
|
|
65
|
+
onVideoFrame?.(imageBitmap);
|
|
66
|
+
canvasRef.current?.getContext('2d')?.drawImage(imageBitmap, 0, 0);
|
|
67
|
+
imageBitmap.close();
|
|
68
|
+
if (audio) {
|
|
69
|
+
registerRenderAsset({
|
|
70
|
+
type: 'inline-audio',
|
|
71
|
+
id,
|
|
72
|
+
audio: Array.from(audio.data),
|
|
73
|
+
sampleRate: audio.sampleRate,
|
|
74
|
+
numberOfChannels: audio.numberOfChannels,
|
|
75
|
+
frame: absoluteFrame,
|
|
76
|
+
timestamp: audio.timestamp,
|
|
77
|
+
duration: (audio.numberOfFrames / audio.sampleRate) * 1000000,
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
continueRender(newHandle);
|
|
81
|
+
})
|
|
82
|
+
.catch((error) => {
|
|
83
|
+
cancelRender(error);
|
|
84
|
+
});
|
|
85
|
+
return () => {
|
|
86
|
+
continueRender(newHandle);
|
|
87
|
+
unregisterRenderAsset(id);
|
|
88
|
+
};
|
|
89
|
+
}, [
|
|
90
|
+
absoluteFrame,
|
|
91
|
+
continueRender,
|
|
92
|
+
delayRender,
|
|
93
|
+
delayRenderRetries,
|
|
94
|
+
delayRenderTimeoutInMilliseconds,
|
|
95
|
+
environment.isClientSideRendering,
|
|
96
|
+
fps,
|
|
97
|
+
frame,
|
|
98
|
+
id,
|
|
99
|
+
logLevel,
|
|
100
|
+
onVideoFrame,
|
|
101
|
+
playbackRate,
|
|
102
|
+
registerRenderAsset,
|
|
103
|
+
shouldRenderAudio,
|
|
104
|
+
src,
|
|
105
|
+
unregisterRenderAsset,
|
|
106
|
+
]);
|
|
107
|
+
return (_jsx("canvas", { ref: canvasRef, width: videoConfig.width, height: videoConfig.height }));
|
|
108
|
+
};
|
package/dist/video.d.ts
ADDED
package/dist/video.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useCallback } from 'react';
|
|
3
|
+
import { Internals, Sequence, useRemotionEnvironment } from 'remotion';
|
|
4
|
+
import { VideoForRendering } from './video-for-rendering';
|
|
5
|
+
const { validateMediaTrimProps, resolveTrimProps, validateMediaProps, VideoForPreview, } = Internals;
|
|
6
|
+
export const Video = (props) => {
|
|
7
|
+
// Should only destruct `trimBefore` and `trimAfter` from props,
|
|
8
|
+
// rest gets drilled down
|
|
9
|
+
const { trimBefore, trimAfter, name, pauseWhenBuffering, stack, showInTimeline, ...otherProps } = props;
|
|
10
|
+
const environment = useRemotionEnvironment();
|
|
11
|
+
const onDuration = useCallback(() => undefined, []);
|
|
12
|
+
if (typeof props.src !== 'string') {
|
|
13
|
+
throw new TypeError(`The \`<Video>\` tag requires a string for \`src\`, but got ${JSON.stringify(props.src)} instead.`);
|
|
14
|
+
}
|
|
15
|
+
validateMediaTrimProps({
|
|
16
|
+
startFrom: undefined,
|
|
17
|
+
endAt: undefined,
|
|
18
|
+
trimBefore,
|
|
19
|
+
trimAfter,
|
|
20
|
+
});
|
|
21
|
+
const { trimBeforeValue, trimAfterValue } = resolveTrimProps({
|
|
22
|
+
startFrom: undefined,
|
|
23
|
+
endAt: undefined,
|
|
24
|
+
trimBefore,
|
|
25
|
+
trimAfter,
|
|
26
|
+
});
|
|
27
|
+
if (typeof trimBeforeValue !== 'undefined' ||
|
|
28
|
+
typeof trimAfterValue !== 'undefined') {
|
|
29
|
+
return (_jsx(Sequence, { layout: "none", from: 0 - (trimBeforeValue ?? 0), showInTimeline: false, durationInFrames: trimAfterValue, name: name, children: _jsx(Video, { pauseWhenBuffering: pauseWhenBuffering ?? false, ...otherProps }) }));
|
|
30
|
+
}
|
|
31
|
+
validateMediaProps(props, 'Video');
|
|
32
|
+
if (environment.isRendering) {
|
|
33
|
+
return _jsx(VideoForRendering, { ...otherProps });
|
|
34
|
+
}
|
|
35
|
+
const { onAutoPlayError, onVideoFrame, crossOrigin, delayRenderRetries, delayRenderTimeoutInMilliseconds, ...propsForPreview } = otherProps;
|
|
36
|
+
return (_jsx(VideoForPreview, { _remotionInternalStack: stack ?? null, _remotionInternalNativeLoopPassed: false, onDuration: onDuration, onlyWarnForMediaSeekingError: true, pauseWhenBuffering: pauseWhenBuffering ?? false, showInTimeline: showInTimeline ?? true, onAutoPlayError: onAutoPlayError ?? undefined, onVideoFrame: onVideoFrame ?? null, crossOrigin: crossOrigin, ...propsForPreview }));
|
|
37
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@remotion/media",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.380",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"module": "dist/esm/index.mjs",
|
|
@@ -22,14 +22,14 @@
|
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"mediabunny": "1.24.5",
|
|
25
|
-
"remotion": "4.0.
|
|
25
|
+
"remotion": "4.0.380"
|
|
26
26
|
},
|
|
27
27
|
"peerDependencies": {
|
|
28
28
|
"react": ">=16.8.0",
|
|
29
29
|
"react-dom": ">=16.8.0"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@remotion/eslint-config-internal": "4.0.
|
|
32
|
+
"@remotion/eslint-config-internal": "4.0.380",
|
|
33
33
|
"@vitest/browser-webdriverio": "4.0.7",
|
|
34
34
|
"eslint": "9.19.0",
|
|
35
35
|
"react": "19.0.0",
|