Skip to content

feat: smaller task recordings (Settings › Privacy › Recording size) - #127

Merged
DIYgod merged 5 commits into
mainfrom
claude/blissful-austin-02ed0a
Nov 14, 2026
Merged

DIYgod merged 5 commits into
mainfrom
claude/blissful-austin-02ed0a

Conversation

@DIYgod

@DIYgod DIYgod commented Nov 14, 2026

Copy link
Copy Markdown
Owner

Closes #125.

Recordings took 11.6 MB a minute on an iPhone 13 mini (the average over 20 real tasks, sizes read from the history only) and 17.7 MB a minute on a Mi 10 Pro (a 2-minute test of Settings scrolling). That is 21 to 32 GB a month for an hour of tasks a day.

This adds Settings › Privacy › Recording size: Smaller (the default) or Original. With Smaller, each finished recording is encoded again in the background:

  • the long side at most 1280 px;
  • at most 10 pictures a second, always keeping the last picture of a burst so the screen a step settled on stays in;
  • H.264 at 800 kbit/s.

The smaller file then replaces the original. On the Mi 10 Pro clip it goes from 17.7 to 3.0 MB a minute (5.8× smaller), and the smallest text in Settings stays as readable as in the original. docs/notes/recording-size.md has the measurements and why the other two approaches were rejected:

  • A smaller phone stream would blur the live mirror and the OCR frames, and iOS 27's stream takes no bit rate.
  • Dropping still stretches saves nothing: phones already send no frames while the screen is still.

Changes

  • internal/h264enc (new): the iPhone driver's H.264 encoder (VideoToolbox through purego on macOS; FFmpeg's OpenH264 or Media Foundation encoder on Windows), moved out of internal/driver/ios so the recorder can use it.
    • New options: bit rate, key-frame interval, offline mode.
    • New Flush for Media Foundation, which holds pictures back.
    • The iOS driver uses it as before (same 15 fps, 2.5 Mbit/s).
  • video.Decoder.ScaleNV12: scales the last picture to NV12 in BT.601 video range. It shares toI420's swscale path, including the BT.709 fallback for the Mi 10 Pro's YCgCo.
  • recording.Shrink: decodes, caps the frame rate, scales and encodes, keeping times, turns and size changes from rotations.
  • Gateway (internal/gateway/shrink.go): SetSmallerRecordings(on) and one worker that shrinks recordings as their tasks end, one at a time.
    • history.ReplaceRecording renames the new file over the original and updates the row under the store's lock, only while the task still has that recording. A task deleted during the encode never gets its file back.
    • The original stays when the new file would be larger, when the rename fails (Windows, a replay open), or when Pinky quits first. A leftover .part is removed the next time a recording is shrunk.
    • Linux has no encoder, so recordings stay as recorded there and the gateway logs that once.
  • Settings: a SmallerRecordings setting, on by default (an existing settings file without the key gets it on), passed at start and on change by the app and the daemon. It appears in the diagnostics line, and its messages are in en, zh-Hans and ja.

Tests

  • make check passes; CGO_ENABLED=0 builds pass for darwin, windows and linux, and go vet passes for windows.
  • New tests:
    • recording.Shrink: H.264 and HEVC sources, frame cap, last picture kept, length; turns and a size change; cancellation.
    • fitSize.
    • history.ReplaceRecording, including a task deleted meanwhile, and RemoveRecordingTemps.
    • Gateway Smaller and Original end to end.
  • Real phones:
    • The Mi 10 Pro clip was recorded under scripts/devlock.sh, in Settings on a background display, and shrunk with this code.
    • The iPhone was locked, so its test skipped without touching it. The iPhone "after" figure (about 2.5 to 3 MB a minute) is an estimate.
    • All scratch recordings are deleted.

Existing recordings are not shrunk; only recordings that finish from now on are.

🤖 Generated with Claude Code

DIYgod and others added 5 commits November 14, 2026 21:51
The recorder will use it to shrink recordings, so it moves out of the iOS
driver into a package of its own with options for the bit rate, key frame
interval and offline encoding, and a Flush for encoders that hold pictures
back.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Shrink decodes a recording, keeps at most a set number of pictures a
second (always the last of a burst), scales it down and encodes it in
H.264 with internal/h264enc, keeping its times and turns.
Decoder.ScaleNV12 gives the scaled pictures.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With SetSmallerRecordings on, a worker encodes each finished task's
recording again with recording.Smaller and puts it in the original's
place through history.ReplaceRecording, which checks the task still has
that recording, so a deleted task never gets its file back.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Settings › Privacy gets Recording size under Record the screen: Smaller,
the default, has the gateway make each finished recording smaller;
Original keeps the phone's stream. docs/notes/recording-size.md measures
both and explains why the recording is encoded again after the task
rather than asking the phone for a smaller stream or dropping still
stretches.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@DIYgod
DIYgod merged commit 46e5428 into main Nov 14, 2026
3 checks passed
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