Live Hacktion Replay

What is it?

Here at Zuto Tech, we like to play table tennis, and some of us have got pretty good at it. Often, we'll play out a particularly sweet point, then congratulate each other on our outstanding skill. However, we really want to be able to share this with the world, so a few of us used our recent Hack Day to build something that would allow us to do just that.

The Product

Our product, entitled "Live Hacktion Replay", is a constantly running camera connected to a button. When the button gets hit, the camera will tweet out the last 30 seconds of buffered video. It all sounded so simple.

The Plan

We procured a Raspberry Pi 3, a camera node and a whole host of components for GPIO, including a breadboard, jumper wires, resistors and buttons.

Like any good tech project, it all started with a whiteboard.

The Plan

We'd use raspivid, run as a headless start-up process to create a circular 30 second buffer. The button press would then send a USR1 signal to the raspivid process which would upload the video in H264 format to Amazon S3.

We'd then create a Lambda function in AWS, triggered by an upload to the S3 bucket, which would use Elastic Transcoder to re-size and re-format the video, then use the Twitter API to upload the video and tweet it out to the world.

Building the Components

Appropriately, we commandeered our table tennis table to lay out our components and work out what we needed.

The Components

And quickly we got the pi into it's case, plugged the camera in and powered it up.

Building the Components

We then had all sorts of fun and games getting it connected to our wireless network. Here is Xavier from IT Support getting it sorted for us:

No Wi-Fi

Getting raspivid working was easy enough, and we used systemd to run it as a background service. This was less straight-forward, as we were using the -c switch to do a 30 second circular buffer, but this meant that a number of the other switches didn't behave as we'd expect.

We also found that the video it created was too big for the pi itself to play it, which made debugging a challenge.

The Camera Works

With a working camera in place, and the circular buffer recording video, the next step was to get the button working. We wired up the breadboard to the GPIO section of the Pi. At this point, we learnt that plugging an LED into the +/- of the breadboard is a BAD idea. Here is the fried LED as evidence:

Fried LED

After some frantic wiring and some nervous moments, we eventually got the button set up, and wrote a Python script to detect the button press... and success! Here's the celebratory team picture:

A working button

At this point, we were running short of time, so we had to make some compromises.

We did manage to get the video uploaded to S3 quite quickly, but then decided Elastic Transcoder was going to be a step too far, so we converted the video from H264 to MP4 on the Pi before upload.

And alas, the Twitter API was also a step too far, so we scaled down the feature and decided to post a link to the video on S3 to a Slack channel instead, so we could at least share the videos with our colleagues.

Overall, it was great to do some electronics, and learn a lot about Linux, GPIO, Python and AWS in the process. Next steps are to make the hardware a little less flimsy, get it wired up to a big button, then get it mounted on the wall so we can start sharing our incredible table tennis skills with the world!

Dave Mason

Head of Software Engineering. Nurturing and empowering software engineers to create innovative, disruptive software that improves the lives of those who use it.


Subscribe to Zuto Tech Blog

Get the latest posts delivered right to your inbox.

or subscribe via RSS with Feedly!