Hacker News new | past | comments | ask | show | jobs | submit login
VHS: CLI home video recorder (github.com/charmbracelet)
309 points by denysvitali on Oct 27, 2022 | hide | past | favorite | 60 comments



Similar tool: https://asciinema.org/

It does not generate a GIF file, but can be easily published on the web. The recorded terminal session is clipboard friendly: you can select and copy.


I love asciinema. A key difference between these two tools seems to be that asciinema records a human using the terminal, whereas VHS generates output based on a list of steps to execute.

I can see VHS being nicer than asciinema for a lot of applications, since you can avoid typos and fumbling, and you can easily re-render the same output with different settings.


I've started using demo-magic [1] to automate my asciinema recorded demos, not perfect but it gets the job done. VHS does look excellent however and I'll definitely be giving it a go the next time I need to record anything.

[1] https://github.com/paxtonhare/demo-magic


> It does not generate a GIF file,...

Although it's separate, the creator(s) does provide a utility called `agg`[0] to convert asciicast files to GIF. The GitHub appears to provide prebuilt binaries in Releases, but it's easily built using Cargo/Rust too.

0: https://github.com/asciinema/agg


But that kind of defeats the purpose, no? If I'm going to record asciinema to convert to GIF, why not just record the terminal to GIF directly?


You may want to edit the timing maybe? Or provide an asciicast format where you can run JS (your blog or site) and a gif where you can only insert a picture, like social networks.


You can't edit the timing with asciinema though, as far as I know.


It's possible. The file format is JSONL, you just need to export the raw version before uploading.


To generate GIFs use: https://github.com/dstein64/gifcast Works in the browser and locally. No install needed.



do you still have to go to asciinema.org to view them? that always rubbed me the wrong way, whether it was a requirement or just the dominant preference.


You can record and play cast files offline easily. You can also embed an asciinema js player [1] on your own site to play casts.

[1]: https://github.com/asciinema/asciinema-player


The publishing is why I've avoided asciinema. Very easy to publish secrets. Can't easily share them around as an image either.


I wrote a blog post[1] breaking down tools to record terminal sessions just a couple weeks ago. I wasn't aware of this particular one but it looks like it's going to have issues with recording anything that requires user input.

My post describes how to make high quality recordings of terminal sessions that can be replayed in the terminal, or shared on the web. I'm defining high quality as recordings with zero typos, and relatively controlled timing between commands.

I'm going to assume this works well because all the stuff from Charm seems to, BUT its limitations are ... problematic. I think the techniques i list in the post combined with agg[2] or gifcast[3] to covert it to a gif would be a better solution for non-trivial cases.

I'll add notes about agg and gifcast to the post this evening hopefully.

[1]: https://weblog.masukomi.org/2022/10/11/recording_and_sharing...

[2]: https://github.com/asciinema/agg

[3]: https://github.com/dstein64/gifcast


Seems like it'd be fine for user input? You just tell it what the input is and it will record it.


This looks super useful. Tempted to go and add CI-maintained gifs to a whole bunch of existing projects now.

Some ideas for new features:

* If the prefix of the tape file is unchanged, reuse the intermediate updates through that prefix from a cache (edit: hmm, upon further thought this seems more difficult than I initially imagined, since the state would need to be cached to save time, not just the images)

* Allow an option for using real-time delays in the gif or user-selected delays (I think currently delays are constant unless user-selected, but I don't see a way to use the real runtime delay in the gif)


Nice tool. As a nit,

> Linux > brew

Please don't do this, it's not safe, despite it "existing" as an option. Even a binary download is better than suggesting brew on Linux.


Perhaps you don't understand the use case. It's often the only option for users to install packages on an HPC system, as on such systems you cannot install things as root so the system package manager is infeasible. The only other possibility is Anaconda, but that has its origins as a Python tool and only has a fairly limited set of non-Python related packages.


Semi-relevant (userspace dev tools)

Asdf – language tool version manager

https://news.ycombinator.com/item?id=33323261 (3 days ago)


why


Not necessarily doubting you, but I am curious to hear why you think this. On what basis do you suggest that it's not safe?


What do you feel is unsafe about Homebrew?


For starters: auto-updating everything before installing anything (HOMEBREW_NO_AUTO_UPDATE default 0).

Coupled with uninstalling before determining whether or not the OS version is still supported (not sure if this still can happen, or ever happened on Linux)... fun times all around.


that's it?


Charmbracelet is a gem. Ran across their stuff a year or two ago and it's just a pleasure.


When did Github get play/pause controls on GIF images?

Pretty neat! I've always had a gripe with GIF's autoplaying after the page loads so the first time I see it it's halfway through the animation.

VHS looks like a pretty neat tool! Not sure if I'd use it, but definitely some use cases out there for tutorials, guides, etc.


I've done a few gifs of "this happens" for bug reports and the like. One thing that this solves is the "ugh i screwed up the sequence, time to try recoring for the 10th time" problem, so that's interesting. I wonder how well it works with programs that set their input line discipline to "raw" or read from the pty directly - ncurses-like interfaces and things like sudo, etc.


I don't see the play/pause buttons (Chrome on Android): gif are autoplaying. Perhaps it comes from your browser?


Maybe, I'm using Firefox - I wonder if that's built into the browser now?

I really wish there was a set of browser standards for at least a modicum of similarity (I guess chromium is one?)- things are all over the place still hahaha


they even have a tree-sitter parser for vhs/.tape -- https://github.com/charmbracelet/tree-sitter-vhs#readme -- but then they hand-roll the parser for it in the actual vhs repo

Is tree-sitter so hard to use in anger that it's worth the diverging implementations?


We started off hand rolling the parser and had that fully implemented and then wrote the tree-sitter grammar. If I were to do it again I would probably use tree-sitter for the actual repo so that the implementations were the same for sure.


> VHS has an SSH server built in! When you self host VHS you can access it as though it were installed locally. VHS will have access to commands and applications on the host so you don't need to install them on your machine.

That is super slick!


Cool name and file extension. This person could be in branding.


Almost certainly trademark infringement though.


Trademarks are domain specific, so it wouldn't be an open and shut case.


It wouldn't get to trial. Cease and desist letter with the threat of legal action would likely do the trick, as charmbracelet likely have insufficient funds to defend themselves, and it simply wouldn't be worth the money to defend a small project name. At the very least it would be easy to force them to remove any use of VHS in relation to video tapes: they have a giant picture of a VHS video tape on their homepage!

If the trademark owner discovers this, they would be legally obliged to defend their trademark if they want to keep it.

JVC/Kenwood has previously successfully defended their mark when used in artworks/apparel (which are not in the same domains).


Very cool. I love their other projects as well.

https://charm.sh/


This is awesome! I can see adding a demo for at least one of my projects.

Based on a quick glance, I'd say the best thing about it is that can you reuse the script (for ex: something changed with the command usage/output, automate recording for different command, etc).


If the author's reading this, please consider whether a picture of a video cassette was really of value, and if it was please don't put in a bloody great 2MB image.


For what it's worth, I enjoyed the nice cassette logo :)


Author here. Fair point! Definitely forgot to compress it and make it smaller. Thanks for the call out.


At one of the Open Source Conferences (OSCON) I saw Damian Conway use a tool like this (I believe it was asciinema) to give one of the best command line based demos I've ever seen. He was typing away like mad and not one typo! It was mesmerizing and the demo was totally awesome, of course it helps that he's a superb presenter to begin with.

Later he revealed the "magic trick"!


Oooh this looks great! I have a soft spot for terminal recording tools.

I made the inverse of this (give it keystrokes and it plays them back as you type, for live demos: https://gitlab.com/stavros/itsalive).


Maybe another alternative for inspiration: https://github.com/faressoft/terminalizer

I love it because it gives you the option to record or to prepare your file... very easy and good results.


We definitely want to add an option to record a session which would output a generated file for you!


So, this seems to just download chrome and run some sort of terminal emulator in it (then converts it to video). Do I have that right? Seems like massive overkill for something you could do with just ffmpeg and a terminal emulator...


I've actually used ffmpeg + GNU screen to do something very similar in the past.

The benefit of using GNU screen is that the "tape" can be a shell script. I suppose if you don't like shell scripts that's not a benefit, but I do like them.

For example, instead of:

    Type "echo 'Welcome to VHS!'"
    # Pause for dramatic effect...
    Sleep 500ms
    Enter
With GNU screen, you would write:

    #!/bin/sh
    screen -d -m -S whatever -- bash
    screen -S whatever -X stuff "echo Welcome to screen" 
    sleep 0.5
    screen -S whatever -X stuff $'\n'
If you want to start interacting with the session, just do screen -r whatever

You can also read what is in the screen with -X hardcopy, then do something with the output, like verify the output is correct or adjust the input.


This is actually really cool. Thanks for sharing this!


Where/how does ffmpeg come in? How are you connecting screen output to ffmpeg input?


ffmpeg can capture an xterm as a source, it's called x11grab.


TIL! Thanks for sharing!

Edit: X11 as a source, not xterm. At least from what I can see.


I think that may just be copy-paste in the Dockerfile, as it doesn't seem to use chromium (nor chrome) anywhere else in the repo: https://sourcegraph.com/search?q=context:global+repo:%5Egith...

which for sure matches my mental model of using ttyd and ffmpeg -- what in the world would anyone need chromium for?


One of the dependencies is `rod`[0], which is a web scraping/automation library, and I believe requires a browser to work. I don't know what they're using it for though as I haven't looked at the code (and I'm not familiar with Go anyways). There's a feature of the library that finds and installs a browser, but they may just be preemptively including chromium in the dockerfile and assuming that non-docker users will already have a supported browser on their machine.

0: https://github.com/go-rod/rod


> what in the world would anyone need chromium for?

Perhaps rendering an xterm.js canvas? (I don't know, it's just a guess)


Really nice!

Which font family can be used? I'm trying with font names from fonts that I have installed (i.e. Terminus or terminus) and it's not working.


super cool project, any way to integrate it in mkdocs or pymarkdown ?


Would love to know what other people think about the overall design and comunication stategy of Charm. On one hand I already knew who did this project even before the image was fully loaded, youtube content seems interesting, and branding is very strong but I also feel a bit overwhelmed by all the brands shouting at me. they have Charm Cloud, VHS, Soft Serve, Buble Tea, Lip Gloss, Charm, Wish, Bubbles, Glamour, Harmonica, Gum, Skate, Glow.


I miss how CPAN required that you name modules. they were named according to their capabilities, and they were narrowly scoped.

these days, you just pick a word from the dictionary, and that's your software's name. now I have 1000 names to remember.


I personally love it. It's charming :)

The other themes that all the tools have are quality, usefulness, and creativity. Personally my favorite is gum, it makes me want to write shell scripts. It's like zenity for the terminal.


I love their branding




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: