Skip to content

🎥 Make videos programmatically with React

ability to disable video

Jonny Burger78a2b6535d38
diff --git a/packages/media/src/extract-frame-via-broadcast-channel.ts b/packages/media/src/extract-frame-via-broadcast-channel.ts
index 19e1e53d12..11bf5d204b 100644
--- a/packages/media/src/extract-frame-via-broadcast-channel.ts
+++ b/packages/media/src/extract-frame-via-broadcast-channel.ts
@@ -78,7 +78,7 @@ if (window.remotion_broadcastChannel && window.remotion_isMainTab) {
);
}
-export const extractFrameViaBroadcastChannel = async ({
+export const extractFrameViaBroadcastChannel = ({
src,
timeInSeconds,
logLevel,
@@ -101,7 +101,7 @@ export const extractFrameViaBroadcastChannel = async ({
audio: PcmS16AudioData | null;
}> => {
if (isClientSideRendering || window.remotion_isMainTab) {
- const {frame, audio} = await extractFrameAndAudio({
+ return extractFrameAndAudio({
logLevel,
src,
timeInSeconds,
@@ -110,15 +110,6 @@ export const extractFrameViaBroadcastChannel = async ({
includeVideo,
volume,
});
-
- return {
- frame,
- audio,
- };
- }
-
- if (typeof window.remotion_isMainTab === 'undefined') {
- throw new Error('This should be defined');
}
const requestId = crypto.randomUUID();
diff --git a/packages/media/src/video/video-for-rendering.tsx b/packages/media/src/video/video-for-rendering.tsx
index 54c3f6f48e..cd34776722 100644
--- a/packages/media/src/video/video-for-rendering.tsx
+++ b/packages/media/src/video/video-for-rendering.tsx
@@ -97,19 +97,19 @@ export const VideoForRendering: React.FC<VideoProps> = ({
durationInSeconds,
logLevel: logLevel ?? 'info',
includeAudio: shouldRenderAudio,
- includeVideo: true,
+ includeVideo: window.remotion_videoEnabled,
isClientSideRendering: environment.isClientSideRendering,
volume,
})
.then(({frame: imageBitmap, audio}) => {
- if (!imageBitmap) {
+ if (imageBitmap) {
+ onVideoFrame?.(imageBitmap);
+ canvasRef.current?.getContext('2d')?.drawImage(imageBitmap, 0, 0);
+ imageBitmap.close();
+ } else if (window.remotion_videoEnabled) {
cancelRender(new Error('No video frame found'));
}
- onVideoFrame?.(imageBitmap);
- canvasRef.current?.getContext('2d')?.drawImage(imageBitmap, 0, 0);
- imageBitmap.close();
-
if (audio) {
registerRenderAsset({
type: 'inline-audio',