-
-
Notifications
You must be signed in to change notification settings - Fork 36
feat: add --idle-pause <time> to set the max time before idle frame optimization. Can improve readability. #267
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
- Add -i/--idle-pause CLI parameter accepting duration values (s, ms, m) - Replace frame counting with duration-based idle detection - Allow specifying a minimum idle display time before optimization begins - Add test coverage with conditional compilation for faster execution - Update README documentation with usage examples Gives viewers time to read text on screen before the animation advances to the next change, making demos easier to follow.
…uration control Previous behavior: The idle_pause feature saved idle frames up to the threshold, then skipped the remaining idle frames. The skipped time remained in the timestamps, creating large gaps between consecutive frames during playback that exceeded the specified threshold (e.g., 10+ seconds instead of 3 seconds). What changed: - Refactored frame decision logic to maintain the timeline compression invariant - Modified idle frame handling to compress the timeline for skipped frames beyond the threshold - Preserved natural pauses up to the idle_pause duration while compressing excess time - Enhanced compression state tracking for smooth playback timing - Added comprehensive test coverage for multiple idle period scenarios Technical implementation: - Maintains compressed timestamps (effective_now = now - idle_duration) for all saved frames - Skips frames when current_idle_period >= threshold and adds duration to idle_duration - Preserves backward compatibility when idle_pause = None (maximum compression mode) - Timeline compression eliminates gaps preventing jarring playback issues Files affected: - src/capture.rs: Complete fix for idle period duration control with timeline compression - Updated capture_thread() function with corrected frame decision logic - Enhanced documentation explaining terminal recording quality goals - Added 9 comprehensive test cases covering edge cases and multiple idle periods Testable: Run capture tests to verify idle periods are compressed to exact threshold durations
… test Refactored capture module tests for better maintainability: - Merged 12 individual test functions into 1 table-driven test - Extracted reusable test infrastructure (TestApi, helper functions) - Replaced magic numbers with meaningful variable names - Added docstrings to all test functions and structs - Created frame sequence generation using simple number arrays - Improved test stability by allowing for timing variations - Made test descriptions more specific about expected behavior The single parameterized test runs all previous test scenarios through a test_cases array, reducing code duplication while maintaining the same test coverage. Files changed: - src/capture.rs: Consolidated test functions, added documentation
…ove documentation Previous behavior: Tests used create_frames() function with string patterns. Frame numbering and test format were undocumented. What changed: Removed create_frames() function and used inline test data arrays. Added documentation explaining that numbers represent pixel values simulating terminal activity. Made frames() generic. Documented the 5-element tuple format and [..] slice syntax. Why: Direct inline test data is clearer than string pattern matching. Documentation helps future maintainers understand the test framework. Files affected: - src/capture.rs: Simplified test structure and added comprehensive documentation Testable: cargo test test_idle_pause
Apply rustfmt to maintain consistent code style. Removes extra blank lines in documentation comments and reformats long function calls. Files affected: - src/capture.rs: Format documentation and function calls - src/main.rs: Reformat capture_thread call parameters
Previous behavior: Documentation contained vague terms, grammatical errors, and incorrectly stated files were saved as TGA format. What changed: - src/capture.rs: Fixed file format documentation (TGA → BMP) - Simplified verbose comments while preserving technical accuracy - Clarified how idle pause parameter controls frame compression - Fixed grammar issues throughout function and test documentation Why: Documentation must accurately describe code behavior and maintain clarity for future developers. Files affected: - src/capture.rs: Updated capture_thread() and test documentation
|
I found and fixed a bug where some pauses wouldn't be clipped, I've fixed the issue and successfully tested it on a demo recording I've made. This is working really well now I have been using it for a while. |
|
@ahundt I really like your idea, thank you so much for your contribution. I'm thinking if it would not make sense to have something like 1s or 1.5s as a default that is always in place. Because it makes demos just way smoother, easier to follow. What are your thoughts? Have you found a value that works best so far for you? |
|
Cool I'm glad you liked it! Thanks! The time that's in there is the one I've been using but feel free to adjust it. It worked well for me as full pages were appearing between pauses in my case. I've been using it for a while now and I've been happy with it! |
|
Just to be sure:
You are meaning this very |
|
I double checked, it turns out I settled on 3s for my demo script. YMMV though! |
|
Could you please have a look once more at the failing tests, that would be awesome to get them green. |
Add
--idle-pause <time>the max time before idle frame optimization starts. Can improve readability.This PR adds the
--idle-pauseparameter to t-rec's existing idle optimization. This parameterallows users to specify a max duration for idle frames to be displayed before optimization
begins.
Benefits
The key benefit is giving viewers sufficient time to read the text on screen before the animation
advances to the next change. This makes demos easier to read and follow, particularly for:
Implementation Details
CLI Interface
-i, --idle-pause <s | ms | m>parameterparse_delayfunction for duration parsing--start-pauseand--end-pauseCore Logic Changes
identical_framescounter withcurrent_idle_periodduration trackingcurrent_idle_period < idle_pausethreshold is metidle_pause: Option<Duration>parameter tocapture_threadTesting
identical frames, and idle pause behavior
Usage Examples
Backward Compatibility
When
--idle-pauseis not specified, behavior remains identical to previous versions.Files Modified
src/cli.rs: Added CLI parameter definitionsrc/main.rs: Parses idle-pause argument and passes it to capture threadsrc/capture.rs: Implements duration-based idle detection and test coverageREADME.md: Documents parameter and provides usage examplesThis enhancement extends t-rec's efficient idle optimization with user-configurable timing control,
enabling recordings to give viewers adequate reading time.