@remotion/renderer
Version:
Render Remotion videos using Node.js or Bun
96 lines (95 loc) • 3.99 kB
JavaScript
;
// Adapted from @swc/core package
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getExecutableDir = exports.getExecutablePath = void 0;
exports.isMusl = isMusl;
const path_1 = __importDefault(require("path"));
const logger_1 = require("../logger");
let warned = false;
function isMusl({ indent, logLevel, }) {
var _a;
if (!process.report && typeof Bun !== 'undefined') {
if (!warned) {
logger_1.Log.warn({ indent, logLevel }, 'Bun limitation: Could not determine if your Linux is using musl or glibc. Assuming glibc.');
}
warned = true;
return false;
}
const report = (_a = process.report) === null || _a === void 0 ? void 0 : _a.getReport();
if (report && typeof report === 'string') {
if (!warned) {
logger_1.Log.warn({ indent, logLevel }, 'Bun limitation: Could not determine if your Windows is using musl or glibc. Assuming glibc.');
}
warned = true;
return false;
}
// @ts-expect-error no types
const { glibcVersionRuntime } = report.header;
return !glibcVersionRuntime;
}
const getExecutablePath = ({ indent, logLevel, type, binariesDirectory, }) => {
const base = binariesDirectory !== null && binariesDirectory !== void 0 ? binariesDirectory : (0, exports.getExecutableDir)(indent, logLevel);
switch (type) {
case 'compositor':
if (process.platform === 'win32') {
return path_1.default.resolve(base, 'remotion.exe');
}
return path_1.default.resolve(base, 'remotion');
case 'ffmpeg':
if (process.platform === 'win32') {
return path_1.default.join(base, 'ffmpeg.exe');
}
return path_1.default.join(base, 'ffmpeg');
case 'ffprobe':
if (process.platform === 'win32') {
return path_1.default.join(base, 'ffprobe.exe');
}
return path_1.default.join(base, 'ffprobe');
default:
throw new Error(`Unknown executable type: ${type}`);
}
};
exports.getExecutablePath = getExecutablePath;
const getExecutableDir = (indent, logLevel) => {
switch (process.platform) {
case 'win32':
switch (process.arch) {
case 'x64':
return require('@remotion/compositor-win32-x64-msvc').dir;
default:
throw new Error(`Unsupported architecture on Windows: ${process.arch}`);
}
case 'darwin':
switch (process.arch) {
case 'x64':
return require('@remotion/compositor-darwin-x64').dir;
case 'arm64':
return require('@remotion/compositor-darwin-arm64').dir;
default:
throw new Error(`Unsupported architecture on macOS: ${process.arch}`);
}
case 'linux': {
const musl = isMusl({ indent, logLevel });
switch (process.arch) {
case 'x64':
if (musl) {
return require('@remotion/compositor-linux-x64-musl').dir;
}
return require('@remotion/compositor-linux-x64-gnu').dir;
case 'arm64':
if (musl) {
return require('@remotion/compositor-linux-arm64-musl').dir;
}
return require('@remotion/compositor-linux-arm64-gnu').dir;
default:
throw new Error(`Unsupported architecture on Linux: ${process.arch}`);
}
}
default:
throw new Error(`Unsupported OS: ${process.platform}, architecture: ${process.arch}`);
}
};
exports.getExecutableDir = getExecutableDir;