Skip to content

🎥 Make videos programmatically with React

size in bytes

Jonny Burgera95b2ea31504
diff --git a/packages/cli/src/config/index.ts b/packages/cli/src/config/index.ts
index 96cb053b90..1a6cce6b6b 100644
--- a/packages/cli/src/config/index.ts
+++ b/packages/cli/src/config/index.ts
@@ -87,7 +87,10 @@ import {getMuted, setMuted} from './muted';
import type {Loop} from './number-of-gif-loops';
import {getNumberOfGifLoops, setNumberOfGifLoops} from './number-of-gif-loops';
import {setNumberOfSharedAudioTags} from './number-of-shared-audio-tags';
-import {getOffthreadVideoCacheSizeInBytes} from './offthread-video-cache-size';
+import {
+ getOffthreadVideoCacheSizeInBytes,
+ setOffthreadVideoCacheSizeInBytes,
+} from './offthread-video-cache-size';
import {getShouldOpenBrowser, setShouldOpenBrowser} from './open-browser';
import {setOutputLocation} from './output-location';
import type {WebpackOverrideFn} from './override-webpack';
@@ -400,6 +403,7 @@ type FlatConfig = RemotionConfigObject &
* See the Encoding guide in the docs for defaults and available options.
*/
setAudioCodec: (codec: 'pcm-16' | 'aac' | 'mp3' | 'opus') => void;
+ setOffthreadVideoCacheSizeInBytes: (size: number | null) => void;
/**
* @deprecated 'The config format has changed. Change `Config.Bundling.*()` calls to `Config.*()` in your config file.'
*/
@@ -511,6 +515,7 @@ export const Config: FlatConfig = {
overrideWidth,
overrideFfmpegCommand: setFfmpegOverrideFunction,
setAudioCodec,
+ setOffthreadVideoCacheSizeInBytes,
};
export type {Concurrency, WebpackConfiguration, WebpackOverrideFn};
diff --git a/packages/cli/src/parse-command-line.ts b/packages/cli/src/parse-command-line.ts
index 02cacb5b94..794459e80c 100644
--- a/packages/cli/src/parse-command-line.ts
+++ b/packages/cli/src/parse-command-line.ts
@@ -29,8 +29,8 @@ type CommandLineOptions = {
['every-nth-frame']: number;
['number-of-gif-loops']: number;
['number-of-shared-audio-tags']: number;
- [BrowserSafeApis.options.offthreadVideoCacheSizeOption
- .cliFlag]: typeof BrowserSafeApis.options.offthreadVideoCacheSizeOption.type;
+ [BrowserSafeApis.options.offthreadVideoCacheSizeInBytesOption
+ .cliFlag]: typeof BrowserSafeApis.options.offthreadVideoCacheSizeInBytesOption.type;
version: string;
codec: Codec;
concurrency: number;
@@ -257,6 +257,12 @@ export const parseCommandLine = () => {
if (typeof parsedCli['video-bitrate'] !== 'undefined') {
Config.setVideoBitrate(parsedCli['video-bitrate']);
}
+
+ if (typeof parsedCli['offthreadvideo-cache-size-in-bytes'] !== 'undefined') {
+ Config.setOffthreadVideoCacheSizeInBytes(
+ parsedCli['offthreadvideo-cache-size-in-bytes'],
+ );
+ }
};
export const quietFlagProvided = () => parsedCli.quiet || parsedCli.q;
diff --git a/packages/renderer/src/client.ts b/packages/renderer/src/client.ts
index 99c08a75f3..881e0e0edb 100644
--- a/packages/renderer/src/client.ts
+++ b/packages/renderer/src/client.ts
@@ -20,7 +20,7 @@ import {crfOption} from './options/crf';
import {enforceAudioOption} from './options/enforce-audio';
import {jpegQualityOption} from './options/jpeg-quality';
import {muteOption} from './options/mute';
-import {offthreadVideoCacheSizeOption} from './options/offthreadvideo-cache-size';
+import {offthreadVideoCacheSizeInBytesOption} from './options/offthreadvideo-cache-size';
import {optionsMap} from './options/options-map';
import {scaleOption} from './options/scale';
import {videoBitrate} from './options/video-bitrate';
@@ -55,7 +55,7 @@ export const BrowserSafeApis = {
enforceAudioOption,
muteOption,
videoCodecOption,
- offthreadVideoCacheSizeOption,
+ offthreadVideoCacheSizeInBytesOption,
},
optionsMap,
codecSupportsCrf,
diff --git a/packages/renderer/src/offthread-video-server.ts b/packages/renderer/src/offthread-video-server.ts
index eb7c2ba344..a282d8e376 100644
--- a/packages/renderer/src/offthread-video-server.ts
+++ b/packages/renderer/src/offthread-video-server.ts
@@ -10,7 +10,7 @@ import {
import type {LogLevel} from './log-level';
import {isEqualOrBelowLogLevel} from './log-level';
import {Log} from './logger';
-import {validateOffthreadVideoCacheSize} from './options/offthreadvideo-cache-size';
+import {validateOffthreadVideoCacheSizeInBytes} from './options/offthreadvideo-cache-size';
export const extractUrlAndSourceFromUrl = (url: string) => {
const parsed = new URL(url, 'http://localhost');
@@ -48,10 +48,10 @@ export const startOffthreadVideoServer = ({
concurrency,
logLevel,
indent,
- offthreadVideoCacheSize,
+ offthreadVideoCacheSizeInBytes,
}: {
downloadMap: DownloadMap;
- offthreadVideoCacheSize: number | null;
+ offthreadVideoCacheSizeInBytes: number | null;
concurrency: number;
logLevel: LogLevel;
indent: boolean;
@@ -60,13 +60,14 @@ export const startOffthreadVideoServer = ({
close: () => Promise<void>;
compositor: Compositor;
} => {
- validateOffthreadVideoCacheSize(offthreadVideoCacheSize);
+ validateOffthreadVideoCacheSizeInBytes(offthreadVideoCacheSizeInBytes);
const compositor = startCompositor(
'StartLongRunningProcess',
{
concurrency,
maximum_frame_cache_size_in_bytes:
- offthreadVideoCacheSize ?? getIdealMaximumFrameCacheSizeInBytes(),
+ offthreadVideoCacheSizeInBytes ??
+ getIdealMaximumFrameCacheSizeInBytes(),
verbose: isEqualOrBelowLogLevel(logLevel, 'verbose'),
},
logLevel,
diff --git a/packages/renderer/src/options/offthreadvideo-cache-size.tsx b/packages/renderer/src/options/offthreadvideo-cache-size.tsx
index 6cec867d18..c395beccf9 100644
--- a/packages/renderer/src/options/offthreadvideo-cache-size.tsx
+++ b/packages/renderer/src/options/offthreadvideo-cache-size.tsx
@@ -1,6 +1,6 @@
import {AnyRemotionOption} from './option';
-export const offthreadVideoCacheSizeOption = {
+export const offthreadVideoCacheSizeInBytesOption = {
name: 'OffthreadVideo cache size',
cliFlag: 'offthreadvideo-cache-size-in-bytes' as const,
description: (
@@ -23,7 +23,7 @@ export const offthreadVideoCacheSizeOption = {
type: 0 as number | null,
} satisfies AnyRemotionOption;
-export const validateOffthreadVideoCacheSize = (option: unknown) => {
+export const validateOffthreadVideoCacheSizeInBytes = (option: unknown) => {
if (option === undefined || option === null) {
return;
}
diff --git a/packages/renderer/src/options/options-map.ts b/packages/renderer/src/options/options-map.ts
index 4d496da894..94be2f0a4c 100644
--- a/packages/renderer/src/options/options-map.ts
+++ b/packages/renderer/src/options/options-map.ts
@@ -1,14 +1,14 @@
-import {offthreadVideoCacheSizeOption} from './offthreadvideo-cache-size';
+import {offthreadVideoCacheSizeInBytesOption} from './offthreadvideo-cache-size';
export const optionsMap = {
- renderMedia: [offthreadVideoCacheSizeOption],
- renderStill: [offthreadVideoCacheSizeOption],
- getCompositions: [offthreadVideoCacheSizeOption],
- selectComposition: [offthreadVideoCacheSizeOption],
- renderFrames: [offthreadVideoCacheSizeOption],
- renderMediaOnLambda: [offthreadVideoCacheSizeOption],
- renderStillOnLambda: [offthreadVideoCacheSizeOption],
- getCompositionsOnLambda: [offthreadVideoCacheSizeOption],
- renderMediaOnCloudRun: [offthreadVideoCacheSizeOption],
- renderStillOnCloudRun: [offthreadVideoCacheSizeOption],
+ renderMedia: [offthreadVideoCacheSizeInBytesOption],
+ renderStill: [offthreadVideoCacheSizeInBytesOption],
+ getCompositions: [offthreadVideoCacheSizeInBytesOption],
+ selectComposition: [offthreadVideoCacheSizeInBytesOption],
+ renderFrames: [offthreadVideoCacheSizeInBytesOption],
+ renderMediaOnLambda: [offthreadVideoCacheSizeInBytesOption],
+ renderStillOnLambda: [offthreadVideoCacheSizeInBytesOption],
+ getCompositionsOnLambda: [offthreadVideoCacheSizeInBytesOption],
+ renderMediaOnCloudRun: [offthreadVideoCacheSizeInBytesOption],
+ renderStillOnCloudRun: [offthreadVideoCacheSizeInBytesOption],
} as const;
diff --git a/packages/renderer/src/serve-static.ts b/packages/renderer/src/serve-static.ts
index 9f7e61df7c..be228bc771 100644
--- a/packages/renderer/src/serve-static.ts
+++ b/packages/renderer/src/serve-static.ts
@@ -32,7 +32,7 @@ export const serveStatic = async (
concurrency: options.concurrency,
logLevel: options.logLevel,
indent: options.indent,
- offthreadVideoCacheSize: options.offthreadVideoCacheSizeInBytes,
+ offthreadVideoCacheSizeInBytes: options.offthreadVideoCacheSizeInBytes,
});
const connections: Record<string, Socket> = {};