So something I’ve always wanted is the ability to “script” a video, so that all i have to do is edit the script file then regenerate the video.
I think I could hack this together by using shell-mode in emacs and then writing elisp to send commands to it. But, has anyone else done something like this?
An example, I have a project GitHub - joelmccracken/reddup: Helping you keep your workstation nice and tidy , and i get a lot of people who don’t quite “get” why the project would be useful. So I thought having a screencast would be a great way to “demo”. Basically, if I could script it, what I would do is something like:
cd to some directory
run a bunch of git and touch commands to set up a repo in a certain way.
start asciinema
run my project (and script the way it should interact)
stop asciinema.
I hope that is clear. The big value would be in having a repeatable “setup” and it would be a lot easier to add and remove demo features.
Well yes, pretty easy. Maybe even easier than you think!
The --command= option allows to specify the program you run, it’s $SHELL by default. Just set it to whatever program you can script in which will literally output the “movie” to its stdout! Then you get the scriptability from the program (oh I guess it’ll be rich in sleep() calls), as well as the preserved recording from asciinema. That’s Unix-style program composition!
Too bad you can’t really edit the recordings… Or can you? However there’s also asciinema rec --stdin mode, which’ll record your manual timed input into the replayable file.
I hope, some combination of these would become useful!
not sure if it is still a topic but I created a small golang based tool which allows to script the sequence by defining a couple of parameters such as character typing speed:
In case it could be useful, I have made a small python package to automate recordings. It uses pexpect, so it is similar to what is used in the blog post @ku1ik pointed out in his answer in some sense.
BTW if someone wants to help me package this up into its own container in GitHub’s Container Registry and create a GitHub Action from it to regenerate screencasts from a set of shell scripts in a screencasts directory.
ie. after every merge to main in any repo using it in a github action