MCPcopy Create free account
hub / github.com/heygen-com/hyperframes / runFfprobe

Function runFfprobe

packages/engine/src/utils/ffprobe.ts:8–42  ·  view source on GitHub ↗

Spawn ffprobe with given args, return stdout. Throws on non-zero exit or missing binary.

(args: string[])

Source from the content-addressed store, hash-verified

6
7/** Spawn ffprobe with given args, return stdout. Throws on non-zero exit or missing binary. */
8function runFfprobe(args: string[]): Promise<string> {
9 return new Promise((resolve, reject) => {
10 const command = getFfprobeBinary();
11 const proc = spawn(command, args);
12 let stdout = "";
13 let stderr = "";
14 proc.stdout.on("data", (data) => {
15 stdout += data.toString();
16 });
17 proc.stderr.on("data", (data) => {
18 stderr += data.toString();
19 });
20 proc.on("close", (code) => {
21 if (code !== 0) {
22 reject(new Error(`[FFmpeg] ffprobe exited with code ${code}: ${stderr}`));
23 } else {
24 resolve(stdout);
25 }
26 });
27 proc.on("error", (err) => {
28 if ((err as NodeJS.ErrnoException).code === "ENOENT") {
29 const configured = process.env[FFPROBE_PATH_ENV]?.trim();
30 reject(
31 new Error(
32 configured
33 ? `[FFmpeg] ffprobe not found at ${FFPROBE_PATH_ENV}="${configured}". Please install FFmpeg.`
34 : "[FFmpeg] ffprobe not found. Please install FFmpeg.",
35 ),
36 );
37 } else {
38 reject(err);
39 }
40 });
41 });
42}
43
44function parseProbeJson(stdout: string): FFProbeOutput {
45 try {

Callers 3

extractMediaMetadataFunction · 0.85
extractAudioMetadataFunction · 0.85

Calls 4

getFfprobeBinaryFunction · 0.85
resolveFunction · 0.85
spawnFunction · 0.70
onMethod · 0.65

Tested by

no test coverage detected