🎥 Make videos programmatically with React
import {BrowserSafeApis} from '@remotion/renderer/client';
import type {JobProgressCallback, RenderJob} from '@remotion/studio-server';
import {convertEntryPointToServeUrl} from '../convert-entry-point-to-serve-url';
import {parsedCli} from '../parsed-cli';
import {renderStillFlow} from '../render-flows/still';
import type {StudioRenderJobFixedConfig} from './studio-render-job-fixed-config';
const {
askAIOption,
keyboardShortcutsOption,
browserExecutableOption,
bundleCacheOption,
} = BrowserSafeApis.options;
export const processStill = async ({
job,
remotionRoot,
entryPoint,
onProgress,
addCleanupCallback,
fixedConfig,
}: {
job: RenderJob;
remotionRoot: string;
entryPoint: string;
onProgress: JobProgressCallback;
addCleanupCallback: (label: string, cb: () => void) => void;
fixedConfig: StudioRenderJobFixedConfig;
}) => {
if (job.type !== 'still') {
throw new Error('Expected still job');
}
const browserExecutable = browserExecutableOption.getValue({
commandLine: parsedCli,
}).value;
const askAIEnabled = askAIOption.getValue({commandLine: parsedCli}).value;
const keyboardShortcutsEnabled = keyboardShortcutsOption.getValue({
commandLine: parsedCli,
}).value;
const shouldCache = bundleCacheOption.getValue({
commandLine: parsedCli,
}).value;
const fullEntryPoint = convertEntryPointToServeUrl(entryPoint);
await renderStillFlow({
remotionRoot,
browser: 'chrome',
browserExecutable,
chromiumOptions: job.chromiumOptions,
entryPointReason: 'same as Studio',
envVariables: job.envVariables,
height: null,
width: null,
fps: null,
durationInFrames: null,
fullEntryPoint,
serializedInputPropsWithCustomSchema:
job.serializedInputPropsWithCustomSchema,
overwrite: true,
port: fixedConfig.rendererPort,
publicDir: fixedConfig.publicDir,
puppeteerTimeout: job.delayRenderTimeout,
jpegQuality: job.jpegQuality,
remainingArgs: [],
scale: job.scale,
stillFrame: job.frame,
compositionIdFromUi: job.compositionId,
imageFormatFromUi: job.imageFormat,
logLevel: job.logLevel,
onProgress,
indent: true,
addCleanupCallback,
cancelSignal: job.cancelToken.cancelSignal,
outputLocationFromUi: job.outName,
offthreadVideoCacheSizeInBytes: job.offthreadVideoCacheSizeInBytes,
offthreadVideoThreads: job.offthreadVideoThreads,
binariesDirectory: job.binariesDirectory,
publicPath: null,
chromeMode: job.chromeMode,
audioLatencyHint: null,
mediaCacheSizeInBytes: job.mediaCacheSizeInBytes,
askAIEnabled,
keyboardShortcutsEnabled,
rspack: fixedConfig.rspack,
shouldCache,
bundlerOverride: fixedConfig.bundlerOverride,
rspackOverride: fixedConfig.rspackOverride,
webpackOverride: fixedConfig.webpackOverride,
licenseKey: job.licenseKey,
});
};