Skip to content

Instantly share code, notes, and snippets.

@indirect
Forked from anthonyray/kiosk.md
Last active October 30, 2021 00:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save indirect/cf2a38fc08605bb1063b0eb66a1490f7 to your computer and use it in GitHub Desktop.
Save indirect/cf2a38fc08605bb1063b0eb66a1490f7 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=XDG_RUNTIME_DIR=/home/pi
ExecStart=/usr/bin/mpv --no-audio --fs --loop --no-terminal Videos/myvideofile.mp4
WorkingDirectory=/home/pi
Restart=always

[Install]
WantedBy=multi-user.target

We created a systemd service that we call videokiosk.

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 !!

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