Skip to content

An open source triggered video player/looper for Raspberry Pi (video kiosk) useful for artists, creatives, advertising, interaction.

License

Notifications You must be signed in to change notification settings

JesseCake/RPi_Triggered_video_player

Repository files navigation

A Raspberry Pi Video content triggered looper/logic set of players for artists
(Loop, trigger, multi-play on multiple monitors, logic trigger, you name it!)

Initial version by Jesse Stevens (from artist duo Cake Industries) 26-3-2018, network versions added 12/9/2019, GPIO version 1-2-2021.

This video player is written in Python, and allows full logic control and triggering of video playback suitable for artists and creatives.

The first version here allows GPIO triggering of videos/logic and is fully configurable much like many commercial video solutions for video kiosks and signage.
If used simply for looping video, will allow video looping with crash protection.

The other version here allows the same functionality but with UDP network packet triggering instead of GPIO input, and is made to be run by launching the shell script. 
(older versions with various different methods etc in the /old folder)

** Instructions below are for the Network triggered version, will combine GPIO and Network in time **

The networking ability means suddenly you can interface and control video playback from a wide range things including:
- Arduino (UDP sending)
- MAX/MSP
- Puredata
- other programs you write (Python, C, etc etc)
- random gadgets (as long as you change what packet is matched to trigger)

Future versions will include:
- reintroduction of seamless looping (it was proving unreliable in omxplayer after several hours)
- scripts for running as system process on boot
- scripts to automatically mount USB drives and use the contents of the USB as media source
- scripts to mount all USBs in the same position to allow videos to be loaded from USB instead of internal storage
- more complex options like Raspberry Pi screen configuration etc.

We use this now in our works meshing video with mechatronics/robotics so that we can match up videos with physical movement.

Requirements:
- Raspbian lite installation (no desktop required)
- omxplayer
- python 3 (Python 2 for the GPIO version possibly? Stupid spaces/tabs!)
- python3-psutil (library) - possibly others
- possibly other python libraries (I'm sure I'll get back to this to make sure)
- set gpu-mem to a higher amount to allow better video playback in your /boot/config.txt file:
    gpu_mem=192

Getting running:
==================

1.
=====
Ensure you have a "video" directory in your pi user's home directory with:
mkdir /home/pi/video
Place your videos to trigger in here. H264 Videos work best.
"start.mp4" will run as a placeholder when not triggered and on startup. 
"video1.mp4" will be played once when triggered from first trigger
"video2.mp4" will be played once when triggered from second trigger

2.
=====
Config and support programs/libraries:
Disable console "screensaver" so that it never goes blank by adding to the end of "/boot/cmdline.txt":
consoleblank=0
Also add the root user (the user that effectively is used to run /etc/rc.local commands) to the tty group:
sudo adduser root tty
Install omxplayer:
sudo apt install omxplayer
Install Python psutils library:
sudo apt install python3-psutil
(FOR GPIO VERSION ONLY):
Install Python library for Raspberry Pi GPIO usage:
sudo apt install python3-rpi.gpio

3.
=====
#################
For UDP version:
#################
Place the files:
"TriggerPlayerLaunch_UDP.sh"
"TriggeredVideoPlayer_NetworkUDP_v9.py"
into your home folder (/home/pi/).

Ensure that the TriggerPlayerLaunch_UDP.sh file is executable. You can make it so by typing:
"chmod a+x /home/pi/TriggerPlayerLaunch_UDP.sh"

#################
For GPIO version:
#################
Place the files:
"TriggerPlayerLaunch_GPIO.sh"
"TriggeredVideoPlayer_GPIO_v9.py"
into your home folder (/home/pi/).

Ensure that the TriggerPlayerLaunch_GPIO.sh file is executable. You can make it so by typing:
"chmod a+x /home/pi/TriggerPlayerLaunch_GPIO.sh"

4. 
=====
Test that the code works properly by launching it via ssh on your Raspberry Pi (you will lose your console directly on the screen).
(this may need you to enable SSH access on your Raspberry Pi by creating an empty file called "SSH" on your /boot partition. This will enable it!

You can launch the program to test it directly by typing the following:
UDP VERSION:
"sudo /home/pi/TriggerPlayerLaunch_UDP.sh"

GPIO VERSION:
"sudo /home/pi/TriggerPlayerLaunch_GPIO.sh"

This will take a short moment to start and you should see it begin to play videos.

If you'd like to test the python script directly, so you can make adjustments or troubleshoot, simply do the following:
UDP VERSION:
"python3 /home/pi/TriggeredVideoPlayer_NetworkUDP_v9.py"

GPIO VERSION:
"python3 /home/pi/TriggeredVideoPlayer_GPIO_v9.py"

To kill it off, it might take a couple of Ctrl-c's to stop (threaded processes).

Included in the files is a Python UDP packet sender that will send a UDP packet to trigger video 1 for the UDP version: "SendUDPtester.py" 
You'll need to adjust the IP address in this script to suit the IP of your Raspberry Pi. Each time you run it, it will send a trigger.

If you're successful on this step, and everything is working as you want it to, do the next step.

5.
=====

Set your Raspberry Pi to start the triggered player on boot up.

Add the following to your "/etc/rc.local" file, BUT BEFORE THE LINE THAT SAYS "exit 0" otherwise your system will hang:
FOR UDP VERSION:
/home/pi/TriggerPlayerLaunch_UDP.sh &

FOR GPIO VERSION:
/home/pi/TriggerPlayerLaunch_GPIO.sh &

This will now start the triggered player on boot up as a forked background process. Good luck!

ALTERNATE USAGE:
=================

Perhaps you only want a seamless looping player? You can follow the instructions as above, but simply place your video in the video folder as:
start.mp4

This will permanently loop the video forever. Without any triggers, it will simply be a looping video player with some crash protection.

Also included here is a prototype dual head video player that will output a different looping video on each output of a Raspberry Pi 4. This is early days for this setup, but very handy to have a single Raspberry pi for two monitors next to each other. This is named "MultiMonitorVideoLooper_v1.py". Use as you wish!


Thanks!
==========
We hope this has been useful to you, we've certainly used it a lot in our installation pieces. Feel free to contribute and help make a useful open source player for everybody.

I'm also open to commissioning to build the logic you require for your project/work, or adding features that you require.

Don't hesitate to get in touch,

Jesse
Cake Industries (artist duo)
www.cake.net.au

About

An open source triggered video player/looper for Raspberry Pi (video kiosk) useful for artists, creatives, advertising, interaction.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published