Skip to content

Log capture encoder progress every 5 s (logging only) - #149

Merged
ConWan30 merged 2 commits into
mainfrom
feat/encoder-progress-log
Nov 11, 2026
Merged

ConWan30 merged 2 commits into
mainfrom
feat/encoder-progress-log

Conversation

@ConWan30

Copy link
Copy Markdown
Owner

What

Every 5 s while the capture ffmpeg runs, QorCap now writes one info line to qorcap.log:

encoder progress: frame=1234 fps=59.94 speed=0.998x dup=3 drop=1

The last block of a session (progress=end) is always logged and gets (end) at the end of the line. A field that is missing from ffmpeg's output or doesn't parse is left out. Nothing is made up.

Why

Practice match 201238 dropped about 7.7 s of frames: 4,472 "frame dropped" warnings, with the Elgato buffer at 100% from 8:13:14 PM CST. Right now the log can't tell us whether the encoder fell behind (fps and speed drop) or the capture thread stalled (fps and speed hold steady while frames drop). This line answers that.

Where the data comes from

  • The capture ffmpeg is already started with -stats_period 1 -progress pipe:2 (src/ffmpeg.rs). Its stderr is already drained by its own thread in run_capture_once (src/engine.rs). That thread already reads frame, fps, dup_frames and drop_frames into /status.
  • This PR adds a ProgressLog (src/encprog.rs) on that same thread. It takes the same key=value pairs and returns at most one line every 5 s. It reads time from a thread-local Instant.
  • ffmpeg argv is unchanged. No new pipe, thread, lock or dependency. The capture/stdout thread is untouched.
  • If a whole -stats line (frame= 1234 fps= 30 ... speed=1.00x) ever reaches this thread, it's parsed too. With -loglevel warning ffmpeg doesn't print those lines.

Tests

  • 6 new unit tests in encprog:
    • a progress block renders one line
    • the 5 s limit, tested with an injected clock (lines at 0/5/10/15/20 s; nothing at 4.999 s)
    • the end block is always logged
    • missing fields are left out, and values from one block don't carry into the next
    • -stats lines are parsed
    • garbage input and backwards or huge clock values never panic and never produce a field
  • cargo build --locked ✅
  • cargo build --release --locked ✅
  • QORTIME=<qortime 0204 pin> cargo test --locked: lib 202 (base 196, +6), main 1, contracts 2, haptic_replay 1, redteam 2 ✅
  • cargo clippy --all-targets --locked: 46 warning lines, the same as base 506a3bc, and none in the new code.
  • Tested on Linux only. The code is platform-neutral.

Scope

Logging only, no behavior change. receipt.v0, contracts/, schema/, the recording/manifest/checkpoint/seal path and the live tap are untouched. REAL MATCH behaves the same apart from the extra log line.

Draft. Merge only on Con's word.

Condense the capture ffmpeg's existing -progress pipe:2 blocks (already drained
by the stderr thread) into one qorcap.log line at most every 5 s:
  encoder progress: frame=1234 fps=59.94 speed=0.998x dup=3 drop=1
Fields missing or unparsable in ffmpeg's output are omitted. ffmpeg argv,
recording, manifest, checkpoint, seal, live tap, receipt.v0 and contracts/
are unchanged. No new dependencies.
@ConWan30
ConWan30 marked this pull request as ready for review November 11, 2026 03:01
@ConWan30
ConWan30 merged commit e8509dc into main Nov 11, 2026
3 checks passed
@ConWan30
ConWan30 deleted the feat/encoder-progress-log branch November 11, 2026 03:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant