@remotion/media 4.0.352 → 4.0.353
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/props.d.ts +1 -2
- package/dist/audio-extraction/audio-iterator.d.ts +1 -1
- package/dist/audio-extraction/audio-iterator.js +2 -2
- package/dist/audio-extraction/audio-manager.d.ts +1 -1
- package/dist/audio-extraction/extract-audio.d.ts +1 -1
- package/dist/caches.d.ts +6 -6
- package/dist/caches.js +5 -6
- package/dist/convert-audiodata/resample-audiodata.js +3 -2
- package/dist/esm/index.mjs +45 -71
- package/dist/video-extraction/extract-frame-via-broadcast-channel.d.ts +1 -1
- package/dist/video-extraction/extract-frame.d.ts +1 -1
- package/dist/video-extraction/get-frames-since-keyframe.js +1 -1
- package/dist/video-extraction/keyframe-bank.d.ts +1 -1
- package/dist/video-extraction/keyframe-bank.js +7 -7
- package/dist/video-extraction/keyframe-manager.d.ts +1 -1
- package/dist/video-extraction/keyframe-manager.js +6 -6
- package/package.json +3 -3
- package/dist/audio-for-rendering.d.ts +0 -3
- package/dist/audio-for-rendering.js +0 -94
- package/dist/audio.d.ts +0 -3
- package/dist/audio.js +0 -60
- package/dist/audiodata-to-array.d.ts +0 -0
- package/dist/audiodata-to-array.js +0 -1
- package/dist/convert-audiodata/data-types.d.ts +0 -1
- package/dist/convert-audiodata/data-types.js +0 -22
- package/dist/convert-audiodata/is-planar-format.d.ts +0 -1
- package/dist/convert-audiodata/is-planar-format.js +0 -3
- package/dist/convert-audiodata/log-audiodata.d.ts +0 -1
- package/dist/convert-audiodata/log-audiodata.js +0 -8
- package/dist/convert-audiodata/trim-audiodata.d.ts +0 -0
- package/dist/convert-audiodata/trim-audiodata.js +0 -1
- package/dist/deserialized-audiodata.d.ts +0 -15
- package/dist/deserialized-audiodata.js +0 -26
- package/dist/extract-audio.d.ts +0 -7
- package/dist/extract-audio.js +0 -98
- package/dist/extract-frame-via-broadcast-channel.d.ts +0 -15
- package/dist/extract-frame-via-broadcast-channel.js +0 -104
- package/dist/extract-frame.d.ts +0 -27
- package/dist/extract-frame.js +0 -21
- package/dist/extrct-audio.d.ts +0 -7
- package/dist/extrct-audio.js +0 -94
- package/dist/get-frames-since-keyframe.d.ts +0 -22
- package/dist/get-frames-since-keyframe.js +0 -41
- package/dist/keyframe-bank.d.ts +0 -25
- package/dist/keyframe-bank.js +0 -120
- package/dist/keyframe-manager.d.ts +0 -23
- package/dist/keyframe-manager.js +0 -170
- package/dist/new-video-for-rendering.d.ts +0 -3
- package/dist/new-video-for-rendering.js +0 -108
- package/dist/new-video.d.ts +0 -3
- package/dist/new-video.js +0 -37
- package/dist/props.d.ts +0 -29
- package/dist/props.js +0 -1
- package/dist/remember-actual-matroska-timestamps.d.ts +0 -4
- package/dist/remember-actual-matroska-timestamps.js +0 -19
- package/dist/serialize-videoframe.d.ts +0 -0
- package/dist/serialize-videoframe.js +0 -1
- package/dist/video/media-player.d.ts +0 -64
- package/dist/video/media-player.js +0 -501
- package/dist/video/new-video-for-preview.d.ts +0 -10
- package/dist/video/new-video-for-preview.js +0 -114
- package/dist/video-extraction/media-player.d.ts +0 -64
- package/dist/video-extraction/media-player.js +0 -501
- package/dist/video-extraction/new-video-for-preview.d.ts +0 -10
- package/dist/video-extraction/new-video-for-preview.js +0 -114
- package/dist/video-for-rendering.d.ts +0 -3
- package/dist/video-for-rendering.js +0 -108
- package/dist/video.d.ts +0 -3
- package/dist/video.js +0 -37
|
@@ -1,108 +0,0 @@
|
|
|
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
DELETED
package/dist/video.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
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
|
-
};
|