How to configure your Raspberry Pi Zero to play videos in a loop (= cheap and flexible solution for video art installations)

Raspberry Pi art. Abstract triptych based on the innards of three models of the Raspberry Pi computer — the little one is the Zero model
“Abstract triptych based on the innards of three models of the Raspberry Pi computer — the little one is the Zero model” by https://www.flickr.com/photos/shakespearesmonkey/

This tutorial contains 2 sets of instructions depending on the type of Raspberry Pi Zero you have:

Recently my media art collective Moving Target set up a video installation for our new exhibition “(Y)OUR DATA IS A BATTLEGROUND”. The installation, titled “Latent Riot”, consisted of many screens of different sizes that were arranged to mimic the signs of a street protest scenario.

My job was to make the different screens play a different video each, in a synchronized and automated way, e.g. turn themselves on and off according to the opening times of the gallery. We already had a few Raspberry Pis lounge around in our collective’s stock, and I thought why not use them for this occasion? And indeed, it was a good choice!

Why you should use a Raspberry Pi for your video art installation:

💡 — They have an extremely low energy consumption
🐁 — They are small and they don’t draw attention away from your art
🤖 — They offer flexibility for automation, e.g. you can program them to turn the video on/off at a certain time
🌐 — They can be controlled remotely over the internet if you need it

Case 1: Your Pi has WiFi enabled (e.g. Pi Zero W)

Summary

— Communicate with your Pi via SSH over your WiFi network
— Install necessary video libraries via the internet
— Add a bash script to play a video file automatically

Requirements

— A computer
— A Raspberry Pi with a power supply
— SD-Card (optional: SD-Card reader for your computer)
— WiFi
— Helpful: access to the admin interface of the router
— Optional: A Monitor and a mini-VGA to XYZ adapter (whatever your monitor needs: regular HDMI, VGA or DVI)

Step by Step

1. Setup

2. Get it connected

3. Install libraries and scripts

2. Create the bash script
— Create a file called videoloop in the /etc/init.ddirectory:
sudo nano /etc/init.d/videoloop
— Copypaste the content from this link (step 3) into the file and change the varible video_path to match the path to your videofile (/boot/video.mp4)
— Change the permissions of the script to allow writing and execution:
sudo chmod 755 /etc/init.d/videoloop

4. Test if everything works

Run the following commands:
— Start the video loop:
/etc/init.d/videoloop start
— Close the video loop:
/etc/init.d/videoloop stop
— Re-open the video loop if it closes:
/etc/init.d/videoloop repair

Last step: Enable auto play whenever the Pi boots:
sudo update-rc.d videoloop defaults

Now reboot your Pi to see if the video plays automatically:
sudo reboot

🎉🎉🎉

Case 2: Your Pi doesn’t have WiFi enabled, e.g. the Standard Pi Zero (without a w in its name)

Summary

— Communicate with your Pi via SSH over USB/Ethernet & enable internet access on your Pi via Internet sharing on your Computer
— Install necessary video libraries via the internet
— Add a bash script to play a video file automatically

Requirements

— A computer
— Wifi
— A Raspberry Pi with power supply
— SD-Card (optional: SD-Card reader for your computer)
— USB Data Cable (important! Not a regular electricity cable as used for chargers etc…)
— Optional: A Monitor and a mini-VGA to XYZ adapter (whatever your monitor needs: regular HDMI, VGA or DVI)

Step by Step

1. Setup

The 2 Micro USB ports on a Raspberry Pi Zero

6. Connect a monitor to your Pi to see when booting has finished and if there were any problems during booting. If auto login isnt enabled (which is probably the case) it should end with a prompt to login. But we’re not going to login on our device directly, we’re going to do it remotely via SSH (next step):

7. On your computer type: ssh pi@raspberrypi.localand login with the default password: raspberry

2. Share Internet between your computer and the Pi over USB

3. Test if your Pi now has an Internet connection by typing: sudo apt-get update

3. Install libraries and scripts

See previous tutorial above!

4. Test if everything works

See previous tutorial above!

🎉🎉🎉

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Alexa Steinbrück

A mix of Frontend Development, Machine Learning, Musings about Creative AI and more