All checks were successful
Deploy / build-and-deploy (push) Successful in 1m44s
19 lines
525 B
TypeScript
19 lines
525 B
TypeScript
import { execSync } from "child_process";
|
|
|
|
/**
|
|
* Convert any audio/video file to a 6-second compressed MP3 via ffmpeg.
|
|
* Returns true on success, false on failure.
|
|
* The output file is always mp3Path (overwritten if exists).
|
|
*/
|
|
export function convertToCompressedMp3(inputPath: string, mp3Path: string): boolean {
|
|
try {
|
|
execSync(
|
|
`ffmpeg -i "${inputPath}" -t 6 -vn -codec:a libmp3lame -b:a 64k -y "${mp3Path}" 2>/dev/null`,
|
|
{ timeout: 30000 }
|
|
);
|
|
return true;
|
|
} catch {
|
|
return false;
|
|
}
|
|
}
|