Add named markers to replay recordings as MP4 chapters#289
Draft
rgarcia wants to merge 2 commits into
Draft
Conversation
Add a Mark(name) API to the recorder and a POST /recording/mark endpoint that records named, timestamped markers during an active recording. At finalize the markers are written into the output MP4 as chapter markers via an ffmetadata input, so they can be scrubbed to in any tool that reads MP4 chapters (ffprobe, QuickTime, VLC, NLEs). The feature is additive and backwards-compatible: with no markers the remux command is byte-identical to before, and any marker/metadata failure falls back to the plain remux so a recording is never corrupted. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Contributor
Author
Independent review — replay markers as MP4 chaptersReviewed the full diff, read all changed files, rebuilt, ran unit + integration tests, and verified a few correctness concerns with real ffmpeg/ffprobe. Not blocking — the core mechanism is sound and well-tested. A few minor items below. Verified correct
Minor / nits
Build green, |
buildChapterMetadata always received 0 for the origin shift, so remove the parameter, its drop-when-shifted branch, and the corresponding test. Chapter starts are now computed directly from each marker's offset. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds named, timestamped markers to screen recordings. A marker records a point in time during an active recording; at finalize the markers are injected into the output MP4 as chapter markers, so users can scrub/crop to them in post (ffprobe
-show_chapters, QuickTime, VLC, and most NLEs all read MP4 chapters).The feature is purely additive and backwards-compatible.
Why
Recordings are currently opaque blobs — there's no way to flag "the interesting thing happened here" while a session runs. MP4 chapters are the standard, tool-agnostic way to annotate timeline positions, so a marker dropped during recording survives into the downloaded file with no extra sidecar.
API
New endpoint
POST /recording/mark:{ "name": string (required), "id"?: string }201{ "name": string, "offsetMs": integer }on success409when no recording is in progress400for an empty/oversized name or missing bodyoffsetMsis documented as provisional (measured against the recording start time at mark time); the authoritative offset is the chapter start computed at finalize.How
Mark(name)on the recorder appends a marker under the existing mutex and is safe under concurrent calls.TIMEBASE=1/1000chapters, special characters escaped) and passed as a second input with-map 0 -map_chapters 1. A sentinel chapter is prepended atSTART=0because ffmpeg forces the first chapter to start at 0 — without it the first real marker's timestamp would be clamped.lib/oapi/oapi.gowas regenerated viamake oapi-generate(openapi-down-convert + oapi-codegen), not hand-edited.Tests
START=0, integerSTART/ENDtiling, negative-offset markers dropped, ascending ordering, special-character escaping, and a nonzero origin-shift parameter.Mark(): 409 path when not recording, trim/validation, and concurrency (run under-race).-map_chaptersis injected only when markers are present.testsrc, no display needed) that records a synthetic clip, marks at known offsets, finalizes, and asserts viaffprobe -show_chaptersthat chapters land within ~1.5 frame intervals.go vet ./...,go build ./..., and the full non-e2e suite (go test -race) pass locally.