From 9c3d100196ad8ced3360d2530f99efbd119923b9 Mon Sep 17 00:00:00 2001 From: Ettore Di Giacinto Date: Sun, 19 Apr 2026 22:41:01 +0000 Subject: [PATCH] fix(stable-diffusion.ggml): force mp4 container in ffmpeg mux gen_video's ffmpeg subprocess was relying on the filename extension to choose the output container. Distributed LocalAI hands the backend a staging path (e.g. /staging/localai-output-NNN.tmp) that is renamed to .mp4 only after the backend returns, so ffmpeg saw a .tmp extension and bailed with "Unable to choose an output format". Inference had already completed and the frames were piped in, producing the cryptic "video inference failed (code 1)" at the API layer. Pass -f mp4 explicitly so the container is selected by flag instead of by filename suffix. Co-Authored-By: Claude Opus 4.7 (1M context) --- backend/go/stablediffusion-ggml/gosd.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/backend/go/stablediffusion-ggml/gosd.cpp b/backend/go/stablediffusion-ggml/gosd.cpp index ce5febe77503..17781fb66154 100644 --- a/backend/go/stablediffusion-ggml/gosd.cpp +++ b/backend/go/stablediffusion-ggml/gosd.cpp @@ -1106,6 +1106,11 @@ static int ffmpeg_mux_raw_to_mp4(sd_image_t* frames, int num_frames, int fps, co const_cast("-c:v"), const_cast("libx264"), const_cast("-pix_fmt"), const_cast("yuv420p"), const_cast("-movflags"), const_cast("+faststart"), + // Force MP4 container. Distributed LocalAI hands us a staging + // path (e.g. /staging/localai-output-NNN.tmp) with a non-standard + // extension; relying on filename suffix makes ffmpeg bail with + // "Unable to choose an output format". + const_cast("-f"), const_cast("mp4"), const_cast(dst), nullptr };