Skip to content

Open-source AI podcast clipper. Generate vertical clips with face tracking and burned-in captions. CLI, MCP server, web app.

Scale the Remotion render timeout to the clip instead of hardcoding it (#200)

Nika Siradzed3f5478e9efc
diff --git a/backend/services/clip_generator.py b/backend/services/clip_generator.py
index e212fb2..d2ec2f5 100644
--- a/backend/services/clip_generator.py
+++ b/backend/services/clip_generator.py
@@ -704,12 +704,20 @@ def _render_with_remotion(
# not happen, and what it threw away was the only description of the
# failure. Every clip on the Linux worker fell back to burned-in ASS
# for months and the reason went to /dev/null with the rest of it.
+ #
+ # Above render.mjs's own worst case, not just its per-phase one: it
+ # budgets selectComposition and renderMedia separately, up to 50
+ # minutes each, and a slow first phase does not borrow from the
+ # second. Sized for both back to back plus a buffer, so a render that
+ # is genuinely just slow times out inside Remotion with an actionable
+ # message, rather than being hard-killed here first with nothing but
+ # "TimeoutExpired" to say why.
result = subprocess.run(
cmd,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
text=True,
- timeout=600,
+ timeout=2 * 50 * 60 + 300,
cwd=project_root,
env=remotion_env,
)
diff --git a/remotion/render.mjs b/remotion/render.mjs
index 77e0694..b56dd32 100644
--- a/remotion/render.mjs
+++ b/remotion/render.mjs
@@ -65,7 +65,20 @@ function clampLogoScale(raw) {
// Remotion's 30s default is measured against the font delayRender in Root.tsx,
// which competes with evaluating the whole bundle. That bundle has three
// compositions now, and the slowest CI runner does not finish inside 30s.
-const DELAY_RENDER_TIMEOUT_MS = 120_000;
+//
+// A fixed cap on top of that was wrong in the other direction: a card-heavy
+// clip renders roughly 13x slower than realtime on the container's actual CPU
+// quota, not the few seconds a bundle load costs, and a 120s ceiling killed
+// the render itself mid-flight, not just a slow font load — the "delayRender
+// not cleared" it reported was a symptom of the whole page stalling under
+// load, not a broken font. Scaled to the clip so a 3-second clip still fails
+// fast and a full-length one gets the minutes it actually needs; overridable
+// for a box whose real throughput has already been measured.
+const timeoutFor = (durationSec) => {
+ const override = parseInt(process.env.PODCLI_REMOTION_TIMEOUT_MS ?? "", 10);
+ if (Number.isFinite(override)) return Math.max(1, override);
+ return Math.min(50 * 60_000, Math.max(120_000, 90_000 + durationSec * 15_000));
+};
async function main() {
const opts = parseArgs();
@@ -304,7 +317,7 @@ async function main() {
serveUrl: bundleLocation,
id: "CaptionedClip",
inputProps,
- timeoutInMilliseconds: DELAY_RENDER_TIMEOUT_MS,
+ timeoutInMilliseconds: timeoutFor(durationSec),
browserExecutable,
chromeMode,
});
@@ -347,7 +360,7 @@ async function main() {
outputLocation: captionOverlay,
inputProps,
concurrency,
- timeoutInMilliseconds: DELAY_RENDER_TIMEOUT_MS,
+ timeoutInMilliseconds: timeoutFor(durationSec),
onProgress: ({ progress }) => {
const pct = Math.round(progress * 100);
if (pct > lastPct + 9) {