Graft Animation Language on Raspberry Pi

Because the Rapsberry Pi uses a slightly older Python version, there is a special version of Graft for it.

Here’s how to get it:

  • Open a terminal window by clicking the black icon with a “>” symbol on it at the top near the left.
  • First we need to install a couple of things Graft needs, so type this, then press Enter:
    sudo apt install python3-attr at-spi2-core
  • If you want to be able to make animated GIFs, install one more thing:
    sudo apt install imagemagick
  • To download Graft and switch to the Raspberry Pi version, type in these commands, pressing Enter after each line.
    git clone
    cd graft
    git checkout raspberry-pi
  • Now, you should be able to run Graft just like on another computer, for example, like this:
    ./graft 'd+=10 S()'
  • If you’re looking for a fun way to start, why not try the worksheet “Tell a story by making animations with code”?

    For more info, see Graft Raspberry Pi Setup.

Recording gameplay videos on RetroPie

Credits: this is a slightly corrected and shortened version of How To Record A GamePlay Video From A RetroPie by selsine, which is itself based on Recording Live Gameplay in RetroPie’s RetroArch Emulators Natively on the Raspberry Pi by Retro Resolution.

RetroPie is based on RetroArch. RetroArch has a feature to record gameplay videos, but the current version of RetroPie has it disabled, presumably because it was thought to be too intensive to run properly on a Raspberry Pi.

These instructions tell you how to turn the recording feature on, and set it up. This works perfectly on my Raspberry Pi 3, allowing me to record video and sound from games I am playing.

The code for this is here: – this was code written by RetroRevolution, with small corrections and additions by me.

Before you start, you should have RetroPie working and connected to the Internet, and updated to the latest version.

Note: you should make a backup of your RetroPie before you start, because if you type the command below you could completely break it, meaning you will have to wipe your SD card and start fresh.

Turning on the recording feature

RetroArch uses the ffmpeg program to record video. To turn on recording, we need to log into the Pi using ssh, download and compile ffmpeg, and then recompile RetroArch with recording support turned on.

Log in to the Pi using ssh

Find out the IP address of your Pi by choosing “RetroPie setup” in the RetroPie menu and choosing “Show IP Address”. Write down the IP address (four numbers with dots in between – for example:

On your Linux* computer open a Terminal and type:

ssh pi@

(put in the IP address you wrote down instead of

When it asks for your password, type: raspberry

If this works right, you should see something like this:
The RetroPie Project joystick logo

* Note: if you don’t have Linux, this should work OK on a Mac, or on Windows you could try using PuTTY.

Download and compile ffmpeg

Log in to the RetroPie as described above. The commands shown below should all be typed in to the window where you are logged in to the RetroPie.

Download the script by typing this:


Now run it like this:


(Note: DON’T use sudo to run this – just type exactly what is written above.)

Now wait a long time for this to work. If it prints out errors, something went wrong – read what it says, and you may need to edit the script to figure out what to do. Leave a comment and include the errors you saw if you need help.

Hopefully it will end successfully and print:

FFmpeg and Codec Installation Complete

If so, you are ready to move on to recompiling RetroArch:

Recompile RetroArch with recording turned on

Download the script by typing this:


Now run it like this:


It should finish in about 10 minutes, and print:

Building RetroArch with ffmpeg enabled complete

If it printed that, your RetroPie now has recording support! Restart your RetroPie:

Restart the RetroPie

Restart your RetroPie.

If you want to check that recording support is enabled, Look for “Checking FFmpeg Has Been Enabled in RetroArch” on the RetroResolution guide.

Now you need to set up RetroPie to record your emulator.

Setting up recording for your emulator

To set up an emulator, you need a general recording config file (the same for all emulators), and a launch config for the actual emulator you are using.

Create the recording config file

Log into the RetroPie as described in the first section, and type this to download the recording config file. If you want to change settings like what file format to record in, this is the file you will need to change.


Create a launch config for your emulator

Each RetroPie emulator has a config file that describes how to launch it. For example, the NES emulator’s version is in /opt/retropie/configs/nes/emulators.cfg.

To get a list of all the emulators, log into your RetroPie and type:

ls /opt/retropie/configs

In that list you will see, for example, “nes” for the NES emulators, and “gb” for the GameBoy emulators. Find the one you want to edit, and edit it with the nano editor by typing:

nano /opt/retropie/configs/gb/emulators.cfg

(Instead of “gb” type the right name for the emulator you want to use, from the list you got when you typed the “ls” command above.)

Now you need to add a new line in this file. Each line describes how to launch an emulator. You should copy an existing line, and add some more stuff to the end.

For example, my version of this file looks like this:

lr-gambatte = "/opt/retropie/emulators/retroarch/bin/retroarch -L /opt/retropie/libretrocores/lr-gambatte/ --config /opt/retropie/configs/gb/retroarch.cfg %ROM%"
lr-gambatte-record = "/opt/retropie/emulators/retroarch/bin/retroarch -L /opt/retropie/libretrocores/lr-gambatte/ --config /opt/retropie/configs/gb/retroarch.cfg --record /home/pi/recording_GB_$(date +%Y-%m-%d-%H%M%S).mkv --recordconfig /home/pi/recording-config.cfg %ROM%"
default = "lr-gambatte"
lr-tgbdual = "/opt/retropie/emulators/retroarch/bin/retroarch -L /opt/retropie/libretrocores/lr-tgbdual/ --config /opt/retropie/configs/gb/retroarch.cfg %ROM%"

The line I added is coloured: The green parts are things copied from the line above, and the red parts are new – those parts tell the launcher to use the recording config we made in the previous section.

When you’ve made your edits, press Ctrl-X to exit nano, and type “Y” when it asks whether you want to save.

Once you’ve done something similar to this for every emulator you want to record with, you are ready to actually do the recording!

Actually doing a recording

Launching a game with recording turned on

In the normal RetroPie interface, go to your emulator and start it, but press the A button while it’s launching, and choose “Select emulator for ROM”. In the list that comes up, choose the new line you added in emulators.cfg. In our example, that was called “lr-gambatte-record”.

Now play the game, and exit when you are finished. If all goes well, the recording will have been saved!

(Note: doing this means that every time you launch this game it will be recorded. To stop it doing this, press the “A” button while it’s launching, choose “Select emulator for ROM” and choose the normal line – in our example that would be “lr-gambatte”.)

Getting the recorded files

To get your recording off the RetroPie, go back to your computer, open a terminal, and type:

scp pi@*.mkv ./

This will copy all recorded videos from your RetroPie onto your computer (into your home directory, unless you did a cd commmand before you typed the above).

Now you should delete the files from your RetroPie. Log in to the RetroPie as described in the first section, and delete all recording files by typing this:

Note: This deletes all your recordings, and you can’t undo!

rm recording_*.mkv

Note: This deletes all your recordings, and you can’t undo!

Safer: recording onto a USB stick

Note: recording directly onto the RetroPie like we described above is dangerous because you could fill up all the disk space or corrupt your SD card, which could make RetroPie stop working, meaning you need to wipe your SD card and set up RetroPie again.

It’s safer to record onto a separate USB disk. To find out how, read “Recording to an External Storage Device” in Retro Resolution’s guide.

Hack24: Flaming Background Righteous Fist Business Fish

A Hack24 Story

A couple of weeks ago I competed in Hack24, a hackathon held in Nottinghams’s Council House.

The team consisted of Lex, Joe and Dexter and we were Flaming Background Righteous Fist Business Fish (Joe’s idea).

We went into the 24 hour hackathon intending to go for 2 of the sponsor challenges: Unidays and Packed Pixels.

The Unidays challenge was so somehow integrate a a song into your hack. Most people, including us, chose to make the name of our hack some kind of pun in a popular song title.

The Packed Pixels challenge was to make a hack with a price of hardware that was integral to the functionality of the hack.

Inspired by these challenges, we came up with MAC:ARENA.

The Plan

The original concept behind MAC:ARENA, conceived the night before the hack began, was a game in which you ‘collect’ the MAC addresses of your Bluetooth devices by connecting different devices via Bluetooth to a BBC Micro:Bit.

On connection of a new device the Micro:Bit stores that unique address up to a limit of 4 addresses (only for as long as it’s powered, unfortunately).

Two players may bring their Micro:Bits to the MAC:ARENA once they’ve collected 1 or more addresses.

The MAC:ARENA is a Raspberry Pi 3 computer wired up to a receipt printer.

With the competing players Micro:Bits connected to the Pi via Bluetooth, the Pi uses the players choose MAC Address as a seed to generate a Mac Monster from a wide range of combinations of body parts.
Joe is a good artist, so his task was going to be making those individual body parts (as well as the final video).

Each MAC generates a different monster with different stats, but will always generate the same monster.

The Pi then prints the two competitors monsters and plays out a Pokemon style battle on the receipt printer. Complete with sound effects masterfully generated in a similar way to the body parts, procedurally, based on the MAC address used utilising PureData by Dexter.

A simple concept. That can’t be TOO hard, right?

The Hack

Unfortunately things didn’t go to plan.

On arrival to the hack we spent way too long working on the Micro:Bits trying to get Bluetooth to even connect properly to another device. Only to find that the Bluetooth API doesn’t provide an interface to the connected devices MAC Address. ?

Switching gears, we broke out the Raspberry Pis we had and the USB Bluetooth adapters for them.

With the intention of using them as the devices to collect and store the Bluetooth MAC addresses, we jumped into the afternoon.

By midnight Saturday, we’d barely made progress. This was almost entirely down to struggling to connect too and test code on the Pis. We had to run a network switch and portable router (to behave as DHCP Server) to allow us connect to the Pis over SSH. However, the router was flaky, often refusing to hand out IPs. This meant many frustrating hours of (mostly Lex) unplugging and resetting the router to try and get it to work.

We also had some trouble being able to download Python modules and their dependencies onto the Raspberry Pis. This spurred a couple of visits home just to use internet with more than a couple of carrier pidgeon’s worth of bandwidth.

Without being able to test code on the Pis we couldn’t test or even write our code for the MAC:ARENA since the receipt printer needed to connect over serial via GPIO on the Pi.
We did manage to work on the code for the clients (i.e what WAS going to be Micro:Bits) because I could run that code on my laptop, since it has a Bluetooth chip.

At around 1:00am Sunday morning, we all went our separate ways towards home to get some sleep.
Myself and Lex went home and stayed up a few hours more to make use of an actually reliable internet connection and a working local network to get some useful things done on the Pi.

Returning in the morning, we got to work finishing what we’d got.
By the midday cut off time of the end of the Hack we’d put together most of the hack, just not in a way that all the parts talked to each other.

We’d got the bluetooth clients working on my laptop, utilising an LED Matrix to display MAC addresses captured and allow the user to select if they wanted to keep the address or not.

We also had the receipt printer working, printing monsters generated using a MAC address.
As well as that, we had a great selection of PureData sound effects creating ‘roars’ for each and every unique MAC address.

The Result

Hack24 awards prizes in an interesting way. Unlike most hackathons, you don’t have to present your work on a stage. Instead you have 2 hours to make a short video to sell your hack to the judges.
It can be a serious or as ridiculous as you like. As long as its clear what challenges you were trying to target.

We had Joe. So obviously our video was more on the silly side.

We were up against some amazing other entries. Some that hit the briefs much better than we did.

However, to at least my surprise, we won something!
We were lucky enough to win the Unidays prize for best song title tie-in with MAC:ARENA.
Certainly a great achievement considering that most of the other teams also entered this challenge, compared to other challenges with only a handful of teams entering each of them.

We were also nominated for the Packed Pixels Hardware Hack challenge. Although we didnt win, we’re still pretty proud that we were even considered!

In Conclusion

We had a great time. Despite spending a lot of time stressed due to bad internet, hardware being as horrible and flaky as you’d expect and general hackathon madness.

I’d like to thank the other competitors for coming up with some seriously good hacks. And of course, the organisers of Hack24, Emma and Andrew along with all the other 10s of organisers, volunteers and sponsors. You did a great job!! We thank you for the opportunity.

We’re very proud of what we built. I certainly want to take this further and actually complete the thing as we intended it to be. But we’ll see if I ever have time to do that.

Thanks Hack24!