🎥 Make videos programmatically with React
Warn if Bun cannot determine musl or glibc and assume glibc
Jonny Burger1a049e536ba0
diff --git a/packages/cli/src/ffmpeg.ts b/packages/cli/src/ffmpeg.tsindex 8fd8f116e4..a20249b53c 100644--- a/packages/cli/src/ffmpeg.ts+++ b/packages/cli/src/ffmpeg.ts@@ -1,28 +1,33 @@import {RenderInternals} from '@remotion/renderer';import {spawnSync} from 'node:child_process';import {chmodSync} from 'node:fs';+import {ConfigInternals} from './config';export const ffmpegCommand = (_root: string, args: string[]) => {- const binary = RenderInternals.getExecutablePath('ffmpeg');+ const logLevel = ConfigInternals.Logging.getLogLevel();++ const binary = RenderInternals.getExecutablePath('ffmpeg', false, logLevel);if (!process.env.READ_ONLY_FS) {chmodSync(binary, 0o755);}const done = spawnSync(binary, args, {- ...RenderInternals.dynamicLibraryPathOptions(),+ ...RenderInternals.dynamicLibraryPathOptions(false, logLevel),stdio: 'inherit',});process.exit(done.status as number);};export const ffprobeCommand = (_root: string, args: string[]) => {- const binary = RenderInternals.getExecutablePath('ffprobe');+ const logLevel = ConfigInternals.Logging.getLogLevel();++ const binary = RenderInternals.getExecutablePath('ffprobe', false, logLevel);if (!process.env.READ_ONLY_FS) {chmodSync(binary, 0o755);}const done = spawnSync(binary, args, {- ...RenderInternals.dynamicLibraryPathOptions(),+ ...RenderInternals.dynamicLibraryPathOptions(false, logLevel),stdio: 'inherit',});process.exit(done.status as number);diff --git a/packages/it-tests/src/rendering/base64-audio.test.ts b/packages/it-tests/src/rendering/base64-audio.test.tsindex a089695993..18adc0dd19 100644--- a/packages/it-tests/src/rendering/base64-audio.test.ts+++ b/packages/it-tests/src/rendering/base64-audio.test.ts@@ -25,7 +25,12 @@ test("Should be able to render a MP3 audio file", async () => {const exists = fs.existsSync(outputPath);expect(exists).toBe(true);- const info = await RenderInternals.callFf("ffprobe", [outputPath]);+ const info = await RenderInternals.callFf(+ "ffprobe",+ [outputPath],+ false,+ "info"+ );const data = info.stderr;expect(data).toContain("mp3");expect(data).toContain("stereo");diff --git a/packages/it-tests/src/rendering/frame-accuracy-gif.test.ts b/packages/it-tests/src/rendering/frame-accuracy-gif.test.tsindex e7b9afaa16..bd3ff55eb4 100644--- a/packages/it-tests/src/rendering/frame-accuracy-gif.test.ts+++ b/packages/it-tests/src/rendering/frame-accuracy-gif.test.ts@@ -35,14 +35,19 @@ const getMissedFramesforCodec = async () => {});- await RenderInternals.callFf("ffmpeg", [- "-i",- outputPath,- "-f",- "image2",- path.join(outputDir, "out%2d.jpeg"),- "-y",- ]);+ await RenderInternals.callFf(+ "ffmpeg",+ [+ "-i",+ outputPath,+ "-f",+ "image2",+ path.join(outputDir, "out%2d.jpeg"),+ "-y",+ ],+ false,+ "info"+ );let missedFrames = 0;diff --git a/packages/it-tests/src/rendering/render-scale.test.ts b/packages/it-tests/src/rendering/render-scale.test.tsindex d5b3288738..3e5a2e060a 100644--- a/packages/it-tests/src/rendering/render-scale.test.ts+++ b/packages/it-tests/src/rendering/render-scale.test.ts@@ -38,7 +38,12 @@ test("Should be able to render video with scale 2", async () => {const exists = fs.existsSync(outputPath);expect(exists).toBe(true);- const info = await RenderInternals.callFf("ffprobe", [outputPath]);+ const info = await RenderInternals.callFf(+ "ffprobe",+ [outputPath],+ false,+ "info"+ );const data = info.stderr;expect(data).toContain("Video: h264");expect(data).toContain("yuv420p");@@ -72,7 +77,12 @@ test("Should be able to render video with scale 0.1", async () => {const exists = fs.existsSync(outputPath);expect(exists).toBe(true);- const info = await RenderInternals.callFf("ffprobe", [outputPath]);+ const info = await RenderInternals.callFf(+ "ffprobe",+ [outputPath],+ false,+ "info"+ );const data = info.stderr;expect(data).toContain("Video: h264");expect(data).toContain("yuv420p");diff --git a/packages/it-tests/src/rendering/rendering.test.ts b/packages/it-tests/src/rendering/rendering.test.tsindex b5ea8145f1..d609938d47 100644--- a/packages/it-tests/src/rendering/rendering.test.ts+++ b/packages/it-tests/src/rendering/rendering.test.ts@@ -35,7 +35,12 @@ test("Should be able to render video with custom port", async () => {const exists = fs.existsSync(outputPath);expect(exists).toBe(true);- const info = await RenderInternals.callFf("ffprobe", [outputPath]);+ const info = await RenderInternals.callFf(+ "ffprobe",+ [outputPath],+ false,+ "info"+ );const data = info.stderr;expect(data).toContain("Video: h264");expect(data).toContain("yuv420p");@@ -136,7 +141,7 @@ test("Should render a ProRes video", async () => {const exists = fs.existsSync(out);expect(exists).toBe(true);- const info = await RenderInternals.callFf("ffprobe", [out]);+ const info = await RenderInternals.callFf("ffprobe", [out], false, "info");const data = info.stderr;expect(data.includes("prores (4444)") || data.includes("prores (ap4h")).toBe(true@@ -158,7 +163,7 @@ test("Should render a still image if single frame specified", async () => {expect(task.exitCode).toBe(0);expect(fs.existsSync(outImg)).toBe(true);- const info = await RenderInternals.callFf("ffprobe", [outImg]);+ const info = await RenderInternals.callFf("ffprobe", [outImg], false, "info");const data = info.stderr;expect(data).toContain("Video: png");await fs.promises.rm(outDir, {@@ -180,7 +185,7 @@ test("Should be able to render a WAV audio file", async () => {const exists = fs.existsSync(out);expect(exists).toBe(true);- const info = await RenderInternals.callFf("ffprobe", [out]);+ const info = await RenderInternals.callFf("ffprobe", [out], false, "info");const data = info.stderr;expect(data).toContain("pcm_s16le");expect(data).toContain("2 channels");@@ -205,7 +210,7 @@ test("Should be able to render a MP3 audio file", async () => {const exists = fs.existsSync(out);expect(exists).toBe(true);- const info = await RenderInternals.callFf("ffprobe", [out]);+ const info = await RenderInternals.callFf("ffprobe", [out], false, "info");const data = info.stderr;expect(data).toContain("mp3");expect(data).toContain("stereo");@@ -230,7 +235,7 @@ test("Should be able to render a AAC audio file", async () => {const exists = fs.existsSync(out);expect(exists).toBe(true);- const info = await RenderInternals.callFf("ffprobe", [out]);+ const info = await RenderInternals.callFf("ffprobe", [out], false, "info");const data = info.stderr;expect(data).toContain("aac");expect(data).toContain("stereo");@@ -252,7 +257,12 @@ test("Should render a video with GIFs", async () => {expect(task.exitCode).toBe(0);expect(fs.existsSync(outputPath)).toBe(true);- const info = await RenderInternals.callFf("ffprobe", [outputPath]);+ const info = await RenderInternals.callFf(+ "ffprobe",+ [outputPath],+ false,+ "info"+ );const data = info.stderr;expect(data).toContain("Video: h264");expect(data).not.toContain("bt709");@@ -274,7 +284,7 @@ test("Should render a video with Offline Audio-context", async () => {expect(task.exitCode).toBe(0);expect(fs.existsSync(out)).toBe(true);- const info = await RenderInternals.callFf("ffprobe", [out]);+ const info = await RenderInternals.callFf("ffprobe", [out], false, "info");const data = info.stderr;expect(data).toContain("Stream #0:0: Audio: mp3");expect(data).toContain("48000 Hz, stereo");@@ -291,7 +301,7 @@ test("Should succeed to render an audio file that doesn't have any audio inputs"});expect(task.exitCode).toBe(0);- const info = await RenderInternals.callFf("ffprobe", [out]);+ const info = await RenderInternals.callFf("ffprobe", [out], false, "info");const data = info.stderr;expect(data).toContain("Duration: 00:00:00.36");expect(data).toContain("Audio: mp3, 48000 Hz");@@ -346,7 +356,12 @@ test("Dynamic duration should work, and render from inside src/", async () => {expect(task.exitCode).toBe(0);expect(fs.existsSync(outputPath)).toBe(true);- const info = await RenderInternals.callFf("ffprobe", [outputPath]);+ const info = await RenderInternals.callFf(+ "ffprobe",+ [outputPath],+ false,+ "info"+ );const data = info.stderr;expect(data).toContain("Video: h264");const expectedDuration = (randomDuration / 30).toFixed(2);diff --git a/packages/it-tests/src/ssr/render-frames.test.ts b/packages/it-tests/src/ssr/render-frames.test.tsindex 4fb7f98a5e..a89e3a0565 100644--- a/packages/it-tests/src/ssr/render-frames.test.ts+++ b/packages/it-tests/src/ssr/render-frames.test.ts@@ -58,7 +58,12 @@ test("Legacy SSR way of rendering videos should still work", async () => {codec: "h264",});expect(fs.existsSync(outPath)).toBe(true);- const probe = await RenderInternals.callFf("ffprobe", [outPath]);+ const probe = await RenderInternals.callFf(+ "ffprobe",+ [outPath],+ false,+ "info"+ );expect(probe.stderr).toMatch(/Video: h264/);RenderInternals.deleteDirectory(framesDir);diff --git a/packages/lambda/src/functions/helpers/concat-videos.ts b/packages/lambda/src/functions/helpers/concat-videos.tsindex db30d5482b..b3d1a4e5ea 100644--- a/packages/lambda/src/functions/helpers/concat-videos.ts+++ b/packages/lambda/src/functions/helpers/concat-videos.ts@@ -1,4 +1,4 @@-import type {AudioCodec} from '@remotion/renderer';+import type {AudioCodec, LogLevel} from '@remotion/renderer';import {RenderInternals} from '@remotion/renderer';import fs, {createWriteStream, promises} from 'node:fs';import path, {join} from 'node:path';@@ -183,6 +183,7 @@ export const concatVideosS3 = async ({outdir,audioCodec,audioBitrate,+ logLevel,}: {onProgress: (frames: number) => void;numberOfFrames: number;@@ -193,6 +194,7 @@ export const concatVideosS3 = async ({outdir: string;audioCodec: AudioCodec | null;audioBitrate: string | null;+ logLevel: LogLevel;}) => {const outfile = join(RenderInternals.tmpDir(REMOTION_CONCATED_TOKEN),@@ -212,6 +214,8 @@ export const concatVideosS3 = async ({numberOfGifLoops,audioCodec,audioBitrate,+ indent: false,+ logLevel,});combine.end();diff --git a/packages/lambda/src/functions/helpers/merge-chunks.ts b/packages/lambda/src/functions/helpers/merge-chunks.tsindex 039365555c..7911c434f5 100644--- a/packages/lambda/src/functions/helpers/merge-chunks.ts+++ b/packages/lambda/src/functions/helpers/merge-chunks.ts@@ -1,4 +1,4 @@-import type {AudioCodec} from '@remotion/renderer';+import type {AudioCodec, LogLevel} from '@remotion/renderer';import {RenderInternals} from '@remotion/renderer';import fs from 'fs';import {existsSync, mkdirSync, rmSync} from 'node:fs';@@ -61,6 +61,7 @@ export const mergeChunksAndFinishRender = async (options: {renderMetadata: RenderMetadata;onAllChunks: OnAllChunksAvailable;audioBitrate: string | null;+ logLevel: LogLevel;}): Promise<PostRenderData> => {let lastProgressUploaded = 0;@@ -159,6 +160,7 @@ export const mergeChunksAndFinishRender = async (options: {outdir,audioCodec: options.audioCodec,audioBitrate: options.audioBitrate,+ logLevel: options.logLevel,});const encodingStop = Date.now();diff --git a/packages/lambda/src/functions/launch.ts b/packages/lambda/src/functions/launch.tsindex 145776cdc8..2eb9db6487 100644--- a/packages/lambda/src/functions/launch.ts+++ b/packages/lambda/src/functions/launch.ts@@ -379,6 +379,7 @@ const innerLaunchHandler = async ({renderMetadata,onAllChunks: onAllChunksAvailable,audioBitrate: params.audioBitrate,+ logLevel: params.logLevel,});return postRenderData;diff --git a/packages/lambda/src/functions/merge.ts b/packages/lambda/src/functions/merge.tsindex 43db6d2abc..3bf06870a6 100644--- a/packages/lambda/src/functions/merge.ts+++ b/packages/lambda/src/functions/merge.ts@@ -72,6 +72,7 @@ export const mergeHandler = async (RenderInternals.Log.info('All chunks have been downloaded now.');},audioBitrate: renderMetadata.audioBitrate,+ logLevel: params.logLevel,});return {type: 'success' as const, postRenderData};diff --git a/packages/lambda/src/test/integration/renders/gif.test.ts b/packages/lambda/src/test/integration/renders/gif.test.tsindex 0035cf5c2d..cc025e2507 100644--- a/packages/lambda/src/test/integration/renders/gif.test.ts+++ b/packages/lambda/src/test/integration/renders/gif.test.ts@@ -97,6 +97,11 @@ test('Should make a distributed GIF', async () => {await new Promise<void>((resolve) => {file.pipe(createWriteStream('gif.gif')).on('close', () => resolve());});- const probe = await RenderInternals.callFf('ffprobe', ['gif.gif']);+ const probe = await RenderInternals.callFf(+ 'ffprobe',+ ['gif.gif'],+ false,+ 'info',+ );expect(probe.stderr).toMatch(/Video: gif, bgra, 1080x1080/);}, 90000);diff --git a/packages/lambda/src/test/integration/renders/other-bucket.test.ts b/packages/lambda/src/test/integration/renders/other-bucket.test.tsindex ec7a6ab361..7458f91fd0 100644--- a/packages/lambda/src/test/integration/renders/other-bucket.test.ts+++ b/packages/lambda/src/test/integration/renders/other-bucket.test.ts@@ -97,7 +97,7 @@ test('Should be able to render to another bucket', async () => {expectedBucketOwner: 'abc',region: 'eu-central-1',});- const probe = await RenderInternals.callFf('ffprobe', ['-'], {+ const probe = await RenderInternals.callFf('ffprobe', ['-'], false, 'info', {stdin: file,});expect(probe.stderr).toMatch(/Stream #0:0/);diff --git a/packages/lambda/src/test/integration/renders/silent-audio.test.ts b/packages/lambda/src/test/integration/renders/silent-audio.test.tsindex 6ca68b18fb..2272c58502 100644--- a/packages/lambda/src/test/integration/renders/silent-audio.test.ts+++ b/packages/lambda/src/test/integration/renders/silent-audio.test.ts@@ -94,7 +94,7 @@ test('Should add silent audio if there is no audio', async () => {expectedBucketOwner: 'abc',region: 'eu-central-1',});- const probe = await RenderInternals.callFf('ffprobe', ['-'], {+ const probe = await RenderInternals.callFf('ffprobe', ['-'], false, 'info', {stdin: file,});expect(probe.stderr).toMatch(/Stream #0:0/);diff --git a/packages/lambda/src/test/integration/renders/transparent-webm.test.ts b/packages/lambda/src/test/integration/renders/transparent-webm.test.tsindex a0eb66481a..3957211bfc 100644--- a/packages/lambda/src/test/integration/renders/transparent-webm.test.ts+++ b/packages/lambda/src/test/integration/renders/transparent-webm.test.ts@@ -106,7 +106,7 @@ test('Should make a transparent video', async () => {await new Promise<void>((resolve) => {file.on('close', () => resolve());});- const probe = await RenderInternals.callFf('ffprobe', [out]);+ const probe = await RenderInternals.callFf('ffprobe', [out], false, 'info');expect(probe.stderr).toMatch(/ALPHA_MODE(\s+): 1/);expect(probe.stderr).toMatch(/Video: vp8, yuv420p/);expect(probe.stderr).toMatch(/Audio: opus, 48000 Hz/);diff --git a/packages/renderer/src/assets/get-audio-channels.ts b/packages/renderer/src/assets/get-audio-channels.tsindex 88f57b0ba7..9064ed439e 100644--- a/packages/renderer/src/assets/get-audio-channels.ts+++ b/packages/renderer/src/assets/get-audio-channels.ts@@ -1,4 +1,5 @@import {callFf} from '../call-ffmpeg';+import type {LogLevel} from '../log-level';import {pLimit} from '../p-limit';import type {AudioChannelsAndDurationResultCache,@@ -7,7 +8,11 @@ import type {const limit = pLimit(1);-export const getAudioChannelsAndDurationWithoutCache = async (src: string) => {+export const getAudioChannelsAndDurationWithoutCache = async (+ src: string,+ indent: boolean,+ logLevel: LogLevel,+) => {const args = [['-v', 'error'],['-show_entries', 'stream=channels:format=duration'],@@ -17,7 +22,7 @@ export const getAudioChannelsAndDurationWithoutCache = async (src: string) => {.reduce<(string | null)[]>((acc, val) => acc.concat(val), []).filter(Boolean) as string[];- const task = await callFf('ffprobe', args);+ const task = await callFf('ffprobe', args, indent, logLevel);const channels = task.stdout.match(/channels=([0-9]+)/);const duration = task.stdout.match(/duration=([0-9.]+)/);@@ -32,12 +37,18 @@ export const getAudioChannelsAndDurationWithoutCache = async (src: string) => {async function getAudioChannelsAndDurationUnlimited(downloadMap: DownloadMap,src: string,+ indent: boolean,+ logLevel: LogLevel,): Promise<AudioChannelsAndDurationResultCache> {if (downloadMap.durationOfAssetCache[src]) {return downloadMap.durationOfAssetCache[src];}- const result = await getAudioChannelsAndDurationWithoutCache(src);+ const result = await getAudioChannelsAndDurationWithoutCache(+ src,+ indent,+ logLevel,+ );downloadMap.durationOfAssetCache[src] = result;@@ -47,6 +58,10 @@ async function getAudioChannelsAndDurationUnlimited(export const getAudioChannelsAndDuration = (downloadMap: DownloadMap,src: string,+ indent: boolean,+ logLevel: LogLevel,): Promise<AudioChannelsAndDurationResultCache> => {- return limit(() => getAudioChannelsAndDurationUnlimited(downloadMap, src));+ return limit(() =>+ getAudioChannelsAndDurationUnlimited(downloadMap, src, indent, logLevel),+ );};diff --git a/packages/renderer/src/call-ffmpeg.ts b/packages/renderer/src/call-ffmpeg.tsindex 8e54aa0dc4..190846f1ab 100644--- a/packages/renderer/src/call-ffmpeg.ts+++ b/packages/renderer/src/call-ffmpeg.ts@@ -2,10 +2,18 @@ import execa from 'execa';import {chmodSync} from 'node:fs';import path from 'node:path';import {getExecutablePath} from './compositor/get-executable-path';+import type {LogLevel} from './log-level';import {truthy} from './truthy';-export const dynamicLibraryPathOptions = () => {- const lib = path.join(getExecutablePath('ffmpeg-cwd'), 'remotion', 'lib');+export const dynamicLibraryPathOptions = (+ indent: boolean,+ logLevel: LogLevel,+) => {+ const lib = path.join(+ getExecutablePath('ffmpeg-cwd', indent, logLevel),+ 'remotion',+ 'lib',+ );return {env: {@@ -28,15 +36,17 @@ export const dynamicLibraryPathOptions = () => {export const callFf = (bin: 'ffmpeg' | 'ffprobe',args: (string | null)[],+ indent: boolean,+ logLevel: LogLevel,options?: execa.Options<string>,) => {- const executablePath = getExecutablePath(bin);+ const executablePath = getExecutablePath(bin, indent, logLevel);if (!process.env.READ_ONLY_FS) {chmodSync(executablePath, 0o755);}return execa(executablePath, args.filter(truthy), {- ...dynamicLibraryPathOptions(),+ ...dynamicLibraryPathOptions(indent, logLevel),...options,});};diff --git a/packages/renderer/src/combine-videos.ts b/packages/renderer/src/combine-videos.tsindex 043b1bda87..35f67a486f 100644--- a/packages/renderer/src/combine-videos.ts+++ b/packages/renderer/src/combine-videos.ts@@ -10,6 +10,7 @@ import {import {callFf} from './call-ffmpeg';import type {Codec} from './codec';import {isAudioCodec} from './is-audio-codec';+import type {LogLevel} from './log-level';import {Log} from './logger';import {parseFfmpegProgress} from './parse-ffmpeg-progress';import {truthy} from './truthy';@@ -25,6 +26,8 @@ type Options = {numberOfGifLoops: number | null;audioCodec: AudioCodec | null;audioBitrate: string | null;+ indent: boolean;+ logLevel: LogLevel;};export const combineVideos = async (options: Options) => {@@ -82,7 +85,7 @@ export const combineVideos = async (options: Options) => {Log.verbose('Combining command: ', command);try {- const task = callFf('ffmpeg', command);+ const task = callFf('ffmpeg', command, options.indent, options.logLevel);task.stderr?.on('data', (data: Buffer) => {if (onProgress) {const parsed = parseFfmpegProgress(data.toString('utf8'));diff --git a/packages/renderer/src/compositor/compose.ts b/packages/renderer/src/compositor/compose.tsindex d41bd3ed62..0e964838a3 100644--- a/packages/renderer/src/compositor/compose.ts+++ b/packages/renderer/src/compositor/compose.ts@@ -4,6 +4,7 @@ import {chmodSync} from 'node:fs';import {copyFile} from 'node:fs/promises';import type {DownloadMap} from '../assets/download-map';import {dynamicLibraryPathOptions} from '../call-ffmpeg';+import type {LogLevel} from '../log-level';import type {Compositor} from './compositor';import {getExecutablePath} from './get-executable-path';import {makeNonce} from './make-nonce';@@ -94,14 +95,22 @@ export const compose = async ({downloadMap.compositorCache[hash] = output;};-export const callCompositor = (payload: string) => {+export const callCompositor = (+ payload: string,+ indent: boolean,+ logLevel: LogLevel,+) => {return new Promise<void>((resolve, reject) => {- const execPath = getExecutablePath('compositor');+ const execPath = getExecutablePath('compositor', indent, logLevel);if (!process.env.READ_ONLY_FS) {chmodSync(execPath, 0o755);}- const child = spawn(execPath, [payload], dynamicLibraryPathOptions());+ const child = spawn(+ execPath,+ [payload],+ dynamicLibraryPathOptions(indent, logLevel),+ );const stderrChunks: Buffer[] = [];child.stderr.on('data', (d) => stderrChunks.push(d));diff --git a/packages/renderer/src/compositor/compositor.ts b/packages/renderer/src/compositor/compositor.tsindex b6c53c300c..1823298cf7 100644--- a/packages/renderer/src/compositor/compositor.ts+++ b/packages/renderer/src/compositor/compositor.ts@@ -70,7 +70,7 @@ export const startCompositor = <T extends keyof CompositorCommand>(logLevel: LogLevel,indent: boolean,): Compositor => {- const bin = getExecutablePath('compositor');+ const bin = getExecutablePath('compositor', indent, logLevel);if (!process.env.READ_ONLY_FS) {chmodSync(bin, 0o755);}@@ -83,7 +83,7 @@ export const startCompositor = <T extends keyof CompositorCommand>(const child = spawn(bin,[JSON.stringify(fullCommand)],- dynamicLibraryPathOptions(),+ dynamicLibraryPathOptions(indent, logLevel),);const stderrChunks: Buffer[] = [];diff --git a/packages/renderer/src/compositor/get-executable-path.ts b/packages/renderer/src/compositor/get-executable-path.tsindex 6391cfa3c9..acbf4ea894 100644--- a/packages/renderer/src/compositor/get-executable-path.ts+++ b/packages/renderer/src/compositor/get-executable-path.ts@@ -1,6 +1,18 @@// Adapted from @swc/core package-function isMusl() {+import type {LogLevel} from '../log-level';+import {Log} from '../logger';++function isMusl({indent, logLevel}: {indent: boolean; logLevel: LogLevel}) {+ // @ts-expect-error bun no types+ if (process.report && typeof Bun !== 'undefined') {+ Log.warnAdvanced(+ {indent, logLevel},+ 'Bun limitation: Could not determine if your Linux is using musl or glibc. Assuming glibc.',+ );+ return false;+ }+// @ts-expect-error no typesconst {glibcVersionRuntime} = process.report.getReport().header;return !glibcVersionRuntime;@@ -8,6 +20,8 @@ function isMusl() {export const getExecutablePath = (type: 'compositor' | 'ffmpeg' | 'ffprobe' | 'ffmpeg-cwd',+ indent: boolean,+ logLevel: LogLevel,): string => {if (type === 'compositor' && process.env.COMPOSITOR_PATH) {return process.env.COMPOSITOR_PATH;@@ -43,16 +57,17 @@ export const getExecutablePath = (throw new Error(`Unsupported architecture on macOS: ${process.arch}`);}- case 'linux':+ case 'linux': {+ const musl = isMusl({indent, logLevel});switch (process.arch) {case 'x64':- if (isMusl()) {+ if (musl) {return require('@remotion/compositor-linux-x64-musl')[key];}return require('@remotion/compositor-linux-x64-gnu')[key];case 'arm64':- if (isMusl()) {+ if (musl) {return require('@remotion/compositor-linux-arm64-musl')[key];}@@ -61,6 +76,7 @@ export const getExecutablePath = (default:throw new Error(`Unsupported architecture on Linux: ${process.arch}`);}+ }default:throw new Error(diff --git a/packages/renderer/src/create-silent-audio.ts b/packages/renderer/src/create-silent-audio.tsindex 3fd529c67b..87d74cf56e 100644--- a/packages/renderer/src/create-silent-audio.ts+++ b/packages/renderer/src/create-silent-audio.ts@@ -1,24 +1,34 @@import {callFf} from './call-ffmpeg';+import type {LogLevel} from './log-level';import {DEFAULT_SAMPLE_RATE} from './sample-rate';export const createSilentAudio = async ({numberOfSeconds,outName,+ indent,+ logLevel,}: {numberOfSeconds: number;outName: string;+ indent: boolean;+ logLevel: LogLevel;}) => {- await callFf('ffmpeg', [- '-f',- 'lavfi',- '-i',- `anullsrc=r=${DEFAULT_SAMPLE_RATE}`,- '-c:a',- 'pcm_s16le',- '-t',- String(numberOfSeconds),- '-ar',- String(DEFAULT_SAMPLE_RATE),- outName,- ]);+ await callFf(+ 'ffmpeg',+ [+ '-f',+ 'lavfi',+ '-i',+ `anullsrc=r=${DEFAULT_SAMPLE_RATE}`,+ '-c:a',+ 'pcm_s16le',+ '-t',+ String(numberOfSeconds),+ '-ar',+ String(DEFAULT_SAMPLE_RATE),+ outName,+ ],+ indent,+ logLevel,+ );};diff --git a/packages/renderer/src/guess-extension-for-media.ts b/packages/renderer/src/guess-extension-for-media.tsindex e7e27c31da..791e6d8463 100644--- a/packages/renderer/src/guess-extension-for-media.ts+++ b/packages/renderer/src/guess-extension-for-media.ts@@ -1,7 +1,16 @@import {callFf} from './call-ffmpeg';+import type {LogLevel} from './log-level';-export const guessExtensionForVideo = async ({src}: {src: string}) => {- const {stderr} = await callFf('ffprobe', [src]);+export const guessExtensionForVideo = async ({+ src,+ indent,+ logLevel,+}: {+ src: string;+ indent: boolean;+ logLevel: LogLevel;+}) => {+ const {stderr} = await callFf('ffprobe', [src], indent, logLevel);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 8b2cf11313..33ec6fb162 100644--- a/packages/renderer/src/merge-audio-track.ts+++ b/packages/renderer/src/merge-audio-track.ts@@ -6,6 +6,7 @@ import {createFfmpegComplexFilter} from './create-ffmpeg-complex-filter';import {OUTPUT_FILTER_NAME} from './create-ffmpeg-merge-filter';import {createSilentAudio} from './create-silent-audio';import {deleteDirectory} from './delete-directory';+import type {LogLevel} from './log-level';import {pLimit} from './p-limit';import type {PreprocessedAudioTrack} from './preprocess-audio-track';import {tmpDir} from './tmp-dir';@@ -17,6 +18,8 @@ type Options = {numberOfSeconds: number;downloadMap: DownloadMap;remotionRoot: string;+ indent: boolean;+ logLevel: LogLevel;};const mergeAudioTrackUnlimited = async ({@@ -25,11 +28,15 @@ const mergeAudioTrackUnlimited = async ({numberOfSeconds,downloadMap,remotionRoot,+ indent,+ logLevel,}: Options): Promise<void> => {if (files.length === 0) {await createSilentAudio({outName,numberOfSeconds,+ indent,+ logLevel,});return;}@@ -51,6 +58,8 @@ const mergeAudioTrackUnlimited = async ({outName: chunkOutname,downloadMap,remotionRoot,+ indent,+ logLevel,});return chunkOutname;}),@@ -68,6 +77,8 @@ const mergeAudioTrackUnlimited = async ({outName,downloadMap,remotionRoot,+ indent,+ logLevel,});return;} finally {@@ -90,7 +101,7 @@ const mergeAudioTrackUnlimited = async ({].filter(truthy).flat(2);- const task = callFf('ffmpeg', args);+ const task = callFf('ffmpeg', args, indent, logLevel);await task;cleanup();};diff --git a/packages/renderer/src/preprocess-audio-track.ts b/packages/renderer/src/preprocess-audio-track.tsindex 5ca60a0c0e..daedac95af 100644--- a/packages/renderer/src/preprocess-audio-track.ts+++ b/packages/renderer/src/preprocess-audio-track.ts@@ -4,6 +4,7 @@ import type {MediaAsset} from './assets/types';import {calculateFfmpegFilter} from './calculate-ffmpeg-filters';import {callFf} from './call-ffmpeg';import {makeFfmpegFilterFile} from './ffmpeg-filter-file';+import type {LogLevel} from './log-level';import {pLimit} from './p-limit';import {resolveAssetSrc} from './resolve-asset-src';import {DEFAULT_SAMPLE_RATE} from './sample-rate';@@ -15,6 +16,8 @@ type Options = {expectedFrames: number;fps: number;downloadMap: DownloadMap;+ indent: boolean;+ logLevel: LogLevel;};export type PreprocessedAudioTrack = {@@ -28,10 +31,14 @@ const preprocessAudioTrackUnlimited = async ({expectedFrames,fps,downloadMap,+ indent,+ logLevel,}: Options): Promise<PreprocessedAudioTrack | null> => {const {channels, duration} = await getAudioChannelsAndDuration(downloadMap,resolveAssetSrc(asset.src),+ indent,+ logLevel,);const filter = calculateFfmpegFilter({@@ -57,7 +64,7 @@ const preprocessAudioTrackUnlimited = async ({['-y', outName],].flat(2);- await callFf('ffmpeg', args);+ await callFf('ffmpeg', args, indent, logLevel);cleanup();return {outName, filter};diff --git a/packages/renderer/src/prespawn-ffmpeg.ts b/packages/renderer/src/prespawn-ffmpeg.tsindex 211b9c3433..382e8ddf84 100644--- a/packages/renderer/src/prespawn-ffmpeg.ts+++ b/packages/renderer/src/prespawn-ffmpeg.ts@@ -127,7 +127,12 @@ export const prespawnFfmpeg = (options: PreStitcherOptions) => {? options.ffmpegOverride({type: 'pre-stitcher', args: ffmpegString}): ffmpegString;- const task = callFf('ffmpeg', finalFfmpegString);+ const task = callFf(+ 'ffmpeg',+ finalFfmpegString,+ options.indent,+ options.logLevel,+ );options.signal(() => {task.kill();diff --git a/packages/renderer/src/stitch-frames-to-video.ts b/packages/renderer/src/stitch-frames-to-video.tsindex 21f19c583b..cafcbe202c 100644--- a/packages/renderer/src/stitch-frames-to-video.ts+++ b/packages/renderer/src/stitch-frames-to-video.ts@@ -171,6 +171,8 @@ const getAssetsData = async ({expectedFrames,fps,downloadMap,+ indent,+ logLevel,});preprocessProgress[index] = 1;updateProgress();@@ -187,6 +189,8 @@ const getAssetsData = async ({numberOfSeconds: Number((expectedFrames / fps).toFixed(3)),downloadMap,remotionRoot,+ indent,+ logLevel,});onProgress(1);@@ -371,6 +375,8 @@ const innerStitchFramesToVideo = async (force ? '-y' : null,outputLocation ?? tempFile,].filter(Internals.truthy),+ indent,+ logLevel,);cancelSignal?.(() => {@@ -468,7 +474,7 @@ const innerStitchFramesToVideo = async (finalFfmpegString.join(' '),);- const task = callFf('ffmpeg', finalFfmpegString, {+ const task = callFf('ffmpeg', finalFfmpegString, indent, logLevel, {cwd: dir,});cancelSignal?.(() => {diff --git a/packages/renderer/src/test/get-audio-channels.test.ts b/packages/renderer/src/test/get-audio-channels.test.tsindex 46f6f031d8..57d9ac3192 100644--- a/packages/renderer/src/test/get-audio-channels.test.ts+++ b/packages/renderer/src/test/get-audio-channels.test.ts@@ -19,8 +19,11 @@ test('Get audio channels for video', async () => {'framer-music.mp4',);expect(existsSync(videoWithoutAudio)).toEqual(true);- const channels =- await getAudioChannelsAndDurationWithoutCache(videoWithoutAudio);+ const channels = await getAudioChannelsAndDurationWithoutCache(+ videoWithoutAudio,+ false,+ 'info',+ );expect(channels).toEqual({channels: 2, duration: 10});}, 90000);@@ -36,8 +39,11 @@ test('Get audio channels for video without music', async () => {'framer.mp4',);expect(existsSync(videoWithAudio)).toEqual(true);- const channels =- await getAudioChannelsAndDurationWithoutCache(videoWithAudio);+ const channels = await getAudioChannelsAndDurationWithoutCache(+ videoWithAudio,+ false,+ 'info',+ );expect(channels.channels).toEqual(0);expect(channels.duration).toBeCloseTo(3.334, 2);@@ -56,7 +62,12 @@ test('Get audio channels for video with music', async () => {'sound1.mp3',);expect(existsSync(audio)).toEqual(true);- const channels = await getAudioChannelsAndDuration(downloadMap, audio);+ const channels = await getAudioChannelsAndDuration(+ downloadMap,+ audio,+ false,+ 'info',+ );cleanDownloadMap(downloadMap);expect(channels).toEqual({channels: 2, duration: 56.529});@@ -67,7 +78,7 @@ 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),+ getAudioChannelsAndDuration(downloadMap, tsFile, false, 'info'),).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 8e8339464e..2be365712c 100644--- a/packages/renderer/src/test/guess-extension-for-media.test.ts+++ b/packages/renderer/src/test/guess-extension-for-media.test.ts@@ -13,6 +13,8 @@ test('Guess extension for media - H264', async () => {'public','framermp4withoutfileextension',),+ indent: false,+ logLevel: 'info',});expect(extension).toBe('mp4');@@ -29,6 +31,8 @@ test('Guess extension for media - WebM', async () => {'public','framer.webm',),+ indent: false,+ logLevel: 'info',});expect(extension).toBe('webm');@@ -45,6 +49,8 @@ test('Guess extension for media - WAV', async () => {'public','22khz.wav',),+ indent: false,+ logLevel: 'info',});expect(extension).toBe('wav');@@ -61,6 +67,8 @@ test('Guess extension for media - MP3', async () => {'public','music.mp3',),+ indent: false,+ logLevel: 'info',});expect(extension).toBe('mp3');diff --git a/packages/renderer/src/test/rust-errors.test.ts b/packages/renderer/src/test/rust-errors.test.tsindex d62d3b7ea9..b5d6b891e1 100644--- a/packages/renderer/src/test/rust-errors.test.ts+++ b/packages/renderer/src/test/rust-errors.test.ts@@ -69,7 +69,7 @@ test('Non-long running task panics should be handled', async () => {const command = serializeCommand('DeliberatePanic', {});try {- await callCompositor(JSON.stringify(command));+ await callCompositor(JSON.stringify(command), false, 'info');throw new Error('should not be reached');} catch (err) {expect((err as Error).message).toContain('Compositor panicked');@@ -85,7 +85,7 @@ test('Long running task failures should be handled', async () => {transparent: false,});try {- await callCompositor(JSON.stringify(command));+ await callCompositor(JSON.stringify(command), false, 'info');throw new Error('should not be reached');} catch (err) {expect((err as Error).message).toContain(@@ -104,7 +104,7 @@ test('Invalid payloads will be handled', async () => {original_src: 'fsdfds',});try {- await callCompositor(JSON.stringify(command));+ await callCompositor(JSON.stringify(command), false, 'info');} catch (err) {expect((err as Error).message).toContain('Compositor error: missing field `time`',