Just Because You Can: hovering text to use in a presentation or elsewhere.
Some of you will immediately see that this is the Star Wars screensaver from the great screensaver-collection. Now I’m not sure if running it as an actual screensaver is still feasible in these Wayland times, but that’s not what this is about. This is about recording a movie, an mpeg-file, with this Star Wars themed text in it.
Here’s how to proceed. Things to install are, obviously, xscreensaver; then also the Xephyr xserver and finally ffmpeg to record stuff. Under Ubuntu and Debian this means apt-get install xscreensaver-gl-extra xserver-xephyr ffmpeg
.
Then start Xephyr. I didn’t care to find out how to set the canvas size, for some reason the Star Wars starts with 1280×720 so I’m telling Xephyr -screen 1280x720 :2
The window you’re now seeing is an old-fashioned X server, where anyone can start anything.
So we’ll start Star Wars: DISPLAY=:2 /usr/libexec/xscreensaver/starwars -program 'man -P cat man'
Our “man -P cat man” will output the manpage for man (it will mansplain, if you like), so feel free to use any other program to generate text. The movie above was created by downloading the Dutch constitution to a txt-file, then using cat ~/Downloads/BWBR0001840-geldend_van_22-02-2023_tm_heden_zichtdatum_15-02-2024.txt
for program.
(Yep, that’s how the Dutch constitution is named, on the internet: “BWBR0001840-geldend_van_22-02-2024…” etcetera. I’d guess I should be grateful it doesn’t start with “Microsoft Word – BWBR0001840-….” – but I digress.)
Recording this is rather easy: ffmpeg -f x11grab -framerate 25 -i :2.0 -s 1280x720 -c:v libx264 /tmp/starwars.mp4
I actually used a couple of extra options, -s 640x480 -profile:v baseline -pix_fmt yuv420p -level 3.0
that may help play the movie on Android, then again, I first named my movie starwars.mpg which wouldn’t play at all, so I’m not 100% sure what the mandatory settings for a platform-agnostic movie are. That’s a wholly different discussion, though.
One final note: for some obscure reason, the X cursor isn’t visible, but gets recorded by ffmpeg, which looks a bit weird. So I added one final trick to my setup: DISPLAY=:2 xsetroot -cursor_name star
before starting ffmpeg. That’s why the starry looking thing is in the middle of the screen: it actually is a star, or at least a representation of what the X designers in 1992 thought of a star.