-
-
Notifications
You must be signed in to change notification settings - Fork 35
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
Open
ahundt
wants to merge
7
commits into
sassman:main
Choose a base branch
from
ahundt:feat/idle-pause-parameter
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+393
−32
Conversation
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
- 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 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. |
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.
Add
--idle-pause <time>
the max time before idle frame optimization starts. Can improve readability.This PR adds the
--idle-pause
parameter 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_delay
function for duration parsing--start-pause
and--end-pause
Core Logic Changes
identical_frames
counter withcurrent_idle_period
duration trackingcurrent_idle_period < idle_pause
threshold is metidle_pause: Option<Duration>
parameter tocapture_thread
Testing
identical frames, and idle pause behavior
Usage Examples
Backward Compatibility
When
--idle-pause
is 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.