Local-spawn recorder stop lacks finalize grace → corrupt MP4 / stuck-live (pre-existing) #162

Open
opened 2026-05-29 14:03:12 -04:00 by zgaetano · 0 comments
Owner

Found during NVENC regression testing (not caused by that work).

1. No stop grace period

routes/recorders.js POST /:id/stop local branch (~line 592) issues POST /containers/<id>/stop (Docker default 10s → SIGKILL) then immediately DELETEs the container. The remote sidecar path (node-agent handleSidecarStop) uses stop?t=180, giving the capture's SIGTERM handler time to finalize ffmpeg + call POST /assets/:id/finalize.

Result on local-spawn: the live asset can stay stuck live (finalize never fires).

2. PCM-in-MP4 produces an undecodable master

A recorder with recording_codec=h264 + recording_container=mp4 but the default recording_audio_codec=pcm_s24le writes audio as ipcm in MP4. ffmpeg reads it back as Audio: none → proxy worker fails: Decoder (codec none) not found for input stream. (ProRes/MOV + PCM is fine — that's why SDI recorders work.)

Suggested fixes

  • Give the local-spawn stop the same 180s grace as the remote path (/containers/<id>/stop?t=180), and wait for finalize before removing the container.
  • Guard codec/container/audio combinations: MP4 ⇒ AAC audio (reject or coerce PCM-in-MP4) in the recorder create/validate layer.

Repro

Create an SRT/RTMP listener recorder on the mam-api host node with h264/mp4 and default audio; push a stream; stop → asset stuck live, and retry → error (corrupt/undecodable master).

🤖 Generated with Claude Code

Found during NVENC regression testing (not caused by that work). ## Two related issues on the **local-spawn** capture path (recorder `node_id` = the mam-api host, e.g. zampp1) ### 1. No stop grace period `routes/recorders.js` `POST /:id/stop` local branch (~line 592) issues `POST /containers/<id>/stop` (Docker default **10s** → SIGKILL) then immediately `DELETE`s the container. The **remote sidecar path** (node-agent `handleSidecarStop`) uses `stop?t=180`, giving the capture's SIGTERM handler time to finalize ffmpeg + call `POST /assets/:id/finalize`. Result on local-spawn: the live asset can stay stuck `live` (finalize never fires). ### 2. PCM-in-MP4 produces an undecodable master A recorder with `recording_codec=h264` + `recording_container=mp4` but the default `recording_audio_codec=pcm_s24le` writes audio as `ipcm` in MP4. ffmpeg reads it back as `Audio: none` → proxy worker fails: `Decoder (codec none) not found for input stream`. (ProRes/MOV + PCM is fine — that's why SDI recorders work.) ## Suggested fixes - Give the local-spawn stop the same 180s grace as the remote path (`/containers/<id>/stop?t=180`), and wait for finalize before removing the container. - Guard codec/container/audio combinations: MP4 ⇒ AAC audio (reject or coerce PCM-in-MP4) in the recorder create/validate layer. ## Repro Create an SRT/RTMP listener recorder on the mam-api host node with h264/mp4 and default audio; push a stream; stop → asset stuck `live`, and retry → `error` (corrupt/undecodable master). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: WildDragonLLC/dragonflight#162
No description provided.