Skip to content

HarnessRouter Community Edition: the self-hosted, Apache-2.0 edition of the unified interface for agent harnesses. Run Codex, Claude Code, Hermes, PI, DSH, and more through one API, with sessions, streaming, files, cancellation, and failure handling. Implements the Unified Harness Protocol (UHP), an open standard. Your keys, your infrastructure.

feat(media): a still can be in a cut

richard-epsillac74b486a8137
diff --git a/gateway/app.py b/gateway/app.py
index 9e630400..59e6f378 100644
--- a/gateway/app.py
+++ b/gateway/app.py
@@ -7722,6 +7722,9 @@ def _uhp_message(e: HTTPException) -> str:
_MEDIA_SERVER = "media"
_MEDIA_SCENE_FILE = "scene.excalidraw"
+# How long a still is held when the cut does not say. Not a measurement — a still has no
+# length of its own — so it is a stated default rather than a number pretending to be one.
+STILL_HOLD_S = 3.0
# Candidates stood down after a BILLABLE failure. Per-replica and in memory on purpose: it is a
# hint that saves money, not state anything depends on, and a replica that has not seen the
# failure simply pays for one more attempt rather than serving a stale verdict for half an hour.
@@ -9786,8 +9789,13 @@ async def _media_export_start(hid: str, sid: str, org: str, entry_id: str,
raise media_plane.ExportRefused(
f"Shot {i} is still rendering. Every shot has to have landed before the film can "
f"be cut.")
+ # A still carries no `seconds`, so its hold comes from the SHOT. Falling through to 0 is
+ # what made an image in the cut fail the whole export.
+ out_s = s.get("outS")
+ if out_s is None:
+ out_s = m.get("seconds") or (STILL_HOLD_S if m.get("kind") == "image" else 0.0)
plan.append({"media_id": str(m["mediaId"]), "in_s": float(s.get("inS") or 0.0),
- "out_s": float(s.get("outS") or m.get("seconds") or 0.0)})
+ "out_s": float(out_s or 0.0)})
total = media_plane.timeline_total(scene)
if total > float(cap.get("max_total_s") or 600):
raise media_plane.ExportRefused(
diff --git a/gateway/media_plane.py b/gateway/media_plane.py
index 81a235ad..059214cf 100644
--- a/gateway/media_plane.py
+++ b/gateway/media_plane.py
@@ -1532,6 +1532,31 @@ def assemble(shots: list[dict], audio: list[dict], *, fps: int, resolution: str,
start = max(0.0, float(shot.get("in_s") or 0.0))
end = float(shot.get("out_s") or dur or 0.0) or dur
end = min(end, dur) if dur else end
+
+ # A STILL HAS NO DURATION OF ITS OWN, so the CUT decides how long it is shown. ffprobe
+ # reports 0 seconds for a png, which used to make this refuse the whole film with "shot N
+ # has no length" — the still was in the timeline, the export was impossible, and nothing
+ # said the two facts were connected. `-loop 1 -t` is what turns one frame into a segment.
+ still = dur <= 0 and not info.get("has_audio")
+ if still:
+ hold = float(shot.get("out_s") or 0.0) - start
+ if hold <= 0:
+ raise ExportRefused(
+ f"Shot {i + 1} is a still and nothing says how long to hold it. Give it a "
+ f"duration on the timeline.")
+ planned += hold
+ inputs += ["-loop", "1", "-t", f"{hold:.3f}", "-i", path]
+ filters.append(
+ f"[{i}:v]scale={W}:{H}:force_original_aspect_ratio=decrease,"
+ f"pad={W}:{H}:(ow-iw)/2:(oh-ih)/2:color=black,fps={fps},setsar=1,"
+ f"format=yuv420p[v{i}]")
+ filters.append(f"anullsrc=r=48000:cl=stereo,atrim=0:{hold:.3f},"
+ f"asetpts=PTS-STARTPTS[a{i}]")
+ concat_in += f"[v{i}][a{i}]"
+ if on_progress:
+ on_progress(i, len(shots))
+ continue
+
if end <= start:
raise ExportRefused(f"Shot {i + 1} has no length between {start}s and {end}s.")
planned += end - start