Skip to content

Commit

Permalink
add new offthreadvideo threads option
Browse files Browse the repository at this point in the history
  • Loading branch information
JonnyBurger committed Feb 9, 2025
1 parent f42758d commit e945fd7
Show file tree
Hide file tree
Showing 96 changed files with 452 additions and 47 deletions.
7 changes: 7 additions & 0 deletions packages/cli/src/benchmark.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ const {
metadataOption,
hardwareAccelerationOption,
chromeModeOption,
offthreadVideoThreadsOption,
} = BrowserSafeApis.options;

const getValidConcurrency = (cliConcurrency: number | string | null) => {
Expand Down Expand Up @@ -320,6 +321,9 @@ export const benchmarkCommand = async (
offthreadVideoCacheSizeInBytesOption.getValue({
commandLine: parsedCli,
}).value,
offthreadVideoThreads: offthreadVideoThreadsOption.getValue({
commandLine: parsedCli,
}).value,
binariesDirectory: binariesDirectoryOption.getValue({
commandLine: parsedCli,
}).value,
Expand Down Expand Up @@ -481,6 +485,9 @@ export const benchmarkCommand = async (
indent: undefined,
staticBase: null,
}).serializedString,
offthreadVideoThreads: offthreadVideoThreadsOption.getValue({
commandLine: parsedCli,
}).value,
offthreadVideoCacheSizeInBytes:
offthreadVideoCacheSizeInBytesOption.getValue({
commandLine: parsedCli,
Expand Down
5 changes: 5 additions & 0 deletions packages/cli/src/compositions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {bundleOnCliOrTakeServeUrl} from './setup-cache';
const {
enableMultiprocessOnLinuxOption,
offthreadVideoCacheSizeInBytesOption,
offthreadVideoThreadsOption,
glOption,
headlessOption,
delayRenderTimeoutInMillisecondsOption,
Expand Down Expand Up @@ -97,6 +98,9 @@ export const listCompositionsCommand = async (
offthreadVideoCacheSizeInBytesOption.getValue({
commandLine: parsedCli,
}).value;
const offthreadVideoThreads = offthreadVideoThreadsOption.getValue({
commandLine: parsedCli,
}).value;
const publicDir = publicDirOption.getValue({commandLine: parsedCli}).value;
const chromeMode = chromeModeOption.getValue({
commandLine: parsedCli,
Expand Down Expand Up @@ -146,6 +150,7 @@ export const listCompositionsCommand = async (
logLevel,
server: undefined,
offthreadVideoCacheSizeInBytes,
offthreadVideoThreads,
binariesDirectory,
onBrowserDownload: defaultBrowserDownloadProgress({
indent: false,
Expand Down
4 changes: 4 additions & 0 deletions packages/cli/src/get-composition-id.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export const getCompositionId = async ({
indent,
server,
offthreadVideoCacheSizeInBytes,
offthreadVideoThreads,
binariesDirectory,
onBrowserDownload,
chromeMode,
Expand All @@ -78,6 +79,7 @@ export const getCompositionId = async ({
indent: boolean;
server: RemotionServer;
offthreadVideoCacheSizeInBytes: number | null;
offthreadVideoThreads: number | null;
binariesDirectory: string | null;
onBrowserDownload: OnBrowserDownload;
chromeMode: ChromeMode;
Expand Down Expand Up @@ -109,6 +111,7 @@ export const getCompositionId = async ({
indent,
onBrowserLog: null,
offthreadVideoCacheSizeInBytes,
offthreadVideoThreads,
binariesDirectory,
onBrowserDownload,
onServeUrlVisited: () => undefined,
Expand Down Expand Up @@ -156,6 +159,7 @@ export const getCompositionId = async ({
onBrowserLog: null,
serializedInputPropsWithCustomSchema,
offthreadVideoCacheSizeInBytes,
offthreadVideoThreads,
binariesDirectory,
onBrowserDownload,
chromeMode,
Expand Down
3 changes: 3 additions & 0 deletions packages/cli/src/get-composition-with-dimension-override.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export const getCompositionWithDimensionOverride = async ({
logLevel,
server,
offthreadVideoCacheSizeInBytes,
offthreadVideoThreads,
binariesDirectory,
onBrowserDownload,
chromeMode,
Expand All @@ -47,6 +48,7 @@ export const getCompositionWithDimensionOverride = async ({
serializedInputPropsWithCustomSchema: string;
server: RemotionServer;
offthreadVideoCacheSizeInBytes: number | null;
offthreadVideoThreads: number | null;
binariesDirectory: string | null;
onBrowserDownload: OnBrowserDownload;
chromeMode: ChromeMode;
Expand Down Expand Up @@ -74,6 +76,7 @@ export const getCompositionWithDimensionOverride = async ({
binariesDirectory,
onBrowserDownload,
chromeMode,
offthreadVideoThreads,
});

return {
Expand Down
5 changes: 5 additions & 0 deletions packages/cli/src/get-render-defaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const {
x264Option,
audioBitrateOption,
offthreadVideoCacheSizeInBytesOption,
offthreadVideoThreadsOption,
scaleOption,
jpegQualityOption,
videoBitrateOption,
Expand Down Expand Up @@ -52,6 +53,9 @@ export const getRenderDefaults = (): RenderDefaults => {
offthreadVideoCacheSizeInBytesOption.getValue({
commandLine: parsedCli,
}).value;
const offthreadVideoThreads = offthreadVideoThreadsOption.getValue({
commandLine: parsedCli,
}).value;
const defaultScale = scaleOption.getValue({
commandLine: parsedCli,
}).value;
Expand Down Expand Up @@ -148,6 +152,7 @@ export const getRenderDefaults = (): RenderDefaults => {
ignoreCertificateErrors,
openGlRenderer: gl,
offthreadVideoCacheSizeInBytes,
offthreadVideoThreads,
colorSpace,
multiProcessOnLinux,
userAgent,
Expand Down
2 changes: 2 additions & 0 deletions packages/cli/src/list-of-remotion-packages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export const listOfRemotionPackages = [
'@remotion/lambda-ruby',
'@remotion/lambda-python',
'@remotion/lambda',
'@remotion/lambda-client',
'@remotion/layout-utils',
'@remotion/licensing',
'@remotion/lottie',
Expand All @@ -58,6 +59,7 @@ export const listOfRemotionPackages = [
'@remotion/promo-pages',
'@remotion/streaming',
'@remotion/serverless',
'@remotion/serverless-client',
'@remotion/studio-server',
'@remotion/studio-shared',
'@remotion/studio',
Expand Down
9 changes: 8 additions & 1 deletion packages/cli/src/render-flows/render.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ export const renderVideoFlow = async ({
serializedInputPropsWithCustomSchema,
disallowParallelEncoding,
offthreadVideoCacheSizeInBytes,
offthreadVideoThreads,
colorSpace,
repro,
binariesDirectory,
Expand Down Expand Up @@ -161,6 +162,7 @@ export const renderVideoFlow = async ({
audioCodec: AudioCodec | null;
disallowParallelEncoding: boolean;
offthreadVideoCacheSizeInBytes: number | null;
offthreadVideoThreads: number | null;
colorSpace: ColorSpace | null;
repro: boolean;
binariesDirectory: string | null;
Expand Down Expand Up @@ -306,7 +308,9 @@ export const renderVideoFlow = async ({

const resolvedConcurrency = RenderInternals.resolveConcurrency(concurrency);
const server = await RenderInternals.prepareServer({
concurrency: resolvedConcurrency,
offthreadVideoThreads:
offthreadVideoThreads ??
RenderInternals.DEFAULT_RENDER_FRAMES_OFFTHREAD_VIDEO_THREADS,
indent,
port,
remotionRoot,
Expand Down Expand Up @@ -337,6 +341,7 @@ export const renderVideoFlow = async ({
logLevel,
server,
offthreadVideoCacheSizeInBytes,
offthreadVideoThreads,
binariesDirectory,
onBrowserDownload,
chromeMode,
Expand Down Expand Up @@ -516,6 +521,7 @@ export const renderVideoFlow = async ({
data: config.props,
}).serializedString,
offthreadVideoCacheSizeInBytes,
offthreadVideoThreads,
parallelEncodingEnabled: isUsingParallelEncoding,
binariesDirectory,
compositionStart: 0,
Expand Down Expand Up @@ -605,6 +611,7 @@ export const renderVideoFlow = async ({
staticBase: null,
}).serializedString,
offthreadVideoCacheSizeInBytes,
offthreadVideoThreads,
colorSpace,
repro: repro ?? false,
binariesDirectory,
Expand Down
8 changes: 7 additions & 1 deletion packages/cli/src/render-flows/still.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ export const renderStillFlow = async ({
binariesDirectory,
publicPath,
chromeMode,
offthreadVideoThreads,
}: {
remotionRoot: string;
fullEntryPoint: string;
Expand Down Expand Up @@ -105,6 +106,7 @@ export const renderStillFlow = async ({
cancelSignal: CancelSignal | null;
outputLocationFromUi: string | null;
offthreadVideoCacheSizeInBytes: number | null;
offthreadVideoThreads: number | null;
binariesDirectory: string | null;
publicPath: string | null;
chromeMode: ChromeMode;
Expand Down Expand Up @@ -201,7 +203,9 @@ export const renderStillFlow = async ({
);

const server = await RenderInternals.prepareServer({
concurrency: 1,
offthreadVideoThreads:
offthreadVideoThreads ??
RenderInternals.DEFAULT_RENDER_FRAMES_OFFTHREAD_VIDEO_THREADS,
indent,
port,
remotionRoot,
Expand Down Expand Up @@ -239,6 +243,7 @@ export const renderStillFlow = async ({
logLevel,
server,
offthreadVideoCacheSizeInBytes,
offthreadVideoThreads,
binariesDirectory,
onBrowserDownload,
chromeMode,
Expand Down Expand Up @@ -372,6 +377,7 @@ export const renderStillFlow = async ({
onBrowserDownload,
onArtifact,
chromeMode,
offthreadVideoThreads,
});

aggregate.rendering = {
Expand Down
1 change: 1 addition & 0 deletions packages/cli/src/render-queue/process-still.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export const processStill = async ({
cancelSignal: job.cancelToken.cancelSignal,
outputLocationFromUi: job.outName,
offthreadVideoCacheSizeInBytes: job.offthreadVideoCacheSizeInBytes,
offthreadVideoThreads: job.offthreadVideoThreads,
binariesDirectory: job.binariesDirectory,
publicPath: null,
chromeMode: job.chromeMode,
Expand Down
1 change: 1 addition & 0 deletions packages/cli/src/render-queue/process-video.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,5 +99,6 @@ export const processVideoJob = async ({
hardwareAcceleration:
job.type === 'video' ? job.hardwareAcceleration : 'disable',
chromeMode: job.chromeMode,
offthreadVideoThreads: job.offthreadVideoThreads,
});
};
5 changes: 5 additions & 0 deletions packages/cli/src/render.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ const {
metadataOption,
hardwareAccelerationOption,
chromeModeOption,
offthreadVideoThreadsOption,
} = BrowserSafeApis.options;

export const render = async (
Expand Down Expand Up @@ -108,6 +109,9 @@ export const render = async (
offthreadVideoCacheSizeInBytesOption.getValue({
commandLine: parsedCli,
}).value;
const offthreadVideoThreads = offthreadVideoThreadsOption.getValue({
commandLine: parsedCli,
}).value;
const scale = scaleOption.getValue({commandLine: parsedCli}).value;
const jpegQuality = jpegQualityOption.getValue({
commandLine: parsedCli,
Expand Down Expand Up @@ -245,5 +249,6 @@ export const render = async (
metadata,
hardwareAcceleration,
chromeMode,
offthreadVideoThreads,
});
};
5 changes: 5 additions & 0 deletions packages/cli/src/still.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const {
publicPathOption,
publicDirOption,
chromeModeOption,
offthreadVideoThreadsOption,
} = BrowserSafeApis.options;

export const still = async (
Expand Down Expand Up @@ -90,6 +91,9 @@ export const still = async (
offthreadVideoCacheSizeInBytesOption.getValue({
commandLine: parsedCli,
}).value;
const offthreadVideoThreads = offthreadVideoThreadsOption.getValue({
commandLine: parsedCli,
}).value;
const puppeteerTimeout = delayRenderTimeoutInMillisecondsOption.getValue({
commandLine: parsedCli,
}).value;
Expand Down Expand Up @@ -159,6 +163,7 @@ export const still = async (
cancelSignal: null,
outputLocationFromUi: null,
offthreadVideoCacheSizeInBytes,
offthreadVideoThreads,
binariesDirectory,
publicPath,
chromeMode,
Expand Down
2 changes: 2 additions & 0 deletions packages/cloudrun/src/api/render-media-on-cloudrun.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ const internalRenderMediaOnCloudrunRaw = async ({
enforceAudioTrack,
preferLossless,
offthreadVideoCacheSizeInBytes,
offthreadVideoThreads,
colorSpace,
downloadBehavior,
metadata,
Expand Down Expand Up @@ -197,6 +198,7 @@ const internalRenderMediaOnCloudrunRaw = async ({
enforceAudioTrack: enforceAudioTrack ?? false,
preferLossless: preferLossless ?? false,
offthreadVideoCacheSizeInBytes: offthreadVideoCacheSizeInBytes ?? null,
offthreadVideoThreads: offthreadVideoThreads ?? null,
colorSpace: colorSpace ?? null,
clientVersion: VERSION,
downloadBehavior,
Expand Down
3 changes: 3 additions & 0 deletions packages/cloudrun/src/api/render-still-on-cloudrun.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ const internalRenderStillOnCloudRun = async ({
logLevel,
delayRenderTimeoutInMilliseconds,
offthreadVideoCacheSizeInBytes,
offthreadVideoThreads,
downloadBehavior,
renderIdOverride,
renderStatusWebhook,
Expand Down Expand Up @@ -140,6 +141,7 @@ const internalRenderStillOnCloudRun = async ({
logLevel,
delayRenderTimeoutInMilliseconds,
offthreadVideoCacheSizeInBytes,
offthreadVideoThreads,
clientVersion: VERSION,
downloadBehavior,
renderIdOverride,
Expand Down Expand Up @@ -242,6 +244,7 @@ export const renderStillOnCloudrun = (options: RenderStillOnCloudrunInput) => {
logLevel: options.logLevel ?? 'info',
offthreadVideoCacheSizeInBytes:
options.offthreadVideoCacheSizeInBytes ?? null,
offthreadVideoThreads: options.offthreadVideoThreads ?? null,
outName: options.outName ?? null,
privacy: options.privacy ?? 'public',
region: options.region,
Expand Down
1 change: 1 addition & 0 deletions packages/cloudrun/src/api/test/payloads.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ test('CloudRunPayload should work with and without optional webhook fields', ()
downloadBehavior: {type: 'play-in-browser' as const},
outName: null,
offthreadVideoCacheSizeInBytes: null,
offthreadVideoThreads: null,
serializedInputPropsWithCustomSchema: JSON.stringify({}),
};

Expand Down
7 changes: 6 additions & 1 deletion packages/cloudrun/src/cli/commands/render/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const {
audioBitrateOption,
x264Option,
offthreadVideoCacheSizeInBytesOption,
offthreadVideoThreadsOption,
scaleOption,
crfOption,
jpegQualityOption,
Expand Down Expand Up @@ -93,6 +94,9 @@ export const renderCommand = async (
offthreadVideoCacheSizeInBytesOption.getValue({
commandLine: CliInternals.parsedCli,
}).value;
const offthreadVideoThreads = offthreadVideoThreadsOption.getValue({
commandLine: CliInternals.parsedCli,
}).value;
const enableMultiProcessOnLinux = enableMultiprocessOnLinuxOption.getValue({
commandLine: CliInternals.parsedCli,
}).value;
Expand Down Expand Up @@ -132,7 +136,7 @@ export const renderCommand = async (
}

const server = RenderInternals.prepareServer({
concurrency: 1,
offthreadVideoThreads: 1,
indent: false,
port: ConfigInternals.getRendererPortFromConfigFileAndCliFlag(),
remotionRoot,
Expand Down Expand Up @@ -168,6 +172,7 @@ export const renderCommand = async (
staticBase: null,
}).serializedString,
offthreadVideoCacheSizeInBytes,
offthreadVideoThreads,
binariesDirectory,
onBrowserDownload: CliInternals.defaultBrowserDownloadProgress({
indent,
Expand Down
Loading

0 comments on commit e945fd7

Please sign in to comment.