Skip to content
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

Support for asciicast 'idle_time_limit' #30

Open
hjmallon opened this issue Feb 20, 2018 · 8 comments
Open

Support for asciicast 'idle_time_limit' #30

hjmallon opened this issue Feb 20, 2018 · 8 comments

Comments

@hjmallon
Copy link

Asciicast version 2 files have a setting for 'idle_time_limit'. This is meant to compresses time differences bigger than the set amount. It is handy for making clean demos. svg-term-cli is not respecting that field currently.

@hjmallon hjmallon changed the title Support for asciicast ''idle_time_limit' Support for asciicast 'idle_time_limit' Feb 20, 2018
@marionebl
Copy link
Owner

Jep, sounds like a good idea. Want to lend a hand?

@hjmallon
Copy link
Author

hjmallon commented Feb 20, 2018

It's as good an excuse as any to learn some more Javascript, I can have a poke around soon hopefully.

@marionebl
Copy link
Owner

It's as good an excuse as any to learn some more Javascript, I can have a poke around soon hopefully.

👍 That is very nice of you, thanks!

You'll want to have a look at the following lines that start the asciinema child process.

svg-term-cli/src/cli.ts

Lines 469 to 475 in e22ca85

const result = await execa("asciinema", [
"rec",
"-c",
cmd,
...(options.title ? ["-t", options.title] : []),
tmp
]);

They'll look something like:

 const result = await execa("asciinema", [ 
   "rec", 
   "-c", 
   cmd, 
   ...(options.title ? ["-t", options.title] : []), 
   ...(typeof options.maxWait === number ? ["--max-wait", options.maxWait] : [])
   tmp 
]); 

This changes also requires the addition of maxWait?: number; to RecordOptions.

asciinema expects --max-wait in seconds, while svg-term-cli uses milliseconds, so the record option will look like this:

record(cli.flags.command, {
  maxWait: typeof cli.flags.maxWait === "number" ? cli.flags.maxWait * 1000 : cli.flags.maxWait
})

@hjmallon
Copy link
Author

I was actually talking about using a json file recorded by asciinema itself. But I see that tying it in here would be useful.

I reported a similar issue here: asciinema/asciicast2gif#34
It was fixed by a commit (and new version bump) here: asciinema/asciinema-player@5c922c8

Maybe if https://github.com/marionebl/load-asciicast pulled it's submodule of asciiema-player up to v2.6.1 then at least the json might work.

This is all hearsay and suspicion as I have not got the build environment set up here yet, so pinch of salt required.

@marionebl
Copy link
Owner

Ok, that is interesting. Could you point to an asciicast that is affected?

@hjmallon
Copy link
Author

hjmallon commented Mar 4, 2018

Yep, here is one (that I added to the other issue)
test.txt

@hjmallon
Copy link
Author

hjmallon commented Mar 4, 2018

Also I tried again today (reinstall from npm) and I assume that pulling the submodules up in the other repo has fixed this.

It works great now. Feel free to close this unless you want to keep it open for adding CLI support for this feature?

@ku1ik
Copy link

ku1ik commented Mar 10, 2018

As long as you update load-asciicast library to use latest asciinema-player it will automatically handle idle_time_limit saved in the asciicast, and adjust timing properly. (asciicast/load ...) function also allows passing idle-time-limit value in case you want to override it / provide it from the command line.

Btw, I've set up a discussion forum for asciinema: https://discourse.asciinema.org/ , where I'd be happy to discuss this and any other asciinema/asciicast related topics 👋

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants