This is pretty awesome. I'm a big fan of both SVG animations and terminal recorders, so this is right up my alley. I previously built a small library called svganimator for creating smooth animations between static SVG images [1], used generated SVG animations to help design the Wayback Machine loading animation [2], and also put together a fairly comprehensive comparison of terminal recording solutions [3]. I'll need to update the comparisons to include termtosvg, I can't wait to try it out and see what the file sizes look like.
As others have mentioned, the major issue with SVG animations is that Microsoft doesn't plan to ever include support for them in Edge. This means that you either need to create fallbacks specifically for Microsoft browsers, or to disregard that portion of the market on your website. It's a real shame because SVG/SMIL allows you to create high quality animations which require a fraction of the bandwidth that would be necessary for comparable GIF or video files.
Honestly, if you're recording terminal sessions, it's probably fine to not support Edge. I doubt any significant portion of your audience is going to be using it, and even if they do, they're going to be perfectly understanding when you say "sorry, Edge doesn't support SVG animations, use a different browser".
Shitty of Microsoft, though. If they aren't going to support it, it's not going to be widely deployed. I expect better of the new and improved Microsoft.
OP here. Sadly, SVG file size is not as small as I'd want it to be. The main problem is that a few attributes (x, y and lengthAdjust) have to be repeated on each text tag to position each character at the right place. I can't use CSS for this since those attributes are not styling attributes.
Using SVG definitions efficiently to avoid duplication is also not as easy as I thought it would be.
I have a few ideas on how to reduce file size, this is the next improvement I'm planning to work on.
For the examples shown at [1], file size ranges from 56kB to 252kB, the worst case scenario being lots of single characters with different colors.
My first thought was "this seems neat", and my second thought was: how hard would it be to write a small js script to play back "script"[s] output? Or, to take script output, convert it to some pre-tags and add js animation on top of that...
I suppose the main barrier would be lack of recorded timing information in script logs, so either pre-procesding or pause for input (say 50ms/keystroke + 200ms pr return/line-feed) and/or output (say 50ms pr line feed).
Although, now I see there's a -t option for a timing file.
So would seem one should be able to take logs from script, and produce svg, gif, png, webm, mp4... js output.
Excellence! The README reads:
"I really like the clean look of SVG animations and I also wanted to see how this solution would hold out against other attempts at terminal recording such as asciinema."
But how does it compare? Is the size smaller, is it more efficient?
Animated SVG animations (really just an svg element + animated css) are significantly smaller, more efficient, and crisper than equivalent GIF animations. I wrote about the difference between the two here: https://hackernoon.com/presenting-your-code-beautifully-fdba...
This is great for many of the same reasons that asciinema is great -- smooth animation and selectable text. The resulting svg is orders of magnitude smaller than a gif would be.
How hard would it be to add some sort of pause button to aid in selecting from the capture? Also, it appears you can only select when you are viewing the image directly, not when it is embedded via an <img> tag. Is that fixable? I guess maybe an <iframe> might work, but I haven't played with it yet.
It would be good to adjust the failure mode so that if SMIL is not supported then at least a meaningful frame (probably the last, though scrolling makes it difficult to decide!) is shown, rather than just a blank rectangle.
Jesus, it's 2018 and they still can't even figure out how to implement animated PNGs? Real browsers had this 10 years ago. What the hell is wrong with Microsoft? Are they really just so incompetent, or is there a more insidious business reason why they don't want more animated formats on the web?
Sadly, I will not replace asciinema+svg-term-cli by termtosvg, because termtosvg takes the terminal size into account when recording, not when rendering. It means that I have to resize my terminal before recording, and that I will not be able to resize it differently for rendering. So if lines are wrapped, I cannot change the width to de-wrap them in the resulting SVG.
Asciinema does not care about your terminal size when recording. In fact you can even reduce it or hide it (if you automate the input). Then you render it with svg-term-cli with the width you feel it is best.
I'm very impressed - it combines two of my favourite technologies, Python and SVG. Three, in fact - including terminal. I will be watching it and tinkering with it.
Cool. It is not very clear from the description so I will ask:
What are the advantages over "asciinema"?
At the moment I only see that it does not require a specific player (javascript for the web), on the other hand it seems you are not able to pause the "execution".
I think standalone is the most outstanding advantage. Many recordings of terminal are using asciiema or youtube, those links in a github readme.md file is a static screenshot instead of animated one, you have to click the link to watch the animation.
You can view the animation without javascript enabled, and it's media type is image, you don't even need to convert it to base64 to use it. It's like gif but relatively smaller and with more colors, and it's Scalable Vector.
What're people using tools like this for? I see the usage surely when demonstrating something in the terminal - and many times used for showcasing projects and tools. Are you using the recordings for other purposes, like to document work and share progress with your team + manager for instance for work you're doing during a sprint (good for demo'ing things at the end of the sprint too).
I did an experiment a couple of years ago where I wanted to see if I could write code 1 pomodoro a day. I recorded myself in asciinema. It's basically several 25 minute pomodoros of me implementing Core Wars (a VM for machine language programs that battle against each other) in Ruby. I hadn't written Ruby in a while and I was more interested in playing experimenting with a TODO list for being efficient with such a small amount of code per day, so the code is not really fantastic. However, if you are interested I did about 60 pomodoros, I think: https://mikekchar.github.io/core-wars-kata/
It's a super old version of asciinema (I haven't bothered to update it). Also, I recommend increasing the playback speed using the '>' key a couple of times so you don't have to suffer from my pathetically slow typing.
It's good for right-way vs wrong-way demonstrations. If I just copy the text out of my terminal and say "this is how we used to do it; this is how we should do it/will do it now" and paste it in a jira ticket, not many people will take the time to read and understand. Gifs are more accessible I guess.
The most obvious example is small videos of terminal. That is to say, better quality than GIF and smaller size than MP4 and the like. SVG is also lossless.
One thing you could do with this is making SVGs from applications such as htop (or _any_ terminal application), and then serving those over WWW. You can then view those in a web browser by going to a certain date (some HTML/JS would be used to neatly organize them in a good UI, or allowing things such as looping and going forward or backward, but you could also use data analysis on the SVGs).
Sure, you could export log data and then use MRTG/RRDTool or something like that and it'd work just as well. My point is that you need support for that (via e.g. SNMP); with Termtosvg you abstract all terminal applications.
A few weeks ago I tried to convert one of my asciinema recordings to a SVG with svg-term-cli [1], but the result had big problems with some browsers, so I took the more mainstream gif approach again.
Anybody tried termtosvg with different browsers yet?
If the standard would have been clear and simple - then maybe yes.
But in my opinion it was and still is, a huge mess.
It somewhat works now, but ... it is a subset, that works. But it is not evil intention(nor the fault of Adobe or now Microsoft), that the love for SVG is not the greatest.
The example recording renders super smoothly in FF v61.0 and Chrome v67.0, but stutters in Safari running on an OS-X 'High Sierra' machine.
That said, I'm absolutely loving this as the file size and the memory footprint of this SVG is super-small relative to what a .gif of the same content would be. Great work!
You could differentiate more from asciinema by building editing tools around the recording (like cutting or embedding the recording in stock frames like in https://shotsnapp.com)
Thanks! I will look into the virtualenv problem, but if you can spare the time could you please open an issue and include the exact steps to reproduce the error?
Well, the animation is inherent to the SVG, so either browsers would need to support that, or some kind of JavaScript library is needed to extract that (probably giving Edge animation support while it's at it)
I had just thrown together a typescript bash script to record IRC with timing for later playback and sync with a podcast, the trick is the rendering step: in theory it could be done on a canvas with native ffmpeg drawtext, but the invocation is super gnarly.
foob|7 years ago
As others have mentioned, the major issue with SVG animations is that Microsoft doesn't plan to ever include support for them in Edge. This means that you either need to create fallbacks specifically for Microsoft browsers, or to disregard that portion of the market on your website. It's a real shame because SVG/SMIL allows you to create high quality animations which require a fraction of the bandwidth that would be necessary for comparable GIF or video files.
[1] - https://github.com/sangaline/svganimator
[2] - https://intoli.com/blog/designing-the-wayback-machine-loadin...
[3] - https://intoli.com/blog/terminal-recorders/
OskarS|7 years ago
Shitty of Microsoft, though. If they aren't going to support it, it's not going to be widely deployed. I expect better of the new and improved Microsoft.
nbe|7 years ago
Using SVG definitions efficiently to avoid duplication is also not as easy as I thought it would be.
I have a few ideas on how to reduce file size, this is the next improvement I'm planning to work on.
For the examples shown at [1], file size ranges from 56kB to 252kB, the worst case scenario being lots of single characters with different colors.
[1] https://github.com/nbedos/termtosvg/blob/master/examples/exa...
d_|7 years ago
And here I thought the Edge team left behind the mistakes of IE.
e12e|7 years ago
I suppose the main barrier would be lack of recorded timing information in script logs, so either pre-procesding or pause for input (say 50ms/keystroke + 200ms pr return/line-feed) and/or output (say 50ms pr line feed).
Although, now I see there's a -t option for a timing file.
So would seem one should be able to take logs from script, and produce svg, gif, png, webm, mp4... js output.
[s] http://man7.org/linux/man-pages/man1/script.1.html
fsiefken|7 years ago
But how does it compare? Is the size smaller, is it more efficient?
transitivebs|7 years ago
As I explained in the above article, this is already possible with asciinema + svg-term-cli (https://github.com/marionebl/svg-term-cli).
The one downside with animated SVGs is that they're not as compatible to be included anywhere as GIFs since they're really just html snippets.
andrewla|7 years ago
How hard would it be to add some sort of pause button to aid in selecting from the capture? Also, it appears you can only select when you are viewing the image directly, not when it is embedded via an <img> tag. Is that fixable? I guess maybe an <iframe> might work, but I haven't played with it yet.
djsumdog|7 years ago
chrismorgan|7 years ago
It would be good to adjust the failure mode so that if SMIL is not supported then at least a meaningful frame (probably the last, though scrolling makes it difficult to decide!) is shown, rather than just a blank rectangle.
swebs|7 years ago
okket|7 years ago
[Edit: This seems to be a macOS/driver bug affecting only some models]
skykooler|7 years ago
The_suffocated|7 years ago
AndrewStephens|7 years ago
cnlwsu|7 years ago
Pawamoy|7 years ago
Asciinema does not care about your terminal size when recording. In fact you can even reduce it or hide it (if you automate the input). Then you render it with svg-term-cli with the width you feel it is best.
b0rsuk|7 years ago
It's written in modern Python and well documented. However, some functions are a bit monolithic: https://github.com/nbedos/termtosvg/blob/master/termtosvg/te...
dethos|7 years ago
What are the advantages over "asciinema"?
At the moment I only see that it does not require a specific player (javascript for the web), on the other hand it seems you are not able to pause the "execution".
4684499|7 years ago
You can view the animation without javascript enabled, and it's media type is image, you don't even need to convert it to base64 to use it. It's like gif but relatively smaller and with more colors, and it's Scalable Vector.
nbe|7 years ago
The output is an SVG animation so you can modify it as you want. For example you could add a last frame with the logo of your project.
Not being able to pause the animation is annoying, I will probably add some way to it with ECMAScript in the future.
dpflan|7 years ago
mikekchar|7 years ago
It's a super old version of asciinema (I haven't bothered to update it). Also, I recommend increasing the playback speed using the '>' key a couple of times so you don't have to suffer from my pathetically slow typing.
joombaga|7 years ago
Fnoord|7 years ago
One thing you could do with this is making SVGs from applications such as htop (or _any_ terminal application), and then serving those over WWW. You can then view those in a web browser by going to a certain date (some HTML/JS would be used to neatly organize them in a good UI, or allowing things such as looping and going forward or backward, but you could also use data analysis on the SVGs).
Sure, you could export log data and then use MRTG/RRDTool or something like that and it'd work just as well. My point is that you need support for that (via e.g. SNMP); with Termtosvg you abstract all terminal applications.
arendtio|7 years ago
Anybody tried termtosvg with different browsers yet?
[1]: https://github.com/marionebl/svg-term-cli
77pt77|7 years ago
hutzlibu|7 years ago
canada_dry|7 years ago
https://d3js.org/
abhiminator|7 years ago
That said, I'm absolutely loving this as the file size and the memory footprint of this SVG is super-small relative to what a .gif of the same content would be. Great work!
unknown|7 years ago
[deleted]
m3tr0s|7 years ago
m3tr0s|7 years ago
Demiurge|7 years ago
One bug I noticed is that it seems to break virtualenv which is made with --system-site-packages its not finding the modules
nbe|7 years ago
https://github.com/nbedos/termtosvg/issues/new
nihil75|7 years ago
michaelmior|7 years ago
dc443|7 years ago
vanderZwan|7 years ago
eltoozero|7 years ago
I had just thrown together a typescript bash script to record IRC with timing for later playback and sync with a podcast, the trick is the rendering step: in theory it could be done on a canvas with native ffmpeg drawtext, but the invocation is super gnarly.
jscoder99|7 years ago