diff --git a/README.md b/README.md index 818de71..babf4aa 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ 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) +- Screenshotting your terminal with 4 frames per second (every 250ms, but this is configurable) - Generates high quality small sized animated gif images - **Build-In idle frames detection and optimization** (for super fluid presentations) - Applies (can be disabled) border decor effects like drop shadow @@ -89,10 +89,12 @@ FLAGS: -v, --verbose Enable verbose insights for the curious. OPTIONS: - -b, --bg Background color when decors are used [default: white] [possible values: white, black, - transparent] - -d, --decor Decorates the animation with certain, mostly border effects. [default: shadow] [possible - values: shadow, none] + -b, --bg Background color when decors are used [default: white] [possible values: white, black, + transparent] + -f, --framerate If you want to capture at a different framerate you can pass it here. For example + '10' [default: 4] + -d, --decor Decorates the animation with certain, mostly border effects. [default: shadow] [possible + values: shadow, none] ARGS: If you want to start a different program than $SHELL you can pass it here. For diff --git a/src/cli.rs b/src/cli.rs index 95af31c..baef64a 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -43,6 +43,16 @@ pub fn launch<'a>() -> ArgMatches<'a> { .long("natural") .help("If you want a very natural typing experience and disable the idle detection and sampling optimization") ) + .arg( + Arg::with_name("capture-framerate") + .value_name("framerate") + .takes_value(true) + .required(false) + .short("f") + .long("framerate") + .default_value("4") + .help("If you want to capture at a different framerate you can pass it here. For example '10'"), + ) .arg( Arg::with_name("list-windows") .value_name("list all visible windows with name and id") diff --git a/src/main.rs b/src/main.rs index 6019388..c6890c2 100644 --- a/src/main.rs +++ b/src/main.rs @@ -74,6 +74,12 @@ fn main() -> Result<()> { let force_natural = args.is_present("natural-mode"); + let framerate = args + .value_of("capture-framerate") + .unwrap() + .parse::() + .context("Invalid value for framerate")?; + check_for_imagemagick()?; // the nice thing is the cleanup on drop @@ -87,7 +93,15 @@ fn main() -> Result<()> { let time_codes = time_codes.clone(); let force_natural = force_natural; thread::spawn(move || -> Result<()> { - capture_thread(&rx, api, win_id, time_codes, tempdir, force_natural) + capture_thread( + &rx, + api, + win_id, + time_codes, + tempdir, + force_natural, + framerate, + ) }) }; let interact = thread::spawn(move || -> Result<()> { sub_shell_thread(&program).map(|_| ()) }); @@ -166,8 +180,9 @@ fn capture_thread( time_codes: Arc>>, tempdir: Arc>, force_natural: bool, + framerate: u32, ) -> Result<()> { - let duration = Duration::from_millis(250); + let duration = Duration::from_secs(1) / framerate; let start = Instant::now(); let mut idle_duration = Duration::from_millis(0); let mut last_frame: Option = None;