Skip to content

🎥 Make videos programmatically with React

add to remotion studio

Jonny Burger1c76d95f25fc
diff --git a/packages/cli/src/editor/components/RenderModal/NumberSetting.tsx b/packages/cli/src/editor/components/RenderModal/NumberSetting.tsx
index 7977acd6cf..b960e8cd42 100644
--- a/packages/cli/src/editor/components/RenderModal/NumberSetting.tsx
+++ b/packages/cli/src/editor/components/RenderModal/NumberSetting.tsx
@@ -28,14 +28,14 @@ export const NumberSetting: React.FC<{
return Math.min(max ?? Infinity, Math.max(newSetting, min));
});
},
- [max, min, onValueChanged]
+ [max, min, onValueChanged],
);
const onValueChange = useCallback(
(newConcurrency: number) => {
onValueChanged(newConcurrency);
},
- [onValueChanged]
+ [onValueChanged],
);
return (
diff --git a/packages/cli/src/editor/components/RenderModal/RenderModal.tsx b/packages/cli/src/editor/components/RenderModal/RenderModal.tsx
index 927d77f8a3..9c6e7c701f 100644
--- a/packages/cli/src/editor/components/RenderModal/RenderModal.tsx
+++ b/packages/cli/src/editor/components/RenderModal/RenderModal.tsx
@@ -1123,6 +1123,10 @@ const RenderModal: React.FC<
setOpenGlOption={setOpenGlOption}
setEnvVariables={setEnvVariables}
envVariables={envVariables}
+ offthreadVideoCacheSizeInBytes={offthreadVideoCacheSizeInBytes}
+ setOffthreadVideoCacheSizeInBytes={
+ setOffthreadVideoCacheSizeInBytes
+ }
codec={codec}
/>
)}
diff --git a/packages/cli/src/editor/components/RenderModal/RenderModalAdvanced.tsx b/packages/cli/src/editor/components/RenderModal/RenderModalAdvanced.tsx
index 678851079a..8bbaee1a06 100644
--- a/packages/cli/src/editor/components/RenderModal/RenderModalAdvanced.tsx
+++ b/packages/cli/src/editor/components/RenderModal/RenderModalAdvanced.tsx
@@ -46,6 +46,10 @@ export const RenderModalAdvanced: React.FC<{
setEnvVariables: React.Dispatch<React.SetStateAction<[string, string][]>>;
x264Preset: X264Preset | null;
setx264Preset: React.Dispatch<React.SetStateAction<X264Preset>>;
+ offthreadVideoCacheSizeInBytes: number | null;
+ setOffthreadVideoCacheSizeInBytes: React.Dispatch<
+ React.SetStateAction<number | null>
+ >;
codec: Codec;
}> = ({
renderMode,
@@ -72,6 +76,8 @@ export const RenderModalAdvanced: React.FC<{
setx264Preset,
x264Preset,
codec,
+ offthreadVideoCacheSizeInBytes,
+ setOffthreadVideoCacheSizeInBytes,
}) => {
const extendedOpenGlOptions: UiOpenGlOptions[] = useMemo(() => {
return ['angle', 'egl', 'swangle', 'swiftshader', 'default'];
@@ -80,35 +86,45 @@ export const RenderModalAdvanced: React.FC<{
(e: ChangeEvent<HTMLInputElement>) => {
setVerboseLogging(e.target.checked);
},
- [setVerboseLogging]
+ [setVerboseLogging],
);
+ const toggleCustomOffthreadVideoCacheSizeInBytes = useCallback(() => {
+ setOffthreadVideoCacheSizeInBytes((previous) => {
+ if (previous === null) {
+ return 512 * 1024 * 1024;
+ }
+
+ return null;
+ });
+ }, [setOffthreadVideoCacheSizeInBytes]);
+
const onDisallowParallelEncodingChanged = useCallback(
(e: ChangeEvent<HTMLInputElement>) => {
setDisallowParallelEncoding(e.target.checked);
},
- [setDisallowParallelEncoding]
+ [setDisallowParallelEncoding],
);
const onDisableWebSecurityChanged = useCallback(
(e: ChangeEvent<HTMLInputElement>) => {
setDisableWebSecurity(e.target.checked);
},
- [setDisableWebSecurity]
+ [setDisableWebSecurity],
);
const onIgnoreCertificatErrors = useCallback(
(e: ChangeEvent<HTMLInputElement>) => {
setIgnoreCertificateErrors(e.target.checked);
},
- [setIgnoreCertificateErrors]
+ [setIgnoreCertificateErrors],
);
const onHeadless = useCallback(
(e: ChangeEvent<HTMLInputElement>) => {
setHeadless(e.target.checked);
},
- [setHeadless]
+ [setHeadless],
);
const openGlOptions = useMemo((): ComboboxValue[] => {
@@ -146,6 +162,25 @@ export const RenderModalAdvanced: React.FC<{
});
}, [setx264Preset, x264Preset]);
+ const changeOffthreadVideoCacheSizeInBytes: React.Dispatch<
+ React.SetStateAction<number>
+ > = useCallback(
+ (cb) => {
+ setOffthreadVideoCacheSizeInBytes((prev) => {
+ if (prev === null) {
+ throw new TypeError('Expected previous value');
+ }
+
+ if (typeof cb === 'function') {
+ return cb(prev);
+ }
+
+ return cb;
+ });
+ },
+ [setOffthreadVideoCacheSizeInBytes],
+ );
+
return (
<div style={container} className={VERTICAL_SCROLLBAR_CLASSNAME}>
{renderMode === 'video' && codec === 'h264' ? (
@@ -191,6 +226,30 @@ export const RenderModalAdvanced: React.FC<{
/>
</div>
</div>
+ {renderMode === 'audio' ? null : (
+ <div style={optionRow}>
+ <div style={label}>Custom OffthreadVideo cache</div>
+ <div style={rightRow}>
+ <Checkbox
+ checked={offthreadVideoCacheSizeInBytes !== null}
+ onChange={toggleCustomOffthreadVideoCacheSizeInBytes}
+ name="custom-audio-bitrate"
+ />
+ </div>
+ </div>
+ )}
+ {renderMode === 'audio' ||
+ offthreadVideoCacheSizeInBytes === null ? null : (
+ <NumberSetting
+ min={minConcurrency}
+ max={2000 * 1024 * 1024}
+ step={1024}
+ name="OffthreadVideo cache size"
+ formatter={(w) => `${w} bytes`}
+ onValueChanged={changeOffthreadVideoCacheSizeInBytes}
+ value={offthreadVideoCacheSizeInBytes}
+ />
+ )}
<div style={optionRow}>
<div style={label}>Verbose logging</div>
<div style={rightRow}>
diff --git a/packages/cli/src/editor/components/RenderModal/layout.ts b/packages/cli/src/editor/components/RenderModal/layout.ts
index 9a077446ff..1d8be5e694 100644
--- a/packages/cli/src/editor/components/RenderModal/layout.ts
+++ b/packages/cli/src/editor/components/RenderModal/layout.ts
@@ -12,7 +12,7 @@ export const optionRow: React.CSSProperties = {
};
export const label: React.CSSProperties = {
- width: 170,
+ width: 220,
fontSize: 15,
lineHeight: '40px',
color: LIGHT_TEXT,