refactor a bit

pull/2803/merge
Mikael Finstad 2 months ago
parent 260510615e
commit 260521b451
No known key found for this signature in database
GPG Key ID: 25AB36E3E81CBC26

@ -41,11 +41,13 @@ function escapeCliArg(arg: string) {
return /[^\w-]/.test(arg) ? `'${String(arg).replaceAll("'", '\'"\'"\'')}'` : arg;
}
export function getFfCommandLine(cmd: string, args: readonly string[]) {
export type FfCommand = 'ffmpeg' | 'ffprobe';
export function getFfCommandLine(cmd: FfCommand, args: readonly string[]) {
return `${cmd} ${args.map((arg) => escapeCliArg(arg)).join(' ')}`;
}
function getFfPath(cmd: string) {
function getFfPath(cmd: FfCommand) {
const exeName = isWindows ? `${cmd}.exe` : cmd;
if (customFfPath) return join(customFfPath, exeName);
@ -55,10 +57,12 @@ function getFfPath(cmd: string) {
}
// local dev
const components = ['ffmpeg', `${platform}-${arch}`];
if (isWindows || isLinux) components.push('lib');
components.push(exeName);
return join(...components);
return join(
'ffmpeg',
`${platform}-${arch}`,
...(isWindows || isLinux ? ['lib'] : []),
exeName,
);
}
const getFfprobePath = () => getFfPath('ffprobe');

Loading…
Cancel
Save