Intro: RASPBERRY PI Interrupt Driven Video Switching
The goal of this project is to provide a dynamic display to a trashbox.
A main video is played in loop on the display.
Everytime an object is thrown into the trashbox, the display switches to a small video (featuring scrat, hyrax or minions)
The project is based on the excellent RPI video looper from Steven Hickson
Step 1: Main Chalenge
The main chalenge was to switch from the main video to another video without delay.
omxplayer is definitely too slow for that kind of switching. I nearly gave up before I found a way to pause omxplayer and to launch the other video with hello_video.bin, bringing the switching delay to about nothin
The only drawback is that hello_video.bin can only read .h264 video format, while omxplayer can read nearly all formats.
Step 2: Main Program
The main program is called startloop.py
Basically, il plays all main video in directory /media/USB/videos in a loop
Sensor 1, 2 and 3 will generate interrupts on pin 11, 9, 25 respectively
Everytime a sensor detects an object, a small video is played from directory /media/USB/button
Step 3: Watchdog
Some times, the main video may stop looping for unknown reasons.
A watchdog was build to restart the videoloop service.
The watchdog constantly monitors the cpu consumption of the process omxplayer.bin
If the CPU consumption goes below 10% or above 50% for more than 10 sec, the videoloop service will be restarted
Step 4: Video Files
The main video is stored in a directory called "videos" on the root of an USB key that will be plugged in the raspberry.
The small cartoon are stored in three directories "button1", "button2" and "button3" on the root of the same USB key.
This allows to change the videos easily without changing the RPI program.
Notice that the small cartoons have to be saved as .h264 files.
Step 5: All Files Needed
This archive contains all the files needed for the project to work
Step 6: Installation
The file install.sh (included in the archive install.zip) will help you install everything...
Step 7: Finalisation
Two more steps are needed :
- First : modify the file /boot/config.txt the option "gpu_mem" must be set to 128
- Second : modify the file /boot/cmdline.txt following options worked for me
coherent_pool=6M smsc95xx.turbo_mode=N dwc_otg.lpm_enable=0 console=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 cgroup_enable=memory elevator=deadline rootwait