46 lines
4.2 KiB
JavaScript
46 lines
4.2 KiB
JavaScript
|
"use strict";
|
||
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||
|
};
|
||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||
|
const os_family_1 = require("os-family");
|
||
|
const resolve_cwd_1 = __importDefault(require("resolve-cwd"));
|
||
|
const promisified_functions_1 = require("./promisified-functions");
|
||
|
const FFMPEG_MODULE_NAME = '@ffmpeg-installer/ffmpeg';
|
||
|
const FFMPEG_SEARCH_COMMAND = os_family_1.isWin ? 'where' : 'which';
|
||
|
const FFMPEG_BINARY_NAME = 'ffmpeg';
|
||
|
async function findFFMPEGinPath() {
|
||
|
try {
|
||
|
const ffmpegPath = await (0, promisified_functions_1.exec)(`${FFMPEG_SEARCH_COMMAND} ${FFMPEG_BINARY_NAME}`);
|
||
|
return ffmpegPath.stdout.trim();
|
||
|
}
|
||
|
catch (e) {
|
||
|
return '';
|
||
|
}
|
||
|
}
|
||
|
async function requireFFMPEGModuleFromCwd() {
|
||
|
try {
|
||
|
const ffmpegModulePath = (0, resolve_cwd_1.default)(FFMPEG_MODULE_NAME);
|
||
|
return require(ffmpegModulePath).path;
|
||
|
}
|
||
|
catch (e) {
|
||
|
return '';
|
||
|
}
|
||
|
}
|
||
|
async function requireFFMPEGModule() {
|
||
|
try {
|
||
|
return require(FFMPEG_MODULE_NAME).path;
|
||
|
}
|
||
|
catch (e) {
|
||
|
return '';
|
||
|
}
|
||
|
}
|
||
|
async function default_1() {
|
||
|
return process.env.FFMPEG_PATH ||
|
||
|
await requireFFMPEGModuleFromCwd() ||
|
||
|
await requireFFMPEGModule() ||
|
||
|
await findFFMPEGinPath();
|
||
|
}
|
||
|
exports.default = default_1;
|
||
|
module.exports = exports.default;
|
||
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZGV0ZWN0LWZmbXBlZy5qcyIsInNvdXJjZ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