🎥 Make videos programmatically with React
binaries directory
Jonny Burger5173072622a9
diff --git a/packages/cli/src/config/index.ts b/packages/cli/src/config/index.tsindex 1d752a91d4..184bfd26b3 100644--- a/packages/cli/src/config/index.ts+++ b/packages/cli/src/config/index.ts@@ -114,6 +114,7 @@ const {enableLambdaInsights,logLevelOption,delayRenderTimeoutInMillisecondsOption,+ binariesDirectoryOption,} = BrowserSafeApis.options;declare global {@@ -452,6 +453,11 @@ declare global {* Collect information that you can submit to Remotion if asked for a reproduction.*/readonly setRepro: (enableRepro: boolean) => void;+ /**+ * The directory where the platform-specific binaries and libraries needed+ for Remotion are located.+ */+ readonly setBinariesDirectory: (directory: string | null) => void;}}@@ -604,6 +610,7 @@ export const Config: FlatConfig = {setEnableFolderExpiry: folderExpiryOption.setConfig,setRepro: reproOption.setConfig,setLambdaInsights: enableLambdaInsights.setConfig,+ setBinariesDirectory: binariesDirectoryOption.setConfig,};export const ConfigInternals = {diff --git a/packages/renderer/src/assets/get-audio-channels.ts b/packages/renderer/src/assets/get-audio-channels.tsindex e93782c955..b3be35a04a 100644--- a/packages/renderer/src/assets/get-audio-channels.ts+++ b/packages/renderer/src/assets/get-audio-channels.ts@@ -12,6 +12,7 @@ export const getAudioChannelsAndDurationWithoutCache = async (src: string,indent: boolean,logLevel: LogLevel,+ binariesDirectory: string | null,) => {const args = [['-v', 'error'],@@ -22,7 +23,13 @@ export const getAudioChannelsAndDurationWithoutCache = async (.reduce<(string | null)[]>((acc, val) => acc.concat(val), []).filter(Boolean) as string[];- const task = await callFf({bin: 'ffprobe', args, indent, logLevel});+ const task = await callFf({+ bin: 'ffprobe',+ args,+ indent,+ logLevel,+ binariesDirectory,+ });const channels = task.stdout.match(/channels=([0-9]+)/);const duration = task.stdout.match(/duration=([0-9.]+)/);@@ -34,12 +41,19 @@ export const getAudioChannelsAndDurationWithoutCache = async (return result;};-async function getAudioChannelsAndDurationUnlimited(- downloadMap: DownloadMap,- src: string,- indent: boolean,- logLevel: LogLevel,-): Promise<AudioChannelsAndDurationResultCache> {+async function getAudioChannelsAndDurationUnlimited({+ downloadMap,+ src,+ indent,+ logLevel,+ binariesDirectory,+}: {+ downloadMap: DownloadMap;+ src: string;+ indent: boolean;+ logLevel: LogLevel;+ binariesDirectory: string | null;+}): Promise<AudioChannelsAndDurationResultCache> {if (downloadMap.durationOfAssetCache[src]) {return downloadMap.durationOfAssetCache[src];}@@ -48,6 +62,7 @@ async function getAudioChannelsAndDurationUnlimited(src,indent,logLevel,+ binariesDirectory,);downloadMap.durationOfAssetCache[src] = result;@@ -55,13 +70,26 @@ async function getAudioChannelsAndDurationUnlimited(return result;}-export const getAudioChannelsAndDuration = (- downloadMap: DownloadMap,- src: string,- indent: boolean,- logLevel: LogLevel,-): Promise<AudioChannelsAndDurationResultCache> => {+export const getAudioChannelsAndDuration = ({+ downloadMap,+ src,+ indent,+ logLevel,+ binariesDirectory,+}: {+ downloadMap: DownloadMap;+ src: string;+ indent: boolean;+ logLevel: LogLevel;+ binariesDirectory: string | null;+}): Promise<AudioChannelsAndDurationResultCache> => {return limit(() =>- getAudioChannelsAndDurationUnlimited(downloadMap, src, indent, logLevel),+ getAudioChannelsAndDurationUnlimited({+ downloadMap,+ src,+ indent,+ logLevel,+ binariesDirectory,+ }),);};diff --git a/packages/renderer/src/call-ffmpeg.ts b/packages/renderer/src/call-ffmpeg.tsindex d7dcef3f95..883e132242 100644--- a/packages/renderer/src/call-ffmpeg.ts+++ b/packages/renderer/src/call-ffmpeg.ts@@ -13,14 +13,21 @@ export const callFf = ({indent,logLevel,options,+ binariesDirectory,}: {bin: 'ffmpeg' | 'ffprobe';args: (string | null)[];indent: boolean;logLevel: LogLevel;+ binariesDirectory: string | null;options?: execa.Options<string>;}) => {- const executablePath = getExecutablePath(bin, indent, logLevel);+ const executablePath = getExecutablePath({+ type: bin,+ indent,+ logLevel,+ binariesDirectory,+ });if (!process.env.READ_ONLY_FS) {chmodSync(executablePath, 0o755);}@@ -37,14 +44,21 @@ export const callFfNative = ({indent,logLevel,options,+ binariesDirectory,}: {bin: 'ffmpeg' | 'ffprobe';args: (string | null)[];indent: boolean;logLevel: LogLevel;+ binariesDirectory: string | null;options?: SpawnOptionsWithoutStdio;}) => {- const executablePath = getExecutablePath(bin, indent, logLevel);+ const executablePath = getExecutablePath({+ type: bin,+ indent,+ logLevel,+ binariesDirectory,+ });if (!process.env.READ_ONLY_FS) {chmodSync(executablePath, 0o755);}diff --git a/packages/renderer/src/combine-videos.ts b/packages/renderer/src/combine-videos.tsindex d9e12d82c1..0b09740a14 100644--- a/packages/renderer/src/combine-videos.ts+++ b/packages/renderer/src/combine-videos.ts@@ -30,6 +30,7 @@ type Options = {audioBitrate: string | null;indent: boolean;logLevel: LogLevel;+ binariesDirectory: string | null;};export const combineVideos = async (options: Options) => {@@ -46,6 +47,7 @@ export const combineVideos = async (options: Options) => {audioBitrate,indent,logLevel,+ binariesDirectory,} = options;const fileList = files.map((p) => `file '${p}'`).join('\n');@@ -94,6 +96,7 @@ export const combineVideos = async (options: Options) => {args: command,indent: options.indent,logLevel: options.logLevel,+ binariesDirectory,});task.stderr?.on('data', (data: Buffer) => {if (onProgress) {diff --git a/packages/renderer/src/compositor/compose.ts b/packages/renderer/src/compositor/compose.tsindex 3266c97dcd..1e92192bf8 100644--- a/packages/renderer/src/compositor/compose.ts+++ b/packages/renderer/src/compositor/compose.ts@@ -99,9 +99,15 @@ export const callCompositor = (payload: string,indent: boolean,logLevel: LogLevel,+ binariesDirectory: string | null,) => {return new Promise<void>((resolve, reject) => {- const execPath = getExecutablePath('compositor', indent, logLevel);+ const execPath = getExecutablePath({+ type: 'compositor',+ indent,+ logLevel,+ binariesDirectory,+ });if (!process.env.READ_ONLY_FS) {chmodSync(execPath, 0o755);}diff --git a/packages/renderer/src/compositor/compositor.ts b/packages/renderer/src/compositor/compositor.tsindex b1281878c3..73f542206d 100644--- a/packages/renderer/src/compositor/compositor.ts+++ b/packages/renderer/src/compositor/compositor.ts@@ -33,21 +33,24 @@ export const startLongRunningCompositor = ({maximumFrameCacheItemsInBytes,logLevel,indent,+ binariesDirectory,}: {maximumFrameCacheItemsInBytes: number | null;logLevel: LogLevel;indent: boolean;+ binariesDirectory: string | null;}) => {- return startCompositor(- 'StartLongRunningProcess',- {+ return startCompositor({+ type: 'StartLongRunningProcess',+ payload: {concurrency: getActualConcurrency(null),maximum_frame_cache_size_in_bytes: maximumFrameCacheItemsInBytes,verbose: isEqualOrBelowLogLevel(logLevel, 'verbose'),},logLevel,indent,- );+ binariesDirectory,+ });};type RunningStatus =@@ -64,13 +67,25 @@ type RunningStatus =signal: NodeJS.Signals | null;};-export const startCompositor = <T extends keyof CompositorCommand>(- type: T,- payload: CompositorCommand[T],- logLevel: LogLevel,- indent: boolean,-): Compositor => {- const bin = getExecutablePath('compositor', indent, logLevel);+export const startCompositor = <T extends keyof CompositorCommand>({+ type,+ payload,+ logLevel,+ indent,+ binariesDirectory = null,+}: {+ type: T;+ payload: CompositorCommand[T];+ logLevel: LogLevel;+ indent: boolean;+ binariesDirectory: string | null;+}): Compositor => {+ const bin = getExecutablePath({+ type: 'compositor',+ indent,+ logLevel,+ binariesDirectory,+ });if (!process.env.READ_ONLY_FS) {chmodSync(bin, 0o755);}diff --git a/packages/renderer/src/compositor/get-executable-path.ts b/packages/renderer/src/compositor/get-executable-path.tsindex 2f0a767727..8ca1c08084 100644--- a/packages/renderer/src/compositor/get-executable-path.ts+++ b/packages/renderer/src/compositor/get-executable-path.ts@@ -31,12 +31,18 @@ export function isMusl({return !glibcVersionRuntime;}-export const getExecutablePath = (- type: 'compositor' | 'ffmpeg' | 'ffprobe',- indent: boolean,- logLevel: LogLevel,-): string => {- const base = getExecutableDir(indent, logLevel);+export const getExecutablePath = ({+ indent,+ logLevel,+ type,+ binariesDirectory,+}: {+ type: 'compositor' | 'ffmpeg' | 'ffprobe';+ indent: boolean;+ logLevel: LogLevel;+ binariesDirectory: string | null;+}): string => {+ const base = binariesDirectory ?? getExecutableDir(indent, logLevel);switch (type) {case 'compositor':if (process.platform === 'win32') {diff --git a/packages/renderer/src/copy-to-clipboard.ts b/packages/renderer/src/copy-to-clipboard.tsindex fa80e364d3..10ed026a44 100644--- a/packages/renderer/src/copy-to-clipboard.ts+++ b/packages/renderer/src/copy-to-clipboard.ts@@ -1,11 +1,16 @@import {startLongRunningCompositor} from './compositor/compositor';import type {LogLevel} from './log-level';-export const copyImageToClipboard = async (src: string, logLevel: LogLevel) => {+export const copyImageToClipboard = async (+ src: string,+ logLevel: LogLevel,+ binariesDirectory: string | null,+) => {const compositor = startLongRunningCompositor({maximumFrameCacheItemsInBytes: null,logLevel,indent: false,+ binariesDirectory,});await compositor.executeCommand('CopyImageToClipboard', {diff --git a/packages/renderer/src/create-silent-audio.ts b/packages/renderer/src/create-silent-audio.tsindex 282638c8ae..b750e35d1f 100644--- a/packages/renderer/src/create-silent-audio.ts+++ b/packages/renderer/src/create-silent-audio.ts@@ -7,11 +7,13 @@ export const createSilentAudio = async ({outName,indent,logLevel,+ binariesDirectory,}: {numberOfSeconds: number;outName: string;indent: boolean;logLevel: LogLevel;+ binariesDirectory: string | null;}) => {await callFf({bin: 'ffmpeg',@@ -30,5 +32,6 @@ export const createSilentAudio = async ({],indent,logLevel,+ binariesDirectory,});};diff --git a/packages/renderer/src/extract-audio.ts b/packages/renderer/src/extract-audio.tsindex dd8996a9d3..f527707e33 100644--- a/packages/renderer/src/extract-audio.ts+++ b/packages/renderer/src/extract-audio.ts@@ -5,11 +5,13 @@ export const extractAudio = async (options: {videoSource: string;audioOutput: string;logLevel?: LogLevel;+ binariesDirectory?: string | null;}) => {const compositor = startLongRunningCompositor({maximumFrameCacheItemsInBytes: null,logLevel: options?.logLevel ?? 'info',indent: false,+ binariesDirectory: options.binariesDirectory ?? null,});await compositor.executeCommand('ExtractAudio', {input_path: options.videoSource,diff --git a/packages/renderer/src/get-compositions.ts b/packages/renderer/src/get-compositions.tsindex ce73b66aee..3ee8ae93e1 100644--- a/packages/renderer/src/get-compositions.ts+++ b/packages/renderer/src/get-compositions.ts@@ -159,6 +159,7 @@ const internalGetCompositionsRaw = async ({timeoutInMilliseconds,logLevel,offthreadVideoCacheSizeInBytes,+ binariesDirectory,}: InternalGetCompositionsOptions) => {const {page, cleanup: cleanupPage} = await getPageAndCleanupFn({passedInInstance: puppeteerInstance,@@ -192,6 +193,7 @@ const internalGetCompositionsRaw = async ({logLevel,indent,offthreadVideoCacheSizeInBytes,+ binariesDirectory,},{onDownload: () => undefined,@@ -216,6 +218,7 @@ const internalGetCompositionsRaw = async ({indent,logLevel,offthreadVideoCacheSizeInBytes,+ binariesDirectory,});})@@ -282,5 +285,6 @@ export const getCompositions = (logLevel: logLevel ?? 'info',offthreadVideoCacheSizeInBytes:config?.offthreadVideoCacheSizeInBytes ?? null,+ binariesDirectory: config?.binariesDirectory ?? null,});};diff --git a/packages/renderer/src/get-silent-parts.ts b/packages/renderer/src/get-silent-parts.tsindex 609f3e4339..e49f5f169e 100644--- a/packages/renderer/src/get-silent-parts.ts+++ b/packages/renderer/src/get-silent-parts.ts@@ -11,16 +11,19 @@ export const getSilentParts = async ({noiseThresholdInDecibels: passedNoiseThresholdInDecibels,minDurationInSeconds: passedMinDuration,logLevel,+ binariesDirectory,}: {src: string;minDurationInSeconds?: number;logLevel?: LogLevel;noiseThresholdInDecibels?: number;+ binariesDirectory?: string | null;}): Promise<GetSilentPartsResponse> => {const compositor = startLongRunningCompositor({maximumFrameCacheItemsInBytes: null,logLevel: logLevel ?? 'info',indent: false,+ binariesDirectory: binariesDirectory ?? null,});const minDurationInSeconds = passedMinDuration ?? 1;diff --git a/packages/renderer/src/get-video-metadata.ts b/packages/renderer/src/get-video-metadata.tsindex 0847c6b467..1d026fdcd0 100644--- a/packages/renderer/src/get-video-metadata.ts+++ b/packages/renderer/src/get-video-metadata.ts@@ -12,6 +12,7 @@ export const getVideoMetadata = async (maximumFrameCacheItemsInBytes: null,logLevel: options?.logLevel ?? 'info',indent: false,+ binariesDirectory: null,});const metadataResponse = await compositor.executeCommand('GetVideoMetadata', {src: videoSource,diff --git a/packages/renderer/src/guess-extension-for-media.ts b/packages/renderer/src/guess-extension-for-media.tsindex cd015102e2..329863e27a 100644--- a/packages/renderer/src/guess-extension-for-media.ts+++ b/packages/renderer/src/guess-extension-for-media.ts@@ -5,16 +5,19 @@ export const guessExtensionForVideo = async ({src,indent,logLevel,+ binariesDirectory,}: {src: string;indent: boolean;logLevel: LogLevel;+ binariesDirectory: string | null;}) => {const {stderr} = await callFf({bin: 'ffprobe',args: [src],indent,logLevel,+ binariesDirectory,});if (stderr.includes('Audio: mp3,')) {return 'mp3';diff --git a/packages/renderer/src/merge-audio-track.ts b/packages/renderer/src/merge-audio-track.tsindex ae3f2cf165..7df25d8dae 100644--- a/packages/renderer/src/merge-audio-track.ts+++ b/packages/renderer/src/merge-audio-track.ts@@ -20,6 +20,7 @@ type Options = {remotionRoot: string;indent: boolean;logLevel: LogLevel;+ binariesDirectory: string | null;};const mergeAudioTrackUnlimited = async ({@@ -30,6 +31,7 @@ const mergeAudioTrackUnlimited = async ({remotionRoot,indent,logLevel,+ binariesDirectory,}: Options): Promise<void> => {if (files.length === 0) {await createSilentAudio({@@ -37,6 +39,7 @@ const mergeAudioTrackUnlimited = async ({numberOfSeconds,indent,logLevel,+ binariesDirectory,});return;}@@ -60,6 +63,7 @@ const mergeAudioTrackUnlimited = async ({remotionRoot,indent,logLevel,+ binariesDirectory,});return chunkOutname;}),@@ -79,6 +83,7 @@ const mergeAudioTrackUnlimited = async ({remotionRoot,indent,logLevel,+ binariesDirectory,});return;} finally {@@ -101,7 +106,13 @@ const mergeAudioTrackUnlimited = async ({].filter(truthy).flat(2);- const task = callFf({bin: 'ffmpeg', args, indent, logLevel});+ const task = callFf({+ bin: 'ffmpeg',+ args,+ indent,+ logLevel,+ binariesDirectory,+ });await task;cleanup();};diff --git a/packages/renderer/src/offthread-video-server.ts b/packages/renderer/src/offthread-video-server.tsindex ef27648147..e7e758c285 100644--- a/packages/renderer/src/offthread-video-server.ts+++ b/packages/renderer/src/offthread-video-server.ts@@ -53,28 +53,31 @@ export const startOffthreadVideoServer = ({logLevel,indent,offthreadVideoCacheSizeInBytes,+ binariesDirectory,}: {downloadMap: DownloadMap;offthreadVideoCacheSizeInBytes: number | null;concurrency: number;logLevel: LogLevel;indent: boolean;+ binariesDirectory: string | null;}): {listener: RequestListener;close: () => Promise<void>;compositor: Compositor;} => {validateOffthreadVideoCacheSizeInBytes(offthreadVideoCacheSizeInBytes);- const compositor = startCompositor(- 'StartLongRunningProcess',- {+ const compositor = startCompositor({+ type: 'StartLongRunningProcess',+ payload: {concurrency,maximum_frame_cache_size_in_bytes: offthreadVideoCacheSizeInBytes,verbose: isEqualOrBelowLogLevel(logLevel, 'verbose'),},logLevel,indent,- );+ binariesDirectory,+ });return {close: async () => {diff --git a/packages/renderer/src/options/binaries-directory.tsx b/packages/renderer/src/options/binaries-directory.tsxnew file mode 100644index 0000000000..382ced1888--- /dev/null+++ b/packages/renderer/src/options/binaries-directory.tsx@@ -0,0 +1,46 @@+import type {AnyRemotionOption} from './option';++const cliFlag = 'binaries-directory' as const;++let currentDirectory: string | null = null;++export const binariesDirectoryOption = {+ name: 'Binaries Directory',+ cliFlag,+ description: () => (+ <>+ The directory where the platform-specific binaries and libraries needed+ for Remotion are located. Those include an <code>FFmpeg</code> and{' '}+ <code>ffprobe</code> binary, a Rust binary for various Remotion tasks, and+ various shared libraries. If the value is set to <code>null</code>, which+ is the default, then the path of a platform-specific package located at{' '}+ <code>node_modules/@remotion/compositor-*</code> is selected.+ </>+ ),+ ssrName: 'binariesDirectory' as const,+ docLink: 'https://www.remotion.dev/docs/renderer',+ type: '' as string | null,+ getValue: ({commandLine}) => {+ if (commandLine[cliFlag] !== undefined) {+ return {+ source: 'cli',+ value: commandLine[cliFlag] as string | null,+ };+ }++ if (currentDirectory !== null) {+ return {+ source: 'config',+ value: currentDirectory,+ };+ }++ return {+ source: 'default',+ value: null,+ };+ },+ setConfig: (value: string | null) => {+ currentDirectory = value;+ },+} satisfies AnyRemotionOption<string | null>;diff --git a/packages/renderer/src/options/index.tsx b/packages/renderer/src/options/index.tsxindex d68da9e1fe..11eb746060 100644--- a/packages/renderer/src/options/index.tsx+++ b/packages/renderer/src/options/index.tsx@@ -1,5 +1,6 @@import {audioBitrateOption} from './audio-bitrate';import {beepOnFinishOption} from './beep-on-finish';+import {binariesDirectoryOption} from './binaries-directory';import {colorSpaceOption} from './color-space';import {crfOption} from './crf';import {deleteAfterOption} from './delete-after';@@ -53,6 +54,7 @@ export const allOptions = {delayRenderTimeoutInMillisecondsOption,headlessOption,overwriteOption,+ binariesDirectoryOption,};export type AvailableOptions = keyof typeof allOptions;diff --git a/packages/renderer/src/options/options-map.ts b/packages/renderer/src/options/options-map.tsindex c1dd00a0e0..ee0f57f452 100644--- a/packages/renderer/src/options/options-map.ts+++ b/packages/renderer/src/options/options-map.ts@@ -1,4 +1,5 @@import {audioBitrateOption} from './audio-bitrate';+import {binariesDirectoryOption} from './binaries-directory';import {colorSpaceOption} from './color-space';import {crfOption} from './crf';import {deleteAfterOption} from './delete-after';@@ -33,28 +34,33 @@ export const optionsMap = {muted: mutedOption,logLevel: logLevelOption,timeoutInMilliseconds: delayRenderTimeoutInMillisecondsOption,+ binariesDirectory: binariesDirectoryOption,},renderStill: {offthreadVideoCacheSizeInBytes: offthreadVideoCacheSizeInBytesOption,jpegQuality: jpegQualityOption,logLevel: logLevelOption,timeoutInMilliseconds: delayRenderTimeoutInMillisecondsOption,+ binariesDirectory: binariesDirectoryOption,},getCompositions: {offthreadVideoCacheSizeInBytes: offthreadVideoCacheSizeInBytesOption,logLevel: logLevelOption,timeoutInMilliseconds: delayRenderTimeoutInMillisecondsOption,+ binariesDirectory: binariesDirectoryOption,},selectComposition: {offthreadVideoCacheSizeInBytes: offthreadVideoCacheSizeInBytesOption,logLevel: logLevelOption,timeoutInMilliseconds: delayRenderTimeoutInMillisecondsOption,+ binariesDirectory: binariesDirectoryOption,},renderFrames: {offthreadVideoCacheSizeInBytes: offthreadVideoCacheSizeInBytesOption,jpegQuality: jpegQualityOption,logLevel: logLevelOption,timeoutInMilliseconds: delayRenderTimeoutInMillisecondsOption,+ binariesDirectory: binariesDirectoryOption,},renderMediaOnLambda: {offthreadVideoCacheSizeInBytes: offthreadVideoCacheSizeInBytesOption,diff --git a/packages/renderer/src/prepare-server.ts b/packages/renderer/src/prepare-server.tsindex 44ae9a2ef0..be3d7505b5 100644--- a/packages/renderer/src/prepare-server.ts+++ b/packages/renderer/src/prepare-server.ts@@ -36,6 +36,7 @@ type PrepareServerOptions = {logLevel: LogLevel;indent: boolean;offthreadVideoCacheSizeInBytes: number | null;+ binariesDirectory: string | null;};export const prepareServer = async ({@@ -46,6 +47,7 @@ export const prepareServer = async ({logLevel,indent,offthreadVideoCacheSizeInBytes,+ binariesDirectory,}: PrepareServerOptions): Promise<RemotionServer> => {const downloadMap = makeDownloadMap();Log.verbose(@@ -67,6 +69,7 @@ export const prepareServer = async ({logLevel,indent,offthreadVideoCacheSizeInBytes,+ binariesDirectory,});let remoteSourceMap: AnySourceMapConsumer | null = null;@@ -139,6 +142,7 @@ export const prepareServer = async ({logLevel,indent,offthreadVideoCacheSizeInBytes,+ binariesDirectory,});return Promise.resolve({diff --git a/packages/renderer/src/preprocess-audio-track.ts b/packages/renderer/src/preprocess-audio-track.tsindex 452e8b0f35..5451da2b84 100644--- a/packages/renderer/src/preprocess-audio-track.ts+++ b/packages/renderer/src/preprocess-audio-track.ts@@ -18,6 +18,7 @@ type Options = {downloadMap: DownloadMap;indent: boolean;logLevel: LogLevel;+ binariesDirectory: string | null;};export type PreprocessedAudioTrack = {@@ -33,13 +34,15 @@ const preprocessAudioTrackUnlimited = async ({downloadMap,indent,logLevel,+ binariesDirectory,}: Options): Promise<PreprocessedAudioTrack | null> => {- const {channels, duration} = await getAudioChannelsAndDuration(+ const {channels, duration} = await getAudioChannelsAndDuration({downloadMap,- resolveAssetSrc(asset.src),+ src: resolveAssetSrc(asset.src),indent,logLevel,- );+ binariesDirectory,+ });const filter = calculateFfmpegFilter({asset,@@ -64,7 +67,7 @@ const preprocessAudioTrackUnlimited = async ({['-y', outName],].flat(2);- await callFf({bin: 'ffmpeg', args, indent, logLevel});+ await callFf({bin: 'ffmpeg', args, indent, logLevel, binariesDirectory});cleanup();return {outName, filter};diff --git a/packages/renderer/src/prespawn-ffmpeg.ts b/packages/renderer/src/prespawn-ffmpeg.tsindex d664842162..1d1b981dd8 100644--- a/packages/renderer/src/prespawn-ffmpeg.ts+++ b/packages/renderer/src/prespawn-ffmpeg.ts@@ -54,6 +54,7 @@ type PreStitcherOptions = {encodingBufferSize: string | null;indent: boolean;colorSpace: ColorSpace;+ binariesDirectory: string | null;};export const prespawnFfmpeg = (options: PreStitcherOptions) => {@@ -136,6 +137,7 @@ export const prespawnFfmpeg = (options: PreStitcherOptions) => {args: finalFfmpegString,indent: options.indent,logLevel: options.logLevel,+ binariesDirectory: options.binariesDirectory,});options.signal(() => {diff --git a/packages/renderer/src/render-frames.ts b/packages/renderer/src/render-frames.tsindex af93ad07cc..fd9b2fe255 100644--- a/packages/renderer/src/render-frames.ts+++ b/packages/renderer/src/render-frames.ts@@ -620,6 +620,7 @@ const internalRenderFramesRaw = ({serializedResolvedPropsWithCustomSchema,offthreadVideoCacheSizeInBytes,parallelEncodingEnabled,+ binariesDirectory,}: InternalRenderFramesOptions): Promise<RenderFramesOutput> => {validateDimension(composition.height,@@ -685,6 +686,7 @@ const internalRenderFramesRaw = ({logLevel,indent,offthreadVideoCacheSizeInBytes,+ binariesDirectory,},{onDownload,@@ -741,6 +743,7 @@ const internalRenderFramesRaw = ({serializedInputPropsWithCustomSchema,serializedResolvedPropsWithCustomSchema,parallelEncodingEnabled,+ binariesDirectory,});}),])@@ -823,6 +826,7 @@ export const renderFrames = (quality,logLevel,offthreadVideoCacheSizeInBytes,+ binariesDirectory,} = options;if (!composition) {@@ -883,5 +887,6 @@ export const renderFrames = (server: undefined,offthreadVideoCacheSizeInBytes: offthreadVideoCacheSizeInBytes ?? null,parallelEncodingEnabled: false,+ binariesDirectory: binariesDirectory ?? null,});};diff --git a/packages/renderer/src/render-media.ts b/packages/renderer/src/render-media.tsindex f9a1d2b101..43cd854911 100644--- a/packages/renderer/src/render-media.ts+++ b/packages/renderer/src/render-media.ts@@ -123,6 +123,7 @@ export type InternalRenderMediaOptions = {serveUrl: string;concurrency: number | string | null;finishRenderProgress: () => void;+ binariesDirectory: string | null;} & MoreRenderMediaOptions;type Prettify<T> = {@@ -177,6 +178,7 @@ export type RenderMediaOptions = Prettify<{concurrency?: number | string | null;colorSpace?: ColorSpace;repro?: boolean;+ binariesDirectory?: string | null;}> &Partial<MoreRenderMediaOptions>;@@ -235,6 +237,7 @@ const internalRenderMediaRaw = ({colorSpace,repro,finishRenderProgress,+ binariesDirectory,}: InternalRenderMediaOptions): Promise<RenderMediaResult> => {if (repro) {enableRepro({@@ -471,6 +474,7 @@ const internalRenderMediaRaw = ({indent,x264Preset: x264Preset ?? null,colorSpace,+ binariesDirectory,});stitcherFfmpeg = preStitcher.task;}@@ -538,6 +542,7 @@ const internalRenderMediaRaw = ({webpackConfigOrServeUrl: serveUrl,offthreadVideoCacheSizeInBytes:offthreadVideoCacheSizeInBytes ?? null,+ binariesDirectory,},{onDownload,@@ -618,6 +623,7 @@ const internalRenderMediaRaw = ({serializedResolvedPropsWithCustomSchema,offthreadVideoCacheSizeInBytes,parallelEncodingEnabled: parallelEncoding,+ binariesDirectory,});return renderFramesProc;@@ -682,6 +688,7 @@ const internalRenderMediaRaw = ({audioCodec,x264Preset: x264Preset ?? null,colorSpace,+ binariesDirectory,}),stitchStart,]);@@ -829,6 +836,7 @@ export const renderMedia = ({offthreadVideoCacheSizeInBytes,colorSpace,repro,+ binariesDirectory,}: RenderMediaOptions): Promise<RenderMediaResult> => {if (quality !== undefined) {console.warn(@@ -894,5 +902,6 @@ export const renderMedia = ({colorSpace: colorSpace ?? 'default',repro: repro ?? false,finishRenderProgress: () => undefined,+ binariesDirectory: binariesDirectory ?? null,});};diff --git a/packages/renderer/src/render-still.ts b/packages/renderer/src/render-still.tsindex 52ff46e84d..91fd30d204 100644--- a/packages/renderer/src/render-still.ts+++ b/packages/renderer/src/render-still.ts@@ -349,6 +349,7 @@ const internalRenderStillRaw = (logLevel: options.logLevel,indent: options.indent,offthreadVideoCacheSizeInBytes: options.offthreadVideoCacheSizeInBytes,+ binariesDirectory: options.binariesDirectory,},{onDownload: options.onDownload,@@ -433,6 +434,7 @@ export const renderStill = (quality,offthreadVideoCacheSizeInBytes,logLevel,+ binariesDirectory,} = options;if (typeof jpegQuality !== 'undefined' && imageFormat !== 'jpeg') {@@ -481,5 +483,6 @@ export const renderStill = (data: composition.props ?? {},}).serializedString,offthreadVideoCacheSizeInBytes: offthreadVideoCacheSizeInBytes ?? null,+ binariesDirectory: binariesDirectory ?? null,});};diff --git a/packages/renderer/src/select-composition.ts b/packages/renderer/src/select-composition.tsindex 0195e7d10a..ae07d9a861 100644--- a/packages/renderer/src/select-composition.ts+++ b/packages/renderer/src/select-composition.ts@@ -48,7 +48,7 @@ export type SelectCompositionOptions = {verbose?: boolean;serveUrl: string;id: string;-} & Partial<ToOptions<typeof optionsMap.renderStill>>;+} & Partial<ToOptions<typeof optionsMap.selectComposition>>;type CleanupFn = () => Promise<unknown>;@@ -194,6 +194,7 @@ export const internalSelectCompositionRaw = async (server,timeoutInMilliseconds,offthreadVideoCacheSizeInBytes,+ binariesDirectory,} = options;const {page, cleanup: cleanupPage} = await getPageAndCleanupFn({@@ -227,6 +228,7 @@ export const internalSelectCompositionRaw = async (logLevel,indent,offthreadVideoCacheSizeInBytes,+ binariesDirectory,},{onDownload: () => undefined,@@ -253,6 +255,7 @@ export const internalSelectCompositionRaw = async (puppeteerInstance,server,offthreadVideoCacheSizeInBytes,+ binariesDirectory,});})@@ -299,6 +302,7 @@ export const selectComposition = async (verbose,logLevel,offthreadVideoCacheSizeInBytes,+ binariesDirectory,} = options;const data = await internalSelectComposition({@@ -321,6 +325,7 @@ export const selectComposition = async (indent: false,server: undefined,offthreadVideoCacheSizeInBytes: offthreadVideoCacheSizeInBytes ?? null,+ binariesDirectory: binariesDirectory ?? null,});return data.metadata;};diff --git a/packages/renderer/src/serve-static.ts b/packages/renderer/src/serve-static.tsindex e244f20710..7668857c0f 100644--- a/packages/renderer/src/serve-static.ts+++ b/packages/renderer/src/serve-static.ts@@ -18,6 +18,7 @@ export const serveStatic = async (logLevel: LogLevel;indent: boolean;offthreadVideoCacheSizeInBytes: number | null;+ binariesDirectory: string | null;},): Promise<{port: number;@@ -34,6 +35,7 @@ export const serveStatic = async (logLevel: options.logLevel,indent: options.indent,offthreadVideoCacheSizeInBytes: options.offthreadVideoCacheSizeInBytes,+ binariesDirectory: options.binariesDirectory,});const connections: Record<string, Socket> = {};diff --git a/packages/renderer/src/stitch-frames-to-video.ts b/packages/renderer/src/stitch-frames-to-video.tsindex 2fa1514f3c..5fb300609b 100644--- a/packages/renderer/src/stitch-frames-to-video.ts+++ b/packages/renderer/src/stitch-frames-to-video.ts@@ -77,6 +77,7 @@ type InternalStitchFramesToVideoOptions = {enforceAudioTrack: boolean;ffmpegOverride: null | FfmpegOverrideFn;colorSpace: ColorSpace;+ binariesDirectory: string | null;};export type StitchFramesToVideoOptions = {@@ -105,6 +106,7 @@ export type StitchFramesToVideoOptions = {ffmpegOverride?: FfmpegOverrideFn;x264Preset?: X264Preset | null;colorSpace?: ColorSpace;+ binariesDirectory?: string | null;};type ReturnType = Promise<Buffer | null>;@@ -119,6 +121,7 @@ const getAssetsData = async ({downloadMap,remotionRoot,indent,+ binariesDirectory,}: {assets: TRenderAsset[][];onDownload: RenderMediaOnDownload | undefined;@@ -129,6 +132,7 @@ const getAssetsData = async ({downloadMap: DownloadMap;remotionRoot: string;indent: boolean;+ binariesDirectory: string | null;}): Promise<string> => {const fileUrlAssets = await convertAssetsToFileUrls({assets,@@ -167,6 +171,7 @@ const getAssetsData = async ({downloadMap,indent,logLevel,+ binariesDirectory,});preprocessProgress[index] = 1;updateProgress();@@ -185,6 +190,7 @@ const getAssetsData = async ({remotionRoot,indent,logLevel,+ binariesDirectory,});onProgress(1);@@ -227,6 +233,7 @@ const innerStitchFramesToVideo = async (onProgress,x264Preset,colorSpace,+ binariesDirectory,}: InternalStitchFramesToVideoOptions,remotionRoot: string,): Promise<ReturnType> => {@@ -353,6 +360,7 @@ const innerStitchFramesToVideo = async (downloadMap: assetsInfo.downloadMap,remotionRoot,indent,+ binariesDirectory,}): null;@@ -377,6 +385,7 @@ const innerStitchFramesToVideo = async (].filter(NoReactInternals.truthy),indent,logLevel,+ binariesDirectory,});cancelSignal?.(() => {@@ -475,6 +484,7 @@ const innerStitchFramesToVideo = async (args: finalFfmpegString,indent,logLevel,+ binariesDirectory,});cancelSignal?.(() => {task.kill();@@ -584,6 +594,7 @@ export const stitchFramesToVideo = ({encodingBufferSize,x264Preset,colorSpace,+ binariesDirectory,}: StitchFramesToVideoOptions): Promise<Buffer | null> => {return internalStitchFramesToVideo({assetsInfo,@@ -614,5 +625,6 @@ export const stitchFramesToVideo = ({preferLossless: false,x264Preset: x264Preset ?? null,colorSpace: colorSpace ?? 'default',+ binariesDirectory: binariesDirectory ?? null,});};diff --git a/packages/renderer/src/test/compositor-rust.test.ts b/packages/renderer/src/test/compositor-rust.test.tsindex 0a48c96c68..eac4095a8f 100644--- a/packages/renderer/src/test/compositor-rust.test.ts+++ b/packages/renderer/src/test/compositor-rust.test.ts@@ -8,6 +8,7 @@ test(maximumFrameCacheItemsInBytes: null,logLevel: 'info',indent: false,+ binariesDirectory: null,});const matching = await Promise.all(diff --git a/packages/renderer/src/test/compositor.test.ts b/packages/renderer/src/test/compositor.test.tsindex a58e3fdc8a..0d0c093399 100644--- a/packages/renderer/src/test/compositor.test.ts+++ b/packages/renderer/src/test/compositor.test.ts@@ -12,16 +12,17 @@ test('Should handle the overlay', async () => {invalid: 'json',},];- const compositor = startCompositor(- 'StartLongRunningProcess',- {+ const compositor = startCompositor({+ type: 'StartLongRunningProcess',+ payload: {concurrency: 2,maximum_frame_cache_size_in_bytes: 100,verbose: false,},- 'info',- false,- );+ logLevel: 'info',+ indent: false,+ binariesDirectory: null,+ });await composeWithoutCache({height: 1080,@@ -55,16 +56,17 @@ test('Should handle valid', async () => {},];- const compositor = startCompositor(- 'StartLongRunningProcess',- {+ const compositor = startCompositor({+ type: 'StartLongRunningProcess',+ payload: {concurrency: 2,maximum_frame_cache_size_in_bytes: 100,verbose: false,},- 'info',- false,- );+ logLevel: 'info',+ indent: false,+ binariesDirectory: null,+ });const output = path.join(__dirname, 'test.png');diff --git a/packages/renderer/src/test/extract-frame-rust.test.ts b/packages/renderer/src/test/extract-frame-rust.test.tsindex 83ec50358b..8f91c733c1 100644--- a/packages/renderer/src/test/extract-frame-rust.test.ts+++ b/packages/renderer/src/test/extract-frame-rust.test.ts@@ -12,6 +12,7 @@ test(maximumFrameCacheItemsInBytes: null,logLevel: 'info',indent: false,+ binariesDirectory: null,});const data = await compositor.executeCommand('ExtractFrame', {@@ -47,6 +48,7 @@ test(maximumFrameCacheItemsInBytes: null,logLevel: 'info',indent: false,+ binariesDirectory: null,});const data = await compositor.executeCommand('ExtractFrame', {@@ -82,12 +84,14 @@ test('Should be able to start two compositors', async () => {maximumFrameCacheItemsInBytes: null,logLevel: 'info',indent: false,+ binariesDirectory: null,});const compositor2 = startLongRunningCompositor({maximumFrameCacheItemsInBytes: null,logLevel: 'info',indent: false,+ binariesDirectory: null,});await compositor.executeCommand('ExtractFrame', {@@ -111,6 +115,7 @@ test('Should be able to seek backwards', async () => {maximumFrameCacheItemsInBytes: null,logLevel: 'info',indent: false,+ binariesDirectory: null,});const data = await compositor.executeCommand('ExtractFrame', {@@ -141,6 +146,7 @@ test(maximumFrameCacheItemsInBytes: null,logLevel: 'info',indent: false,+ binariesDirectory: null,});const data = await compositor.executeCommand('ExtractFrame', {@@ -165,6 +171,7 @@ test(maximumFrameCacheItemsInBytes: null,logLevel: 'info',indent: false,+ binariesDirectory: null,});const data = await compositor.executeCommand('ExtractFrame', {@@ -198,6 +205,7 @@ test(maximumFrameCacheItemsInBytes: null,logLevel: 'info',indent: false,+ binariesDirectory: null,});const data = await compositor.executeCommand('ExtractFrame', {@@ -225,6 +233,7 @@ test('Should be able to extract a frame with abnormal DAR', async () => {maximumFrameCacheItemsInBytes: null,logLevel: 'info',indent: false,+ binariesDirectory: null,});const data = await compositor.executeCommand('ExtractFrame', {@@ -256,6 +265,7 @@ test('Should be able to extract the frames in reverse order', async () => {maximumFrameCacheItemsInBytes: null,logLevel: 'info',indent: false,+ binariesDirectory: null,});let prevPixel = '';@@ -301,6 +311,7 @@ test('Last frame should be fast', async () => {maximumFrameCacheItemsInBytes: null,logLevel: 'info',indent: false,+ binariesDirectory: null,});const time = Date.now();@@ -368,6 +379,7 @@ test('Should get from a screen recording', async () => {maximumFrameCacheItemsInBytes: null,logLevel: 'info',indent: false,+ binariesDirectory: null,});const data = await compositor.executeCommand('ExtractFrame', {@@ -389,6 +401,7 @@ test('Should get from video with no fps', async () => {maximumFrameCacheItemsInBytes: null,logLevel: 'info',indent: false,+ binariesDirectory: null,});const data = await compositor.executeCommand('ExtractFrame', {@@ -410,6 +423,7 @@ test('Should get from broken webcam video', async () => {maximumFrameCacheItemsInBytes: null,logLevel: 'info',indent: false,+ binariesDirectory: null,});const data = await compositor.executeCommand('ExtractFrame', {@@ -431,6 +445,7 @@ test('Should get from iPhone video', async () => {maximumFrameCacheItemsInBytes: null,logLevel: 'info',indent: false,+ binariesDirectory: null,});const data = await compositor.executeCommand('ExtractFrame', {@@ -452,6 +467,7 @@ test('Should get from AV1 video', async () => {maximumFrameCacheItemsInBytes: null,logLevel: 'info',indent: false,+ binariesDirectory: null,});const data = await compositor.executeCommand('ExtractFrame', {@@ -473,6 +489,7 @@ test('Should handle getting a frame from a WebM when it is not transparent', asymaximumFrameCacheItemsInBytes: null,logLevel: 'info',indent: false,+ binariesDirectory: null,});const data = await compositor.executeCommand('ExtractFrame', {@@ -498,6 +515,7 @@ test('Should handle a video with no frames at the beginning', async () => {maximumFrameCacheItemsInBytes: null,logLevel: 'info',indent: false,+ binariesDirectory: null,});const data = await compositor.executeCommand('ExtractFrame', {@@ -523,6 +541,7 @@ test('Two different starting times should not result in big seeking', async () =maximumFrameCacheItemsInBytes: 300 * 1024 * 1024,logLevel: 'info',indent: false,+ binariesDirectory: null,});const expected = [];@@ -631,6 +650,7 @@ test('Should not duplicate frames for iphoneVideo', async () => {maximumFrameCacheItemsInBytes: 500,logLevel: 'info',indent: false,+ binariesDirectory: null,});const firstFrame = await compositor.executeCommand('ExtractFrame', {diff --git a/packages/renderer/src/test/get-audio-channels.test.ts b/packages/renderer/src/test/get-audio-channels.test.tsindex 57d9ac3192..8abef34b30 100644--- a/packages/renderer/src/test/get-audio-channels.test.ts+++ b/packages/renderer/src/test/get-audio-channels.test.ts@@ -23,6 +23,7 @@ test('Get audio channels for video', async () => {videoWithoutAudio,false,'info',+ null,);expect(channels).toEqual({channels: 2, duration: 10});}, 90000);@@ -43,6 +44,7 @@ test('Get audio channels for video without music', async () => {videoWithAudio,false,'info',+ null,);expect(channels.channels).toEqual(0);@@ -62,12 +64,13 @@ test('Get audio channels for video with music', async () => {'sound1.mp3',);expect(existsSync(audio)).toEqual(true);- const channels = await getAudioChannelsAndDuration(+ const channels = await getAudioChannelsAndDuration({downloadMap,- audio,- false,- 'info',- );+ src: audio,+ indent: false,+ logLevel: 'info',+ binariesDirectory: null,+ });cleanDownloadMap(downloadMap);expect(channels).toEqual({channels: 2, duration: 56.529});@@ -78,7 +81,13 @@ test('Throw error if parsing a non video file', () => {const tsFile = path.join(__dirname, '..', 'can-use-parallel-encoding.ts');expect(existsSync(tsFile)).toEqual(true);expect(() =>- getAudioChannelsAndDuration(downloadMap, tsFile, false, 'info'),+ getAudioChannelsAndDuration({+ downloadMap,+ src: tsFile,+ indent: false,+ logLevel: 'info',+ binariesDirectory: null,+ }),).rejects.toThrow(/Invalid data found when processing input/);cleanDownloadMap(downloadMap);});diff --git a/packages/renderer/src/test/guess-extension-for-media.test.ts b/packages/renderer/src/test/guess-extension-for-media.test.tsindex 2be365712c..94b8ea4441 100644--- a/packages/renderer/src/test/guess-extension-for-media.test.ts+++ b/packages/renderer/src/test/guess-extension-for-media.test.ts@@ -15,6 +15,7 @@ test('Guess extension for media - H264', async () => {),indent: false,logLevel: 'info',+ binariesDirectory: null,});expect(extension).toBe('mp4');@@ -33,6 +34,7 @@ test('Guess extension for media - WebM', async () => {),indent: false,logLevel: 'info',+ binariesDirectory: null,});expect(extension).toBe('webm');@@ -51,6 +53,7 @@ test('Guess extension for media - WAV', async () => {),indent: false,logLevel: 'info',+ binariesDirectory: null,});expect(extension).toBe('wav');@@ -69,6 +72,7 @@ test('Guess extension for media - MP3', async () => {),indent: false,logLevel: 'info',+ binariesDirectory: null,});expect(extension).toBe('mp3');diff --git a/packages/renderer/src/test/rust-errors.test.ts b/packages/renderer/src/test/rust-errors.test.tsindex 2f5a13d6a3..58ad085129 100644--- a/packages/renderer/src/test/rust-errors.test.ts+++ b/packages/renderer/src/test/rust-errors.test.ts@@ -7,6 +7,7 @@ test('Should get Rust errors in a good way', async () => {maximumFrameCacheItemsInBytes: null,logLevel: 'info',indent: false,+ binariesDirectory: null,});try {@@ -32,6 +33,7 @@ test('Handle panics', async () => {maximumFrameCacheItemsInBytes: null,logLevel: 'info',indent: false,+ binariesDirectory: null,});try {@@ -72,7 +74,7 @@ test(const command = serializeCommand('DeliberatePanic', {});try {- await callCompositor(JSON.stringify(command), false, 'info');+ await callCompositor(JSON.stringify(command), false, 'info', null);throw new Error('should not be reached');} catch (err) {expect((err as Error).message).toContain("thread 'main' panicked");@@ -92,7 +94,7 @@ test(tone_mapped: false,});try {- await callCompositor(JSON.stringify(command), false, 'info');+ await callCompositor(JSON.stringify(command), false, 'info', null);throw new Error('should not be reached');} catch (err) {expect((err as Error).message).toContain(@@ -114,7 +116,7 @@ test('Invalid payloads will be handled', async () => {tone_mapped: false,});try {- await callCompositor(JSON.stringify(command), false, 'info');+ await callCompositor(JSON.stringify(command), false, 'info', null);} catch (err) {expect((err as Error).message).toContain('Compositor error: missing field `time`',diff --git a/packages/renderer/src/test/rust-get-video-metadata.test.ts b/packages/renderer/src/test/rust-get-video-metadata.test.tsindex 939144ab09..270094b7a6 100644--- a/packages/renderer/src/test/rust-get-video-metadata.test.ts+++ b/packages/renderer/src/test/rust-get-video-metadata.test.ts@@ -9,6 +9,7 @@ test('Should return video metadata', async () => {maximumFrameCacheItemsInBytes: null,logLevel: 'info',indent: false,+ binariesDirectory: null,});const videoFile = path.join(@@ -48,6 +49,7 @@ test('Should return an error due to non existing file', async () => {maximumFrameCacheItemsInBytes: null,logLevel: 'info',indent: false,+ binariesDirectory: null,});try {@@ -66,6 +68,7 @@ test('Should return an error due to using a audio file', async () => {maximumFrameCacheItemsInBytes: null,logLevel: 'info',indent: false,+ binariesDirectory: null,});const audioFile = path.join(diff --git a/packages/renderer/src/test/rust-memory-usage.test.ts b/packages/renderer/src/test/rust-memory-usage.test.tsindex 97c47520d7..b23deeacf6 100644--- a/packages/renderer/src/test/rust-memory-usage.test.ts+++ b/packages/renderer/src/test/rust-memory-usage.test.ts@@ -12,6 +12,7 @@ test('Memory usage should be determined ', async () => {maximumFrameCacheItemsInBytes: 40 * 24 * 1024 * 1024,logLevel: 'info',indent: false,+ binariesDirectory: null,});expect(@@ -102,6 +103,7 @@ test('Should respect the maximum frame cache limit', async () => {maximumFrameCacheItemsInBytes: 50 * 24 * 1024 * 1024,logLevel: 'info',indent: false,+ binariesDirectory: null,});await compositor.executeCommand('ExtractFrame', {@@ -130,6 +132,7 @@ test('Should be able to take commands for freeing up memory', async () => {maximumFrameCacheItemsInBytes: 100 * 24 * 1024 * 1024,logLevel: 'info',indent: false,+ binariesDirectory: null,});expect(