Skip to content

Instantly share code, notes, and snippets.

@anthonyray
Created September 6, 2019 15:45
Show Gist options
  • Star 28 You must be signed in to star a gist
  • Fork 7 You must be signed in to fork a gist
  • Save anthonyray/bb6fd7363cd99204330f17c54513f293 to your computer and use it in GitHub Desktop.
Save anthonyray/bb6fd7363cd99204330f17c54513f293 to your computer and use it in GitHub Desktop.
Turn your Raspberry Pi into a kiosk playing looping videos

An acquaintance needed a video kiosk that plays looping videos for an exposition booth. Since I have a bunch of Raspberry Pis lying around, I figured that it would be the perfect use case for using one of them.

Let's assume we start from scratch, with a unflashed, brand new SD card and your Raspberry Pi.

Installing the OS

Install a version of Raspbian that includes the desktop. You can head over to : https://www.raspberrypi.org/downloads/raspbian/ and follow the instructions.

Once the image is downloaded, you can burn it to your SD card with tools like Etcher (https://www.balena.io/etcher/)

Connect the device to your network

Let's configure your raspberry to connect automatically to your Wifi. Create a file named wpa_supplicant.conf that has the following content :

country=<COUNTRY_CODE>
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
    ssid="Your Wi-Fi network name"
    psk="Your Wi-Fi network password"
}

Make sure to update the country, ssid and psk keys.

Insert the SD card in your computer and copy the wpa_supplicant.conf file at the root of the boot volume of the SD card. To enable SSH access add an empty file ssh also placed at the root of the boot volume on your SD card.

Insert the SD card in your raspberry Pi : You should now have SSH access to your Raspberry Pi. By default, its hostname will be raspberrypi.local.

Copy your video to the Raspberry Pi.

Download the video you want to play on your booth. Since we will be using vlc (https://www.videolan.org/vlc/), your video should have a format that is supported by vlc.

Open up a terminal, and you can copy the video to your Pi with the following command :

scp path_to_your_video/your_video.mp4 pi@raspberrypi.local:~

This will copy your video to the home directory of your Raspberry Pi.

Create a background job that will start playing your video when booting your Pi

We are going to create a background job that your operating system will launch at each boot of your Pi. To do so, we are creating a systemd unit file that will have this content :

[Unit]
Description=videokiosk

[Service]
User=pi
Environment="DISPLAY=:0"
ExecStart=/usr/bin/vlc -Rf path_to_your_video.mp4
WorkingDirectory=/home/pi
Restart=always

[Install]
WantedBy=multi-user.target

We created a systemd service that we call videokiosk.

  • We add a User field as VLC is not supposed to be started as the root user.
  • We add an environment variable called DISPLAY so that the video plays on the HDMI output of the Pi.
  • We use the -Rf flag in the vlc command so that the video plays in full screen and on repeat.

Connect to your raspberry Pi over ssh :

ssh pi@raspberrypi.local

Use your favorite text editor to create the unit file :

sudo nano /etc/systemd/system/videokiosk.service

Copy/Paste the unit file we described earlier. Enable the service to auto-start on boot.

sudo systemctl enable videokiosk.service 

To start the service :

sudo systemctl start videokiosk.service 

To view the latest logs, use sudo journalctl -xfu videokiosk.service

To view the current service status, use sudo systemctl status videokiosk.service

You should be good to go !!

@kevpwhite
Copy link

I am getting no audio any idea why?

@anthonyreinettesonos
Copy link

Sound may be output from HDMI or Jack.
There is a useful command line tool called raspi-config (invoke it with sudo raspi-config), that allow you to manage the output of the sound.

@tomse
Copy link

tomse commented Oct 29, 2022

Nice guide thanks, though video is not being displayed until I jump into windowed mode and back into fullscreen.
only change/differences are the username, work dir (to match username and actually working dir), using playlist instead of single mp4 file.

I changed to play a playlist instead of a single vid, the screen flickers (vlc jumps out of full screen, then back into fullscreen when videos are switched.

any tips on any of these issues?

@siteswapjuggler
Copy link

Trying this on latest Bookworm Lite release and it doesn't start any video... Do you remember which version of Raspberry Pi OS you used for this installation ?

@anthonyray
Copy link
Author

I believe it was the Buster release, but it was a while ago !

@siteswapjuggler
Copy link

Thanks for your answer I finally found a solution by using basic.target and adding a restart delay of 1s... so far it seems to work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment