🎥 Make videos programmatically with React
fix: correct web renderer types and retry payload handling
romeoscript09911ec3cbd0
diff --git a/packages/studio/src/components/Modals.tsx b/packages/studio/src/components/Modals.tsxindex df739db503..731298e0b9 100644--- a/packages/studio/src/components/Modals.tsx+++ b/packages/studio/src/components/Modals.tsx@@ -40,16 +40,7 @@ export const Modals: React.FC<{)}{modalContextType && modalContextType.type === 'web-render' && (- <WebRenderModalWithLoader- type="web-render"- initialFrame={modalContextType.initialFrame}- compositionId={modalContextType.compositionId}- defaultProps={modalContextType.defaultProps}- inFrameMark={modalContextType.inFrameMark}- outFrameMark={modalContextType.outFrameMark}- initialLogLevel={modalContextType.initialLogLevel}- initialLicenseKey={modalContextType.initialLicenseKey}- />+ <WebRenderModalWithLoader {...modalContextType} />)}{modalContextType &&canRender &&diff --git a/packages/studio/src/components/RenderButton.tsx b/packages/studio/src/components/RenderButton.tsxindex e8d6131f65..e9b92430c0 100644--- a/packages/studio/src/components/RenderButton.tsx+++ b/packages/studio/src/components/RenderButton.tsx@@ -7,6 +7,7 @@ import type {OpenGlRenderer,X264Preset,} from '@remotion/renderer';+import type {RenderStillOnWebImageFormat} from '@remotion/web-renderer';import type {SVGProps} from 'react';import React, {useCallback, useContext, useMemo, useRef, useState} from 'react';import ReactDOM from 'react-dom';@@ -282,6 +283,21 @@ export const RenderButton: React.FC<{readonly readOnlyStudio: boolean}> = ({outFrameMark: outFrame,initialLogLevel: defaults.logLevel as LogLevel,initialLicenseKey: defaults.publicLicenseKey,+ initialStillImageFormat:+ defaults.stillImageFormat as RenderStillOnWebImageFormat,+ initialScale: defaults.scale,+ initialDelayRenderTimeout: defaults.delayRenderTimeout,+ initialDefaultOutName: null,+ initialContainer: null,+ initialVideoCodec: null,+ initialAudioCodec: null,+ initialAudioBitrate: null,+ initialVideoBitrate: null,+ initialHardwareAcceleration: null,+ initialKeyframeIntervalInSeconds: null,+ initialTransparent: null,+ initialMuted: null,+ initialMediaCacheSizeInBytes: defaults.mediaCacheSizeInBytes,});}, [video, setSelectedModal, getCurrentFrame, props, inFrame, outFrame]);diff --git a/packages/studio/src/components/RenderModal/WebRenderModal.tsx b/packages/studio/src/components/RenderModal/WebRenderModal.tsxindex 66e1b03aeb..6ba239897f 100644--- a/packages/studio/src/components/RenderModal/WebRenderModal.tsx+++ b/packages/studio/src/components/RenderModal/WebRenderModal.tsx@@ -1,10 +1,4 @@-import type {- AudioCodec,- Codec,- LogLevel,- StillImageFormat,- VideoImageFormat,-} from '@remotion/renderer';+import type {LogLevel} from '@remotion/renderer';import type {HardwareAccelerationOption} from '@remotion/renderer/client';import {getDefaultOutLocation} from '@remotion/studio-shared';import type {@@ -73,16 +67,15 @@ type WebRenderModalProps = {readonly defaultProps: Record<string, unknown>;readonly inFrameMark: number | null;readonly outFrameMark: number | null;- readonly initialVideoImageFormat: VideoImageFormat | null;- readonly initialStillImageFormat: StillImageFormat;+ readonly initialStillImageFormat: RenderStillOnWebImageFormat;readonly initialScale: number;readonly initialDelayRenderTimeout: number;readonly initialDefaultOutName: string | null;- readonly initialContainer: string | null;- readonly initialVideoCodec: Codec | null;- readonly initialAudioCodec: AudioCodec | null;- readonly initialAudioBitrate: string | null;- readonly initialVideoBitrate: string | null;+ readonly initialContainer: WebRendererContainer | null;+ readonly initialVideoCodec: WebRendererVideoCodec | null;+ readonly initialAudioCodec: WebRendererAudioCodec | null;+ readonly initialAudioBitrate: WebRendererQuality | null;+ readonly initialVideoBitrate: WebRendererQuality | null;readonly initialHardwareAcceleration: HardwareAccelerationOption | null;readonly initialKeyframeIntervalInSeconds: number | null;readonly initialTransparent: boolean | null;@@ -219,7 +212,7 @@ const WebRenderModal: React.FC<WebRenderModalProps> = ({);const [tab, setTab] = useState<TabType>('general');const [imageFormat, setImageFormat] = useState<RenderStillOnWebImageFormat>(- () => (initialStillImageFormat as RenderStillOnWebImageFormat) ?? 'png',+ () => initialStillImageFormat ?? 'png',);const [frame, setFrame] = useState(() => initialFrame);const [logLevel, setLogLevel] = useState(() => initialLogLevel);@@ -229,24 +222,24 @@ const WebRenderModal: React.FC<WebRenderModalProps> = ({);const [mediaCacheSizeInBytes, setMediaCacheSizeInBytes] = useState<number | null- >(initialMediaCacheSizeInBytes ?? null);+ >(initialMediaCacheSizeInBytes);const [saving, setSaving] = useState(false);// Video-specific stateconst [codec, setCodec] = useState<WebRendererVideoCodec>(- (initialVideoCodec as WebRendererVideoCodec) ?? 'h264',+ initialVideoCodec ?? 'h264',);const [container, setContainer] = useState<WebRendererContainer>(- (initialContainer as WebRendererContainer) ?? 'mp4',+ initialContainer ?? 'mp4',);const [audioCodec, setAudioCodec] = useState<WebRendererAudioCodec>(- (initialAudioCodec as WebRendererAudioCodec) ?? 'aac',+ initialAudioCodec ?? 'aac',);const [audioBitrate, setAudioBitrate] = useState<WebRendererQuality>(- (initialAudioBitrate as WebRendererQuality) ?? 'medium',+ initialAudioBitrate ?? 'medium',);const [videoBitrate, setVideoBitrate] = useState<WebRendererQuality>(- (initialVideoBitrate as WebRendererQuality) ?? 'high',+ initialVideoBitrate ?? 'high',);const [hardwareAcceleration, setHardwareAcceleration] = useState<'no-preference' | 'prefer-hardware' | 'prefer-software'@@ -260,14 +253,10 @@ const WebRenderModal: React.FC<WebRenderModalProps> = ({initialKeyframeIntervalInSeconds ?? 5,);const [startFrame, setStartFrame] = useState<number | null>(- () => inFrameMark ?? null,- );- const [endFrame, setEndFrame] = useState<number | null>(- () => outFrameMark ?? null,- );- const [transparent, setTransparent] = useState(- initialTransparent ?? false,+ () => inFrameMark,);+ const [endFrame, setEndFrame] = useState<number | null>(() => outFrameMark);+ const [transparent, setTransparent] = useState(initialTransparent ?? false);const [muted, setMuted] = useState(initialMuted ?? false);const [scale, setScale] = useState(initialScale ?? 1);diff --git a/packages/studio/src/components/RenderQueue/client-side-render-types.ts b/packages/studio/src/components/RenderQueue/client-side-render-types.tsindex 739789f1dc..643f3756b5 100644--- a/packages/studio/src/components/RenderQueue/client-side-render-types.ts+++ b/packages/studio/src/components/RenderQueue/client-side-render-types.ts@@ -1,4 +1,10 @@-import type {RenderStillOnWebImageFormat} from '@remotion/web-renderer';+import type {+ RenderStillOnWebImageFormat,+ WebRendererAudioCodec,+ WebRendererContainer,+ WebRendererQuality,+ WebRendererVideoCodec,+} from '@remotion/web-renderer';import type {LogLevel} from 'remotion';export type ClientRenderJobProgress = {@@ -46,13 +52,13 @@ export type ClientStillRenderJob = ClientRenderJobBase & {export type ClientVideoRenderJob = ClientRenderJobBase & {type: 'client-video';- container: string;- videoCodec: string;- audioCodec: string;+ container: WebRendererContainer;+ videoCodec: WebRendererVideoCodec;+ audioCodec: WebRendererAudioCodec;startFrame: number;endFrame: number;- audioBitrate: string;- videoBitrate: string;+ audioBitrate: WebRendererQuality;+ videoBitrate: WebRendererQuality;hardwareAcceleration: string;keyframeIntervalInSeconds: number;transparent: boolean;diff --git a/packages/studio/src/helpers/retry-payload.ts b/packages/studio/src/helpers/retry-payload.tsindex 851094d4bb..1b5938e28d 100644--- a/packages/studio/src/helpers/retry-payload.ts+++ b/packages/studio/src/helpers/retry-payload.ts@@ -3,7 +3,6 @@ import type {Codec,ColorSpace,PixelFormat,- VideoImageFormat,X264Preset,} from '@remotion/renderer';import type {HardwareAccelerationOption} from '@remotion/renderer/client';@@ -205,22 +204,17 @@ export const makeClientRetryPayload = (initialScale: job.scale,initialDelayRenderTimeout: job.delayRenderTimeout,initialMediaCacheSizeInBytes: job.mediaCacheSizeInBytes,- initialAudioBitrate:- job.type === 'client-video' ? job.audioBitrate : null,- initialAudioCodec:- job.type === 'client-video' ? (job.audioCodec as AudioCodec) : null,+ initialAudioBitrate: job.type === 'client-video' ? job.audioBitrate : null,+ initialAudioCodec: job.type === 'client-video' ? job.audioCodec : null,initialContainer: job.type === 'client-video' ? job.container : null,initialHardwareAcceleration:job.type === 'client-video'? (job.hardwareAcceleration as HardwareAccelerationOption): null,- initialVideoBitrate:- job.type === 'client-video' ? job.videoBitrate : null,- initialVideoCodec:- job.type === 'client-video' ? (job.videoCodec as Codec) : null,+ initialVideoBitrate: job.type === 'client-video' ? job.videoBitrate : null,+ initialVideoCodec: job.type === 'client-video' ? job.videoCodec : null,initialStillImageFormat:job.type === 'client-still' ? job.imageFormat : 'png',- initialVideoImageFormat: null,initialKeyframeIntervalInSeconds:job.type === 'client-video' ? job.keyframeIntervalInSeconds : null,initialMuted: job.type === 'client-video' ? job.muted : null,diff --git a/packages/studio/src/state/modals.ts b/packages/studio/src/state/modals.tsindex dfd542ea68..c0150738d6 100644--- a/packages/studio/src/state/modals.ts+++ b/packages/studio/src/state/modals.ts@@ -12,6 +12,13 @@ import type {} from '@remotion/renderer';import type {HardwareAccelerationOption} from '@remotion/renderer/client';import type {PackageManager, RenderDefaults} from '@remotion/studio-shared';+import type {+ RenderStillOnWebImageFormat,+ WebRendererAudioCodec,+ WebRendererContainer,+ WebRendererQuality,+ WebRendererVideoCodec,+} from '@remotion/web-renderer';import type React from 'react';import {createContext} from 'react';import type {_InternalTypes} from 'remotion';@@ -28,16 +35,15 @@ export type WebRenderModalState = {inFrameMark: number | null;outFrameMark: number | null;initialLogLevel: LogLevel;- initialVideoImageFormat: VideoImageFormat | null;- initialStillImageFormat: StillImageFormat;+ initialStillImageFormat: RenderStillOnWebImageFormat;initialScale: number;initialDelayRenderTimeout: number;initialDefaultOutName: string | null;- initialContainer: string | null;- initialVideoCodec: Codec | null;- initialAudioCodec: AudioCodec | null;- initialAudioBitrate: string | null;- initialVideoBitrate: string | null;+ initialContainer: WebRendererContainer | null;+ initialVideoCodec: WebRendererVideoCodec | null;+ initialAudioCodec: WebRendererAudioCodec | null;+ initialAudioBitrate: WebRendererQuality | null;+ initialVideoBitrate: WebRendererQuality | null;initialHardwareAcceleration: HardwareAccelerationOption | null;initialKeyframeIntervalInSeconds: number | null;initialTransparent: boolean | null;