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

Setting the speed of an asciinema cast SVG? #36

Open
dhimmel opened this issue Oct 7, 2018 · 7 comments · May be fixed by #37
Open

Setting the speed of an asciinema cast SVG? #36

dhimmel opened this issue Oct 7, 2018 · 7 comments · May be fixed by #37

Comments

@dhimmel
Copy link

dhimmel commented Oct 7, 2018

We're using this utility to create animated SVGs of a terminal recording, as per manubot/manubot#63 and manubot/manubot#64.

Is it possible to change the speed (i.e. increase / decrease framerate) of the SVG export? I am looking for an equivalent of asciinema's speed parameter, e.g. https://asciinema.org/a/205085?speed=2.

@marionebl
Copy link
Owner

marionebl commented Oct 8, 2018

That is a great suggestion - currently this is not implemented but shouldn’t be to hard to change that.

We would need to

  • accept a —speed flag, default it to 1

  • use parseFloat to parse the input flag, catch NaN or <=0 inputs

  • pass it to svg-term here:

    svg-term-cli/src/cli.ts

    Lines 226 to 237 in fcedbdb

    const svg = render(input, {
    at: toNumber(cli.flags.at),
    cursor: toBoolean(cli.flags.cursor, true),
    from: toNumber(cli.flags.from),
    paddingX: toNumber(cli.flags.paddingX || cli.flags.padding),
    paddingY: toNumber(cli.flags.paddingY || cli.flags.padding),
    to: toNumber(cli.flags.to),
    height: toNumber(cli.flags.height),
    theme,
    width: toNumber(cli.flags.width),
    window: toBoolean(cli.flags.window, false)
    });

  • in svg-term: divide the animation-duration by the specified speed
    https://github.com/marionebl/svg-term/blob/d376d203cb331e34d152aeeb064eb0a430c164bf/src/index.tsx#L120-L125

Want to lend a hand?

@dhimmel
Copy link
Author

dhimmel commented Oct 8, 2018

Hey @marionebl thanks for the straightforward explanation of how to implement this. I have little JS experience, but this seems like a good opportunity for me to learn if you're willing to review / help if I get stuck.

Before I get started, would you mind adding a LICENSE.md file (example) to the repo with the MIT License text? The MIT license terms require

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

@marionebl
Copy link
Owner

marionebl commented Oct 8, 2018

Before I get started, would you mind adding a LICENSE.md file (example) to the repo with the MIT License text? The MIT license terms require

@dhimmel Thanks for the reminder, added it via fcedbdb.

[...] I have little JS experience, but this seems like a good opportunity for me to learn if you're willing to review / help if I get stuck.

I'm happy to help and unblock you during the process 👍

@dhimmel dhimmel linked a pull request Oct 9, 2018 that will close this issue
@Benjamin-Lee
Copy link

@dhimmel let me know if you need any help with this. I'm a javascript beginner as well but needed this feature today so I'm happy to contribute.

@dhimmel
Copy link
Author

dhimmel commented Oct 28, 2018 via email

@ssmirr
Copy link

ssmirr commented Nov 5, 2018

in svg-term: divide the animation-duration by the specified speed
https://github.com/marionebl/svg-term/blob/d376d203cb331e34d152aeeb064eb0a430c164bf/src/index.tsx#L120-L125

@marionebl I tried your suggestions, but this ^ seems to only create animation from the first duration/playback-speed of the recording. Do you have other suggestions for this?

@miraclx
Copy link

miraclx commented May 17, 2020

As a workaround, you can re-record the cast

asciinema rec final -c "asciinema play recording --speed 2"

And thereafter, use svg-term to compile

svg-term --in final --out final.svg

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

Successfully merging a pull request may close this issue.

5 participants