🎥 Make videos programmatically with React
import type {LogLevel} from '@remotion/renderer';
import {RenderInternals} from '@remotion/renderer';
import {BrowserSafeApis} from '@remotion/renderer/client';
import type {RenderDefaults} from '@remotion/studio-shared';
import {ConfigInternals} from './config';
import {parsedCli} from './parsed-cli';
const {
allowHtmlInCanvasOption,
x264Option,
gopSizeOption,
audioBitrateOption,
offthreadVideoCacheSizeInBytesOption,
concurrencyOption,
offthreadVideoThreadsOption,
scaleOption,
jpegQualityOption,
videoBitrateOption,
crfOption,
enforceAudioOption,
mutedOption,
colorSpaceOption,
enableMultiprocessOnLinuxOption,
glOption,
numberOfGifLoopsOption,
beepOnFinishOption,
encodingMaxRateOption,
encodingBufferSizeOption,
reproOption,
delayRenderTimeoutInMillisecondsOption,
headlessOption,
forSeamlessAacConcatenationOption,
audioCodecOption,
hardwareAccelerationOption,
chromeModeOption,
mediaCacheSizeInBytesOption,
darkModeOption,
pixelFormatOption,
everyNthFrameOption,
proResProfileOption,
userAgentOption,
disableWebSecurityOption,
ignoreCertificateErrorsOption,
publicLicenseKeyOption,
stillImageFormatOption,
videoImageFormatOption,
sampleRateOption,
browserExecutableOption,
disableSharedMemoryCaptureOption,
} = BrowserSafeApis.options;
export const getRenderDefaults = (logLevel: LogLevel): RenderDefaults => {
const defaultJpegQuality = jpegQualityOption.getValue({
commandLine: parsedCli,
}).value;
const defaultCodec = ConfigInternals.getOutputCodecOrUndefined();
const concurrency = RenderInternals.resolveConcurrency(
concurrencyOption.getValue({commandLine: parsedCli}).value,
);
const pixelFormat = pixelFormatOption.getValue({
commandLine: parsedCli,
}).value;
const proResProfile =
proResProfileOption.getValue({commandLine: parsedCli}).value ?? null;
const x264Preset = x264Option.getValue({
commandLine: parsedCli,
}).value;
const gopSize = gopSizeOption.getValue({
commandLine: parsedCli,
}).value;
const audioBitrate = audioBitrateOption.getValue({
commandLine: parsedCli,
}).value;
const offthreadVideoCacheSizeInBytes =
offthreadVideoCacheSizeInBytesOption.getValue({
commandLine: parsedCli,
}).value;
const offthreadVideoThreads = offthreadVideoThreadsOption.getValue({
commandLine: parsedCli,
}).value;
const defaultScale = scaleOption.getValue({
commandLine: parsedCli,
}).value;
const videoBitrate = videoBitrateOption.getValue({
commandLine: parsedCli,
}).value;
const crf = crfOption.getValue({commandLine: parsedCli}).value ?? null;
const enforceAudioTrack = enforceAudioOption.getValue({
commandLine: parsedCli,
}).value;
const muted = mutedOption.getValue({
commandLine: parsedCli,
}).value;
const colorSpace = colorSpaceOption.getValue({
commandLine: parsedCli,
}).value;
const multiProcessOnLinux = enableMultiprocessOnLinuxOption.getValue({
commandLine: parsedCli,
}).value;
const gl = glOption.getValue({
commandLine: parsedCli,
}).value;
const numberOfGifLoops = numberOfGifLoopsOption.getValue({
commandLine: parsedCli,
}).value;
const beepOnFinish = beepOnFinishOption.getValue({
commandLine: parsedCli,
}).value;
const encodingMaxRate = encodingMaxRateOption.getValue({
commandLine: parsedCli,
}).value;
const encodingBufferSize = encodingBufferSizeOption.getValue({
commandLine: parsedCli,
}).value;
const repro = reproOption.getValue({
commandLine: parsedCli,
}).value;
const delayRenderTimeout = delayRenderTimeoutInMillisecondsOption.getValue({
commandLine: parsedCli,
}).value;
const headless = headlessOption.getValue({
commandLine: parsedCli,
}).value;
const forSeamlessAacConcatenation =
forSeamlessAacConcatenationOption.getValue({
commandLine: parsedCli,
}).value;
const audioCodec = audioCodecOption.getValue({
commandLine: parsedCli,
}).value;
const hardwareAcceleration = hardwareAccelerationOption.getValue({
commandLine: parsedCli,
}).value;
const chromeMode = chromeModeOption.getValue({
commandLine: parsedCli,
}).value;
const mediaCacheSizeInBytes = mediaCacheSizeInBytesOption.getValue({
commandLine: parsedCli,
}).value;
const publicLicenseKey = publicLicenseKeyOption.getValue({
commandLine: parsedCli,
}).value;
const everyNthFrame = everyNthFrameOption.getValue({
commandLine: parsedCli,
}).value;
const stillImageFormat = stillImageFormatOption.getValue({
commandLine: parsedCli,
}).value;
const videoImageFormat = videoImageFormatOption.getValue({
commandLine: parsedCli,
}).value;
const disableWebSecurity = disableWebSecurityOption.getValue({
commandLine: parsedCli,
}).value;
const ignoreCertificateErrors = ignoreCertificateErrorsOption.getValue({
commandLine: parsedCli,
}).value;
const darkMode = darkModeOption.getValue({
commandLine: parsedCli,
}).value;
const userAgent = userAgentOption.getValue({commandLine: parsedCli}).value;
const metadata = ConfigInternals.getMetadata();
const outputLocation = ConfigInternals.getOutputLocation();
const allowHtmlInCanvas = allowHtmlInCanvasOption.getValue({
commandLine: parsedCli,
}).value;
const maxConcurrency = RenderInternals.getMaxConcurrency();
const minConcurrency = RenderInternals.getMinConcurrency();
const configFileRenderDefaults = {
codec: defaultCodec ?? null,
proResProfile:
proResProfileOption.getValue({commandLine: {}}).value ?? null,
stillImageFormat:
stillImageFormatOption.getValue({commandLine: {}}).value ?? null,
videoImageFormat:
videoImageFormatOption.getValue({commandLine: {}}).value ?? null,
x264Preset: x264Option.getValue({commandLine: {}}).value ?? null,
};
return {
darkMode,
jpegQuality: defaultJpegQuality ?? RenderInternals.DEFAULT_JPEG_QUALITY,
scale: defaultScale ?? 1,
logLevel,
codec: defaultCodec ?? 'h264',
crf,
concurrency,
maxConcurrency,
minConcurrency,
stillImageFormat:
stillImageFormat ?? RenderInternals.DEFAULT_STILL_IMAGE_FORMAT,
videoImageFormat:
videoImageFormat ?? RenderInternals.DEFAULT_VIDEO_IMAGE_FORMAT,
muted,
enforceAudioTrack,
proResProfile,
x264Preset: x264Preset ?? 'medium',
gopSize,
pixelFormat,
audioBitrate,
videoBitrate,
encodingBufferSize,
encodingMaxRate,
everyNthFrame,
delayRenderTimeout,
audioCodec,
disableWebSecurity,
headless,
ignoreCertificateErrors,
openGlRenderer: gl,
offthreadVideoCacheSizeInBytes,
offthreadVideoThreads,
colorSpace,
multiProcessOnLinux,
userAgent,
repro,
numberOfGifLoops,
beepOnFinish,
forSeamlessAacConcatenation,
metadata,
hardwareAcceleration,
chromeMode,
mediaCacheSizeInBytes,
publicLicenseKey,
outputLocation,
allowHtmlInCanvas,
sampleRate: sampleRateOption.getValue({commandLine: parsedCli}).value,
configFileRenderDefaults,
sharedMemoryCapture: {
browserExecutable: browserExecutableOption.getValue({
commandLine: parsedCli,
}).value,
disabled: disableSharedMemoryCaptureOption.getValue({
commandLine: parsedCli,
}).value,
},
};
};