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

Alexa Steinbrück
6 min readFeb 27, 2022
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:

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

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

  1. Install the Raspberry Pi OS on your Pi (ca. 8min)
    — Mount the micro SD card in your computer
    — Use the “Raspberry Pi Imager” Application to install an OS
    — We’re going to install Raspberry Pi OS Lite (Legacy), a legacy version of the OS because of the video libraries (omxplayer) we’re going to need
  2. Copy your video file to the /boot folder
  3. Instruct your Pi to allow SSH connections:
    — In the same /boot folder create an empty file called ssh (no extension, no content). This just sets a flag to tell the OS that we want to enable SSH
  4. Instruct your Pi to automatically connect to your WiFi whenever it boots:
    — You need to create a file named “wpa_supplicant.conf”. It contains the necessary settings to connect with your WiFi, e.g. the name (SSID) of your WiFi, the password, the type of encryption, the country code, and more. You can find a sample file here
    — Copy and fill in your data
    — Copy the file into the /boot folder of the SD card
  5. Put the SD card into your Pi and connect it to electricity. It should now be booting up
  6. Connect a monitor to your Pi to see when booting has finished and if there were any problems

2. Get it connected

  1. In your router’s admin interface search the list of connected devices, look for a device named “raspberrypi” (or similar). Give it a few minutes.
  2. If your Pi does not appear in the list of connected devices, try these troubleshooting tips
  3. If it does appear on the list, congratulations! You can now communicate with your Pi:
  4. Open a terminal on your computer and try if you can speak to the Pi:
    ping raspberrypi If the name doesnt work, try with the IP address (should be visible in the list of connected devices) Stop the output by hitting control + C (on Mac)
  5. Now try to ssh into it. Type: ssh pi@raspberrypi
  6. You will get prompted for the password. The default password is: raspberry

3. Install libraries and scripts

  1. Install libraries
    sudo apt-get update
    sudo apt-get dist-upgrade
    sudo apt-get install omxplayer
    (this can take about 10 minutes..)
    sudo apt-get install screen

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

  1. Repeat Steps 1–3 from the previous tutorial! (1. Flashing the OS, 2. Copy video file, 3. Allowing SSH)
  2. Inside the boot partition of the SD card there should be a file named config.txtconfig.txt. Open it with a text editor (I use Visual Studio Code) and add the following line at the very bottom: dtoverlay=dwc2
  3. There should be another file named cmdline.txtthat you’re going to edit: Add the following after the rootwait parameter: modules-load=dwc2,g_ether
  4. Put the SD card into your Pi
  5. Connect your Pi to your computer via a USB data cable. Use the data + power port (see picture). Important: You need to use a real USB data cable, not a regular USB charging cable. Your Pi should now be booting up.
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

  1. On your Mac, go to “System Preferences” → “Sharing”. Then enable Internet sharing via WiFi. Under “To computers using” select “RNDIS/Ethernet Gadget”. Our Pi is the so-called “Ethernet Gadget” here :-)
  2. You might have to reboot your Pi now via ssh: sudo reboot (this will stop your ssh connection so you have to connect again)

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!

🎉🎉🎉

--

--

Alexa Steinbrück

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