Skip to content

Commit dc4671d

Browse files
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
1 parent d83a873 commit dc4671d

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

packages/cli/src/server/studioServer.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -508,6 +508,22 @@ export function createStudioServer(options: StudioServerOptions): StudioServer {
508508
});
509509
});
510510

511+
// ── Pre-flight checks for render ────────────────────────────────────────
512+
// Intercept render requests before they reach the shared API so we can
513+
// fail fast with an actionable hint instead of burning through the entire
514+
// capture pipeline before hitting "spawn ffmpeg ENOENT" at encode.
515+
let cachedFFmpegPath: string | undefined;
516+
app.post("/api/projects/:id/render", async (c, next) => {
517+
const { findFFmpeg, getFFmpegInstallHint } = await import("../browser/ffmpeg.js");
518+
if (!cachedFFmpegPath) {
519+
cachedFFmpegPath = findFFmpeg();
520+
}
521+
if (!cachedFFmpegPath) {
522+
return c.json({ error: "FFmpeg not found", hint: getFFmpegInstallHint() }, 503);
523+
}
524+
return next();
525+
});
526+
511527
// Mount the shared studio API at /api.
512528
// Use fetch() forwarding (not .route()) so the sub-app sees paths without
513529
// the /api prefix — the shared module's path extraction uses c.req.path.

0 commit comments

Comments
 (0)