mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-11-21 08:01:39 +01:00
feat(capture): record the screen
Screen capture behind a `CaptureBackend`: ScreenCaptureKit and AVFoundation on macOS (HEVC by default), Windows Graphics Capture and a Media Foundation writer on Windows (H.264). Each display is written as fragmented mp4 in segments with every frame's master-clock timestamp, and a manager decides, from what the backend reports, when a segment ends and another begins. The segment logic is shared by both backends and tested without a screen.
This commit is contained in:
1 parent
9d35869f88
commit
fb11cb2db9
19 files changed
+6166
-1
No files matched your search
@@ -75,6 +75,14 @@ The files beside it are the raw records, and they are written as the data arrive
|
||||
(`komorebi.log`, the exact byte range recorded), its events (`events.jsonl`, with full `State` snapshots in `states/`
|
||||
only when they changed), and what happened to the recording itself (`recorder.jsonl`).
|
||||
The OS trace is under `oslog/`, one file per stream.
|
||||
Each display's video is `video-<id>[-<n>].mp4` with a `frames-<id>[-<n>].csv` beside it holding every frame's timestamp,
|
||||
one segment to a file: a display that is unplugged and returns starts a new segment instead of extending the old one.
|
||||
|
||||
## Recording
|
||||
|
||||
The recorder starts its sources in an order that makes the sources that are not video a superset of the video's span
|
||||
(the clock anchor, the OS trace streams, the subscription to komorebi and its first `State`, komorebi's log offset, and
|
||||
last the video), and stops them in the reverse order.
|
||||
|
||||
## Rules and the layer that enforces them
|
||||
|
||||
|
||||
@@ -46,6 +46,21 @@ Video frame times and the OS trace are on the master clock already on both hosts
|
||||
`machTimestamp` on a Mac; Windows.Graphics.Capture on Windows). The field names ending in `_mach_ns` are spelled that way
|
||||
on every host: see [the architecture](ARCHITECTURE.md#the-master-clock).
|
||||
|
||||
### Capturing the screen
|
||||
|
||||
| | macOS | Windows |
|
||||
|---|---|---|
|
||||
| API | ScreenCaptureKit, through `objc2` bindings, and AVFoundation's `AVAssetWriter` | Windows.Graphics.Capture (Windows 10 version 1803 or later), and a Media Foundation MP4 sink |
|
||||
| permission | Screen Recording, granted to the terminal or app that launches the binary | none |
|
||||
| default codec | HEVC | H.264 |
|
||||
| other codec | H.264 (`--codec h264`) | HEVC is refused with an error: Media Foundation's MP4 sink does not write it |
|
||||
| what is captured | each display, excluding the recorder's own processes by name | each monitor whole, so the program's windows ask to be left out (see below) |
|
||||
| a still screen | a healthy stream still calls back about 30 times a second, so silence for four seconds means a stalled stream | Windows sends nothing while the picture does not change, so silence says nothing there |
|
||||
|
||||
The video of a display is written as fragmented MP4 on both hosts, in segments, so that the part written before a crash
|
||||
can still be played. Because ScreenCaptureKit only emits frames when the screen changes, the macOS capture re-submits the
|
||||
last frame so that a static display still flushes fragments.
|
||||
|
||||
### The OS trace
|
||||
|
||||
| | macOS | Windows |
|
||||
|
||||
Reference in new issue
Block a user