Repository navigation
feat: smaller task recordings (Settings › Privacy › Recording size) - #127
Merged
Merged
Conversation
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>
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.
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 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:
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 ofinternal/driver/iosso the recorder can use it.Flushfor Media Foundation, which holds pictures back.video.Decoder.ScaleNV12: scales the last picture to NV12 in BT.601 video range. It sharestoI420'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.internal/gateway/shrink.go):SetSmallerRecordings(on)and one worker that shrinks recordings as their tasks end, one at a time.history.ReplaceRecordingrenames 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..partis removed the next time a recording is shrunk.SmallerRecordingssetting, 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 checkpasses;CGO_ENABLED=0builds pass for darwin, windows and linux, andgo vetpasses for windows.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, andRemoveRecordingTemps.scripts/devlock.sh, in Settings on a background display, and shrunk with this code.Existing recordings are not shrunk; only recordings that finish from now on are.
🤖 Generated with Claude Code