Skip to content

Commit 4e3dda2

Browse files
committed
feat(#36): Add framerate cli option
- add a framerate cli argument `-f | --framerate` - limit the possible framerates to 4 and 8 for now - introduce new wrapper types for better readability - adjust the docs
1 parent b26a853 commit 4e3dda2

File tree

11 files changed

+313
-147
lines changed

11 files changed

+313
-147
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ log = "0.4.14"
2626
env_logger = "0.9.0"
2727
simplerand = "1.3.0"
2828
humantime = "2.1.0"
29+
crossbeam-channel = "0.5"
2930

3031
[dependencies.clap]
3132
version = "3.1.6"
@@ -52,7 +53,7 @@ e2e_tests = []
5253
section = "x11"
5354
depends = "imagemagick"
5455
extended-description = """## Features
55-
- Screenshotting your terminal with 4 frames per second (every 250ms)
56+
- Screenshotting your terminal with 4/8 frames per second
5657
- Generates high quality small sized animated gif images
5758
- **Build-In idle frames detection and optimization** (for super fluid
5859
presentations)

README.md

Lines changed: 54 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ Blazingly fast terminal recorder that generates animated gif images for the web
1818
![demo](./docs/demo.gif)
1919

2020
## Features
21-
- Screenshotting your terminal with 4 frames per second (every 250ms)
22-
- Generates high quality small sized animated gif images or mp4 videos
21+
- Screenshotting your terminal with 4/8 frames per second
22+
- Generates high-quality small-sized animated gif images or mp4 videos
2323
- **Build-In idle frames detection and optimization** (for super fluid presentations)
2424
- Applies (can be disabled) border decor effects like drop shadow
25-
- Runs on MacOS and Linux
25+
- Runs on macOS and Linux
2626
- Uses native efficient APIs
2727
- Runs without any cloud service and entirely offline
2828
- No issues with terminal sizes larger than 80x24
@@ -123,7 +123,7 @@ t-rec /bin/sh
123123
### Full Options
124124

125125
```sh
126-
t-rec 0.7.0
126+
t-rec 0.7.1
127127
Sven Assmann <sven.assmann.it@gmail.com>
128128
Blazingly fast terminal recorder that generates animated gif images for the web written in rust.
129129

@@ -135,28 +135,56 @@ ARGS:
135135
pass it here. For example '/bin/sh'
136136

137137
OPTIONS:
138-
-b, --bg <bg> Background color when decors are used [default: transparent]
139-
[possible values: white, black, transparent]
140-
-d, --decor <decor> Decorates the animation with certain, mostly border effects
141-
[default: none] [possible values: shadow, none]
142-
-e, --end-pause <s | ms | m> to specify the pause time at the end of the animation, that
143-
time the gif will show the last frame
144-
-h, --help Print help information
145-
-l, --ls-win If you want to see a list of windows available for recording
146-
by their id, you can set env var 'WINDOWID' or `--win-id` to
147-
record this specific window only
148-
-m, --video Generates additionally to the gif a mp4 video of the recording
149-
-M, --video-only Generates only a mp4 video and not gif
150-
-n, --natural If you want a very natural typing experience and disable the
151-
idle detection and sampling optimization
152-
-q, --quiet Quiet mode, suppresses the banner: 'Press Ctrl+D to end
153-
recording'
154-
-s, --start-pause <s | ms | m> to specify the pause time at the start of the animation, that
155-
time the gif will show the first frame
156-
-v, --verbose Enable verbose insights for the curious
157-
-V, --version Print version information
158-
-w, --win-id <win-id> Window Id (see --ls-win) that should be captured, instead of
159-
the current terminal
138+
-b, --bg <bg>
139+
Background color when decors are used [default: transparent] [possible values: white,
140+
black, transparent]
141+
142+
-d, --decor <decor>
143+
Decorates the animation with certain, mostly border effects [default: none] [possible
144+
values: shadow, none]
145+
146+
-e, --end-pause <s | ms | m>
147+
Specify the pause time at the end of the animation, that time the gif will show the last
148+
frame
149+
150+
-f, --framerate <frames per second>
151+
Increase the screen capturing rate (framerate) [default: 4] [possible values: 4, 8]
152+
153+
-h, --help
154+
Print help information
155+
156+
-l, --ls-win
157+
If you want to see a list of windows available for recording by their id, you can set
158+
env var 'WINDOWID' or `--win-id` to record this specific window only
159+
160+
-m, --video
161+
Generates additionally to the gif a mp4 video of the recording
162+
163+
-M, --video-only
164+
Generates only a mp4 video and not gif
165+
166+
-n, --natural
167+
If you want a very natural typing experience and disable the idle detection and sampling
168+
optimization
169+
170+
-o, --output <file>
171+
Specify the output file (without extension) [default: t-rec]
172+
173+
-q, --quiet
174+
Quiet mode, suppresses the banner: 'Press Ctrl+D to end recording'
175+
176+
-s, --start-pause <s | ms | m>
177+
Specify the pause time at the start of the animation, that time the gif will show the
178+
first frame
179+
180+
-v, --verbose
181+
Enable verbose insights for the curious
182+
183+
-V, --version
184+
Print version information
185+
186+
-w, --win-id <win-id>
187+
Window Id (see --ls-win) that should be captured, instead of the current terminal
160188
```
161189
162190
### Disable idle detection & optimization

src/capture.rs

Lines changed: 0 additions & 87 deletions
This file was deleted.

src/capture/framerate.rs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
use std::fmt::{Display, Formatter};
2+
3+
#[derive(Clone)]
4+
pub struct Framerate(u32);
5+
6+
impl Framerate {
7+
pub fn new(f: u32) -> Self {
8+
Self(f)
9+
}
10+
}
11+
12+
impl Display for Framerate {
13+
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
14+
let framerate = self.0;
15+
write!(f, "framerate {framerate} [fps]")
16+
}
17+
}
18+
19+
impl From<u32> for Framerate {
20+
fn from(fr: u32) -> Self {
21+
Self(fr)
22+
}
23+
}
24+
25+
impl AsRef<u32> for Framerate {
26+
fn as_ref(&self) -> &u32 {
27+
&self.0
28+
}
29+
}

src/capture/mod.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
mod framerate;
2+
mod processor;
3+
4+
pub use framerate::*;
5+
pub use processor::*;

0 commit comments

Comments
 (0)