Skip to content

Commit

Permalink
feat(#36): Add framerate cli option
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
sassman committed Mar 27, 2022
1 parent b26a853 commit 4e3dda2
Show file tree
Hide file tree
Showing 11 changed files with 313 additions and 147 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ log = "0.4.14"
env_logger = "0.9.0"
simplerand = "1.3.0"
humantime = "2.1.0"
crossbeam-channel = "0.5"

[dependencies.clap]
version = "3.1.6"
Expand All @@ -52,7 +53,7 @@ e2e_tests = []
section = "x11"
depends = "imagemagick"
extended-description = """## Features
- Screenshotting your terminal with 4 frames per second (every 250ms)
- Screenshotting your terminal with 4/8 frames per second
- Generates high quality small sized animated gif images
- **Build-In idle frames detection and optimization** (for super fluid
presentations)
Expand Down
80 changes: 54 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ Blazingly fast terminal recorder that generates animated gif images for the web
![demo](./docs/demo.gif)

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

```sh
t-rec 0.7.0
t-rec 0.7.1
Sven Assmann <[email protected]>
Blazingly fast terminal recorder that generates animated gif images for the web written in rust.

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

OPTIONS:
-b, --bg <bg> Background color when decors are used [default: transparent]
[possible values: white, black, transparent]
-d, --decor <decor> Decorates the animation with certain, mostly border effects
[default: none] [possible values: shadow, none]
-e, --end-pause <s | ms | m> to specify the pause time at the end of the animation, that
time the gif will show the last frame
-h, --help Print help information
-l, --ls-win If you want to see a list of windows available for recording
by their id, you can set env var 'WINDOWID' or `--win-id` to
record this specific window only
-m, --video Generates additionally to the gif a mp4 video of the recording
-M, --video-only Generates only a mp4 video and not gif
-n, --natural If you want a very natural typing experience and disable the
idle detection and sampling optimization
-q, --quiet Quiet mode, suppresses the banner: 'Press Ctrl+D to end
recording'
-s, --start-pause <s | ms | m> to specify the pause time at the start of the animation, that
time the gif will show the first frame
-v, --verbose Enable verbose insights for the curious
-V, --version Print version information
-w, --win-id <win-id> Window Id (see --ls-win) that should be captured, instead of
the current terminal
-b, --bg <bg>
Background color when decors are used [default: transparent] [possible values: white,
black, transparent]

-d, --decor <decor>
Decorates the animation with certain, mostly border effects [default: none] [possible
values: shadow, none]

-e, --end-pause <s | ms | m>
Specify the pause time at the end of the animation, that time the gif will show the last
frame

-f, --framerate <frames per second>
Increase the screen capturing rate (framerate) [default: 4] [possible values: 4, 8]

-h, --help
Print help information

-l, --ls-win
If you want to see a list of windows available for recording by their id, you can set
env var 'WINDOWID' or `--win-id` to record this specific window only

-m, --video
Generates additionally to the gif a mp4 video of the recording

-M, --video-only
Generates only a mp4 video and not gif

-n, --natural
If you want a very natural typing experience and disable the idle detection and sampling
optimization

-o, --output <file>
Specify the output file (without extension) [default: t-rec]

-q, --quiet
Quiet mode, suppresses the banner: 'Press Ctrl+D to end recording'

-s, --start-pause <s | ms | m>
Specify the pause time at the start of the animation, that time the gif will show the
first frame

-v, --verbose
Enable verbose insights for the curious

-V, --version
Print version information

-w, --win-id <win-id>
Window Id (see --ls-win) that should be captured, instead of the current terminal
```
### Disable idle detection & optimization
Expand Down
87 changes: 0 additions & 87 deletions src/capture.rs

This file was deleted.

29 changes: 29 additions & 0 deletions src/capture/framerate.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
use std::fmt::{Display, Formatter};

#[derive(Clone)]
pub struct Framerate(u32);

impl Framerate {
pub fn new(f: u32) -> Self {
Self(f)
}
}

impl Display for Framerate {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
let framerate = self.0;
write!(f, "framerate {framerate} [fps]")
}
}

impl From<u32> for Framerate {
fn from(fr: u32) -> Self {
Self(fr)
}
}

impl AsRef<u32> for Framerate {
fn as_ref(&self) -> &u32 {
&self.0
}
}
5 changes: 5 additions & 0 deletions src/capture/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
mod framerate;
mod processor;

pub use framerate::*;
pub use processor::*;
Loading

0 comments on commit 4e3dda2

Please sign in to comment.