Gif output support
I might be a good idea to build a new tool or sub-command which convert cast to gif(or svg). Original asciinema2gif is useful but installing deps is boring :) asciinema2gif: link
I think it could go in this tool. I see two logical entry points:
- For new recordings:
asciinema rec /path/to/file.cast --format gif/svg/whatever - For existing recordings:
asciinema convert /path/to/file.cast --format gif/svg/whatever
Some quick notes after investigation:
- I think the best way forward would be to use https://github.com/jwilm/alacritty to parse and render the tty. There appears to be a way to get their display grid (https://github.com/jwilm/alacritty/blob/master/tests/ref.rs).
- We could go from the alacritty display grid to our own render, but seems hard.
- alacritty uses
glutinunder the covers (https://github.com/jwilm/alacritty/blob/master/src/window.rs). - Likely need to wait for https://github.com/jwilm/alacritty/issues/450.
- Glutin has a headless renderer (https://docs.rs/glutin/0.13.1/glutin/struct.HeadlessRendererBuilder.html).
- An example of how to save the GL data to an image is at https://github.com/bwasty/gltf-viewer/blob/14342da1ae8ba6d832f0088a92743e8a3a428329/src/viewer.rs#L328 and how to use a headless context is at https://github.com/bwasty/gltf-viewer/blob/14342da1ae8ba6d832f0088a92743e8a3a428329/src/viewer.rs#L86.
- Looks like there may be a bug with the headless glutin context on linux: https://github.com/tomaka/glutin/issues/988
I've been poking at this and have been able to render a static image using alacritty. There are some outstanding issues but nothing that can't be resolved, so this is definitely going to be possible somewhat soon.

Update: I got gif support working, including clamping to 60fps and having proper duration between frames to keep file size down:

I'm going to clean it up a bit, report my findings to alacritty so they can merge their WIP diff, and then we will support gifs!
It seems we can have gif support soon🤔
not sure if gifski is helpful which is gapl licensed. https://github.com/ImageOptim/gifski
There are also (Node) projects that render as SVG: https://github.com/marionebl/svg-term-cli https://github.com/derhuerst/asciicast-to-svg
Would outputting multiple filetypes in one invocation be a good idea?
I've implemented a minimal virtual terminal in Rust for asciinema recently, for the purpose of integrating it into web player (rust-wasm) and screenshot generation: https://github.com/asciinema/vt-rs
It's working nicely, although I haven't had a chance of preparing README, publishing to crates.io, nor integrating into web player. Not sure if useful to you at this stage but I thought mentioning it won't hurt :)
Sweet, looks awesome! I'll look into integrating, the alacritty changes have stalled.
I've just started working on finding a way to render gif's. I'm posting what I find in a forum topic.
I think it might be simple enough to support SVG, animated PNG, and Gif with one solution.
I'm going to try to put the converter logic into its own crate lib/cli because I think it would be useful to people who still want to use the normal asciinema CLI, but we can also include the crate as a library to asciinema-rs so that it is built-in to this tool as well.
Found someone using this tool: https://github.com/nbedos/termtosvg
@piaoger Yes, I've used that before. It is very nice. My biggest problem came when I needed to paste a recording into GitHub and they for some reason don't support SVG in comments!
I forgot to post an update by my https://github.com/katharostech/cast2gif/ program is actually basically working. It needs some new features to be a little nicer, but it is functional now. It's a rust crate so we could incorporate it into asciinema-rs.
@zicklag
yes. I found cast2gif and you also mentioned termtosvg in the post after that.Let me try asciinema-rs and cast2gif together.