Raspberry Pi Live Kitten Stream

What in the hell?

Okay, I admit. I have spare Raspberry Pis just laying around the office. It’d be nice if they were doing SOMETHING right? I heard somewhere that the internet has a thing for cats so this seems like a perfect solution to my problem.

Install Dependencies

We start by running an update/upgrade on our Debian package manager:

sudo apt-get update;
sudo apt-get upgrade;

Now we can install Python (Used by Livestreamer, Omxplayer and a couple of other dependencies):

sudo apt-get install python-pip omxplayer librtmp-dev gcc python-dev libffi-dev;

Install Livestreamer

Now we can install the Livestreamer command, this CLI tool will allow us to hook into a bunch of streaming websites such as Twitch, Ustream, Livestream, Dailymotion, and even YouTube Live:

sudo pip install -U livestreamer;

Install “Desktop” stream support

There are some additional libraries needed in order to provide some “Desktop” streams, which is just a fancy way of saying a higher bitrate/better quality streams. I don’t know about you, but I love some hi-def kittens:

sudo pip install cffi;
sudo pip install python-librtmp;

Find the Kitten Stream

Now we will search the Ustream website for a live stream of kittens:

Ustream.tv - Kitten

The top result I found was Animal Planet’s Live Kitten cam, which is a live feed of an animal rescue center in Washington, make sure to take a note of the URL of the stream:


Setting up the Stream

Now that we have our live Kitten feed. We need to write the script that will fire up the stream via the Livestreamer command and pipe the stream to the Omxplayer command we installed earlier.

cd ~;
mkdir toocute;
cd toocute/;
nano toocute.sh;

We will then add the following bash script into the “toocute.sh” file (borrowed from miguelgrinberg.com:

while true
    livestreamer http://www.ustream.tv/toocute best --player omxplayer --fifo --player-args "--win \"0 0 1600 1200\" {filename}"

This script will restart the livestreamer command if it stops executing. Which is usually caused by buffering.

Now we need to make this script executable:

sudo chmod +x toocute.sh;

And we can now run the kitten stream by:


A Couple Caveats

If you’re running into any issues such as the stream keeps restarting or the stream freezes up (buffers), you may have to use a different (lower) stream quality in order to provide a smooth playback. In order to do so- you will need to modify your script to pass in a lower quality option such as 480p:

while true
    livestreamer http://www.ustream.tv/toocute 480p --player omxplayer --fifo --player-args "--win \"0 0 1600 1200\" {filename}"

Exiting the script

In order to exit from the stream you will need to hold down “Ctrl + C” in order to end the stream command and then exit from the bash script. It could take about 10 seconds to fully exit the command.


If you have any questions or comments let me know below. What will you stream from your Raspberry Pi?