Pause/resume the active encode via SIGSTOP/SIGCONT #10

Closed
opened 2026-06-21 17:22:46 +00:00 by Kessinen · 0 comments
Owner

Let the user pause and resume the in-flight encode from the dashboard.

ffmpeg has no built-in pause, but on Linux the running process can be frozen with SIGSTOP and resumed with SIGCONT. It is the same process with all state and the partial output.mkv intact, so it resumes exactly where it left off - no re-encode, no corruption. libsvtav1 runs in-process (no forked children), so signalling the ffmpeg process suspends all its SVT-AV1 threads at once.

Wiring:

  • Encoder publishes the running *os.Process to a control handle (mutex-guarded; set on start, cleared on finish in runCmdProgress).
  • Add Pause()/Resume() that call proc.Signal(SIGSTOP/SIGCONT). Consider Setpgid + signalling the process group as belt-and-suspenders.
  • Expose POST /api/pause and /api/resume; add a button on the dashboard.
  • Add a 'paused' state to the tracker.

Caveats:

  • RAM stays resident while paused (SVT-AV1 buffers are not released - it just stops using CPU). Not a way to free memory.
  • ETA/elapsed must account for paused time or they drift (elapsed keeps ticking, speed goes stale). Freeze them while paused.
  • SIGTERM/Ctrl-C shutdown still works while paused (context-cancel uses SIGKILL, which lands on a stopped process).
  • podman pause is too coarse - it freezes the whole container (daemon + web UI), not just one encode.

Mutation, so it shares the auth consideration in #2 (deferred on the isolated network).

Let the user pause and resume the in-flight encode from the dashboard. ffmpeg has no built-in pause, but on Linux the running process can be frozen with SIGSTOP and resumed with SIGCONT. It is the same process with all state and the partial output.mkv intact, so it resumes exactly where it left off - no re-encode, no corruption. libsvtav1 runs in-process (no forked children), so signalling the ffmpeg process suspends all its SVT-AV1 threads at once. Wiring: - Encoder publishes the running *os.Process to a control handle (mutex-guarded; set on start, cleared on finish in runCmdProgress). - Add Pause()/Resume() that call proc.Signal(SIGSTOP/SIGCONT). Consider Setpgid + signalling the process group as belt-and-suspenders. - Expose POST /api/pause and /api/resume; add a button on the dashboard. - Add a 'paused' state to the tracker. Caveats: - RAM stays resident while paused (SVT-AV1 buffers are not released - it just stops using CPU). Not a way to free memory. - ETA/elapsed must account for paused time or they drift (elapsed keeps ticking, speed goes stale). Freeze them while paused. - SIGTERM/Ctrl-C shutdown still works while paused (context-cancel uses SIGKILL, which lands on a stopped process). - podman pause is too coarse - it freezes the whole container (daemon + web UI), not just one encode. Mutation, so it shares the auth consideration in #2 (deferred on the isolated network).
Kessinen added the enhancementui labels 2026-06-21 17:22:46 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Kessinen/av1dae#10