Skip to content

Commit 850f185

Browse files
committed
Add configurable timeout to audio extraction
1 parent 108a110 commit 850f185

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

apps/media-server/src/lib/ffmpeg.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ export interface AudioExtractionOptions {
44
format?: "mp3";
55
codec?: "libmp3lame";
66
bitrate?: string;
7+
timeoutMs?: number;
78
}
89

910
const DEFAULT_OPTIONS: Required<AudioExtractionOptions> = {
@@ -240,6 +241,7 @@ export function extractAudioStream(
240241
activeProcesses++;
241242

242243
const opts = { ...DEFAULT_OPTIONS, ...options };
244+
const timeout = options.timeoutMs ?? EXTRACT_TIMEOUT_MS;
243245

244246
const ffmpegArgs = [
245247
"ffmpeg",
@@ -283,7 +285,7 @@ export function extractAudioStream(
283285
timeoutId = setTimeout(() => {
284286
console.error("[ffmpeg] Stream extraction timed out");
285287
cleanup();
286-
}, EXTRACT_TIMEOUT_MS);
288+
}, timeout);
287289

288290
drainStream(proc.stderr as ReadableStream<Uint8Array>);
289291

0 commit comments

Comments
 (0)