fix(studio): add FFmpeg pre-flight check before render (#1100)

* fix(studio): add FFmpeg pre-flight check before starting render

Studio renders now fail fast with a 422 and an actionable FFmpeg
install hint instead of burning through the entire capture pipeline
before hitting "spawn ffmpeg ENOENT" at encode.

* fix(studio): address review — use 503, memoize FFmpeg lookup
This commit is contained in:
Miguel Ángel
2026-05-27 20:20:21 -04:00
committed by GitHub
parent d83a873986
commit dc4671dee6
+16
View File
@@ -508,6 +508,22 @@ export function createStudioServer(options: StudioServerOptions): StudioServer {
});
});
// ── Pre-flight checks for render ────────────────────────────────────────
// Intercept render requests before they reach the shared API so we can
// fail fast with an actionable hint instead of burning through the entire
// capture pipeline before hitting "spawn ffmpeg ENOENT" at encode.
let cachedFFmpegPath: string | undefined;
app.post("/api/projects/:id/render", async (c, next) => {
const { findFFmpeg, getFFmpegInstallHint } = await import("../browser/ffmpeg.js");
if (!cachedFFmpegPath) {
cachedFFmpegPath = findFFmpeg();
}
if (!cachedFFmpegPath) {
return c.json({ error: "FFmpeg not found", hint: getFFmpegInstallHint() }, 503);
}
return next();
});
// Mount the shared studio API at /api.
// Use fetch() forwarding (not .route()) so the sub-app sees paths without
// the /api prefix — the shared module's path extraction uses c.req.path.