From 08f556986a5a74a8425100813951697d169b4d31 Mon Sep 17 00:00:00 2001 From: abhinav-atul Date: Sun, 31 May 2026 02:13:43 +0530 Subject: [PATCH] fix: replace invalid fontweight param with bold=1 and fix fontfile set to name instead of path --- src/lib/text-overlay.ts | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/lib/text-overlay.ts b/src/lib/text-overlay.ts index b7ca5c5c..ae3981db 100644 --- a/src/lib/text-overlay.ts +++ b/src/lib/text-overlay.ts @@ -89,16 +89,19 @@ export function buildTextFilter( const fontFileParam = getFFmpegFontArg(overlay.fontFamily, overlay.fontPath); // Build the drawtext filter with font support - let filter = `drawtext=text='${escapedText}':x=${pixelX}:y=${pixelY}:fontsize=${overlay.fontSize}:fontcolor=${overlay.color}:fontweight=${fontWeightParam}`; + let filter = `drawtext=text='${escapedText}':x=${pixelX}:y=${pixelY}:fontsize=${overlay.fontSize}:fontcolor=${overlay.color}`; - // Add font family if specified - if (overlay.fontFamily) { - // Sanitize font name for FFmpeg - const safeFontName = overlay.fontFamily.replace(/[^a-zA-Z0-9-]/g, ""); - filter += `:fontfile='${safeFontName}'`; + // Add bold flag only when font weight is bold (fontweight= is not a valid FFmpeg option) + if (fontWeightParam === "bold") { + filter += `:bold=1`; + } + + // For system fonts (no custom fontfile), use font= with the family name + // For custom fonts, use only the fontfile= path from getFFmpegFontArg + if (overlay.fontFamily && !fontFileParam) { + filter += `:font='${overlay.fontFamily}'`; } - // Add custom font file path if available if (fontFileParam) { filter += `:${fontFileParam}`; }