mirror of
https://github.com/webadderallorg/Recordly.git
synced 2026-09-25 07:16:02 +00:00
17 lines
722 B
TypeScript
17 lines
722 B
TypeScript
import path from "node:path";
|
|
|
|
export type MacCompanionAudioSuffix = "system" | "mic";
|
|
|
|
export function getFinalMacCompanionAudioPath(
|
|
videoPath: string,
|
|
sourceAudioPath: string,
|
|
suffix: MacCompanionAudioSuffix,
|
|
) {
|
|
const separatorIndex = Math.max(videoPath.lastIndexOf("/"), videoPath.lastIndexOf("\\"));
|
|
const videoDirectory = separatorIndex >= 0 ? videoPath.slice(0, separatorIndex + 1) : "";
|
|
const videoFileName = separatorIndex >= 0 ? videoPath.slice(separatorIndex + 1) : videoPath;
|
|
const videoPathWithoutExt = `${videoDirectory}${path.parse(videoFileName).name}`;
|
|
const sourceExtension = path.extname(sourceAudioPath).toLowerCase() || ".m4a";
|
|
return `${videoPathWithoutExt}.${suffix}${sourceExtension}`;
|
|
}
|