🎥 Make videos programmatically with React
dynamic executable path
Jonny Burger24291afbfd19
diff --git a/packages/compositor/src/compose.ts b/packages/compositor/src/compose.tsindex 8e66960a62..f88bae540e 100644--- a/packages/compositor/src/compose.ts+++ b/packages/compositor/src/compose.ts@@ -1,5 +1,5 @@-import {binaryPath} from '@remotion/compositor-darwin-arm64';import {spawn} from 'child_process';+import {getExecutablePath} from './get-executable-path';import type {CliInput, Layer} from './payload';export const compose = ({@@ -13,8 +13,7 @@ export const compose = ({layers: Layer[];output: string;}) => {- // TODO: Unhardcode- const bin = binaryPath;+ const bin = getExecutablePath();const payload: CliInput = {v: 1,diff --git a/packages/compositor/src/get-executable-path.ts b/packages/compositor/src/get-executable-path.tsnew file mode 100644index 0000000000..b0d9761c27--- /dev/null+++ b/packages/compositor/src/get-executable-path.ts@@ -0,0 +1,55 @@+// Adapted from @swc/core package++function isMusl() {+ // @ts-expect-error no types+ const {glibcVersionRuntime} = process.report.getReport().header;+ return !glibcVersionRuntime;+}++export const getExecutablePath = () => {+ switch (process.platform) {+ case 'win32':+ switch (process.arch) {+ case 'x64':+ return require('@remotion/compositor-win32-x64-msvc').binaryPath;+ default:+ throw new Error(+ `Unsupported architecture on Windows: ${process.arch}`+ );+ }++ case 'darwin':+ switch (process.arch) {+ case 'x64':+ return require('@remotion/compositor-darwin-x64').binaryPath;+ case 'arm64':+ return require('@remotion/compositor-darwin-arm64').binaryPath;+ default:+ throw new Error(`Unsupported architecture on macOS: ${process.arch}`);+ }++ case 'linux':+ switch (process.arch) {+ case 'x64':+ if (isMusl()) {+ return require('@remotion/compositor-linux-x64-musl').binaryPath;+ }++ return require('@remotion/compositor-linux-x64-gnu').binaryPath;+ case 'arm64':+ if (isMusl()) {+ return require('@remotion/compositor-linux-arm64-musl').binaryPath;+ }++ return require('@remotion/compositor-linux-arm64-gnu').binaryPath;++ default:+ throw new Error(`Unsupported architecture on Linux: ${process.arch}`);+ }++ default:+ throw new Error(+ `Unsupported OS: ${process.platform}, architecture: ${process.arch}`+ );+ }+};diff --git a/packages/compositor/src/index.ts b/packages/compositor/src/index.tsindex cf78774190..94f9320b37 100644--- a/packages/compositor/src/index.ts+++ b/packages/compositor/src/index.ts@@ -1 +1,2 @@export {compose} from './compose';+export {getExecutablePath} from './get-executable-path';