Halloween Forum banner

Triggerable Video How-to

4221 Views 8 Replies 4 Participants Last post by  matrixmom
Hello guys and ghouls,

I was tapped to help with some new effects in House of Restless Spirits this year, including figuring out how to get some video to be triggerable. The bad news is, due to circumstances beyond their control, the haunt won't be up this year, for the first time in 17 years. However, the good news is, I did get something figured out for the video, and wanted to share that here.

I first tried a couple of media players from Amazon. (Maybe I could hack the remote?) The problem is, once they're done playing the video, they'll always return to a menu (= no good). I wanted 1) black screen, 2) trigger -> play video, 3) back to black screen. No more, no less.

The solution I found employs a Raspberry Pi single board computer, and some already-written software for making shake-and-bake museum kiosks.

Features:
  • Upon power up (and after boot sequence), it goes directly to black screen, and waits for the first trigger (no kb/mouse required)
  • Trigger happens with either [ENTER] is pressed on a keyboard, or GPIO24 (pin 18) is connected to ground (pin 20). Medusa DMX users will be able to trigger video by connecting the Medusa ground to RPi Pin 20, and one of the "Switch" outputs to RPi Pin 18.
  • Plays a video from a USB stick (Video.mp4, in the root directory of the USB stick).
  • When the video is finished, it goes right back to black screen, to wait for the next trigger.
  • Audio goes out the 1/8" jack
  • Video goes out HDMI if it's connected, or out the composite connection if it's not.

Caveats:
  • There's a lot of setup (typing)
  • It looks like the video is loaded from the USB each time it plays, so there's a delay between the trigger and the playback that's proportional to the resolution of the video. ~2sec for 640x480, ~4sec for 1280x720, ~7sec for 1920x1080
  • There's a lot of setup. No, really. Seriously. For real, though.

Thanks go to Ken Thompson who wrote Pi Presents, the software you'll be installing. All I've done is document all the setup to the point of making it a how-to-make-a-pb&j-sandwich list of things to do. The setup involves downloading a Linux image and flashing it to an SD card, setting up the options on the Pi (think setting up a new computer, DOS-style), installing the software (again, think DOS), and finally, setting up the show that will run. There's a lot of stuff, but the good news is, if you mess anything up, you can just pull out the SD card, and start over.

I'll split it up into two posts below.

Enjoy!
- Hook
See less See more
1 - 9 of 9 Posts
First, we'll get a Raspberry Pi going. This involves downloading a Linux image, writing it to an SD card, and configuring the Pi how we'll need it. By the way, this assumes you're wanting a USA keyboard config.

  1. Download a Raspbian disk image
  2. Create a bootable SD card
    • Download Win32DiskImager (PC application)
      http://sourceforge.net/projects/win32diskimager/
    • Install Win32DiskImager to the PC
    • Plug the SD card you intend to burn with the image into the PC card reader
    • Start Win32DiskImager
    • Open the image file unzipped in step 1b.
    • In the dropdown for Device, carefully select the SD card (drive letter) you intend to burn with the image.
    • Click “Write” [NOTE: This will destroy any data on the selected storage device, and also format it with smaller capacity than it can support. The latter is recoverable, the former is not.]
    • Once the write has finished, remove the SD card. It is ready to load into the Pi
  3. Set up the Raspberry Pi hardware
    • Plug a 5V micro USB converter into the micro USB jack. This is power for the Pi
    • Plug an HDMI monitor into the HDMI port of the Pi
    • Plug a wired USB keyboard and mouse into the Pi
    • Put the SD card with the Raspbian image into the SD card slot on the Pi
  4. Install Raspbian - NOTE: use up/down arrows to navigate; use space to select, and tab to jump to <other options>
    • Power up the Pi. This will generate a bunch of scrolling text messages on the monitor. Wait until the Raspi-config screen comes up
    • Raspi-config
      • Do “Expand Filesystem” - this lets the file system use the whole SD
      • Do “Internationalisation Options,” "Change Locale" - Scroll down until you see the existing tick selecting "en_GB.UTF-8 UTF-8" and uncheck this by pressing the space bar. Scroll down until you see en_US.UTF-8, and select this by pressing the space bar. Tab to select "OK." Choose the same en_US.UTF-8 for the default locale.
      • Do "Internationalisation Options," "Change Keyboard Layout"
      • Don't actually change keyboard layout, nor any following options, except enable use of CTRL+ALT+BACKSPACE to terminate X server
      • In "Advanced Options," turn on “ssh,”just in case you want to use an external terminal to control the Pi later on
      • Select finish (Pi will reboot)
    • Log-in
      • Login: pi
      • Password: raspberry
  5. Configure keyboard mapping
    • At the terminal prompt, type...
      • sudo nano /etc/default/keyboard
        ("sudo" is to assume admin priviledge, nano is a text editor)
    • Navigate through the file using the arrow keys, and edit the line XKBLAYOUT="gb" to say XKBLAYOUT="en". (this changes the keyboard mapping, to match our keyboards, rather than Great Britain.
    • Hit CTRL-O, then Enter, to save the file
    • Hit CTRL-X to exit
  6. Configure automatic mapping of USB drives
    • Plug in the USB drive where you'll want it (and only have one plugged in!)
    • At the terminal prompt, type...
      • cd /mnt
      • sudo mkdir usb
      • sudo nano /etc/fstab
    • Below the other entries, but above the "# a swapfile..." messgage, type...
      • /dev/sda1 /mnt/usb vfat defaults 0 2
      • CTRL-O and Enter to save
      • CTRL-X to exit
    • Restart the Pi by typing at the terminal prompt...
      • sudo reboot
  7. Configure WiFi (optional, and only if you have a USB WiFi dongle)
    • At terminal prompt, type...
      • sudo nano /etc/network/interfaces
    • Edit the line "iface wlan0 inet manual," and all below, to say...
      • iface wlan0 inet dhcp
        wpa-ssid "your network"
        wpa-psk "your password"​
      • Of course, replacing "your network" and "your password" with the appropriate SSID and WiFi password
      • CTRL-O, then Enter, to save the file
      • CTRL-X to exit
    • Restart the Pi by typing at the terminal prompt...
      • sudo reboot
    • Log in again, and type at the terminal prompt...
      • sudo ifconfig
    • Look under wlan0 for an "inet addr:...." If this shows a xxx.xxx.x.xxx number, your Pi has received an IP address from your router, and is now connected to the internet.
See less See more
  • Like
Reactions: 1
Now that we've got a working Linux install on our Raspberry Pi, we'll download and configure the video player software to have it triggerable...

  • Install Pi Presents - website (for reference)
    • Plug an internet-connected network cable into the network jack on the Pi (or have configured WiFi)
    • Install required applications (PIL and X Server utils)
      • At terminal prompt, type
        1. sudo apt-get update
        2. sudo apt-get install python-imaging
        3. sudo apt-get install python-imaging-tk
        4. sudo apt-get install x11-xserver-utils
        5. sudo apt-get install unclutter
    • Download and install pexpect
    • Run LXDE desktop
      • At terminal prompt, type
        1. startx
    • Download Pi Presents
      • Double-click on LXTerminal to get a terminal window within LXDE desktop
      • At terminal prompt, type
        1. cd /home/pi
        2. wget https://github.com/KenT2/pipresents/tarball/master -O - | tar xz
        3. ls
      • Find the file named KenT2-pipresents-xxxx, where xxxx is a version.
      • Taking this name, at the terminal prompt type... (this renames to pipresents)
        1. mv KenT2-pipresents-xxxx pipresents
  • Set up a "profile" (show)
    • Insert media to play into USB. Have the video in .mp4 format, and called video.mp4
    • At terminal prompt, type
      • cd /home/pi/pipresents
      • python pp_editor.py
    • Within the editor GUI that popped up
      • Profile > New from Template > Exhibit
      • Name: Creeps
      • Click OK
      • Click on "Mediashow" in the Shows window
      • Show > Edit
      • Change trigger to PIR
      • Change duration to 0
      • Change OMX Audio to local
      • Click OK
      • Click on "media.json" in the Medialists window
      • Click the Add button near the "Tracks in Selected Medialist" window
      • Navigate to the video file on your usb drive, /mnt/usb/video.mp4
      • Click Open
      • Click on the first track in the "Tracks in Selected Medialist" window, the one with a "text message"
      • Track > Remove
  • Set up for truly fullscreen playback
    • Hide the taskbar
      • Right-click on the taskbar, and pick Panel Settings
      • Choose the Appearance tab
      • Set Background to Solid Color = black, with 255 opacity
      • Choose the Advanced tab
      • Under Automatic hiding, click "Minimize panel when not in use"
      • Click Close
    • Hide the border on the fullscreen playback window
      • Open the Leafpad application
      • File > Open
      • Navigate to Pi
      • Right click within the window, and select "show hidden files"
      • Open file .config/openbox/lxdc-rc.xml
      • Scroll down to the end of the file, and insert this text just above the line </applications>
        <application name="fspipresents">
        <decor>no</decor>​
        </application>​
      • File > Save
      • Restart xwindows to take effect
        1. Click on the "Start" (ish) menu, and Logout
        2. once back at the terminal prompt, type...
          • startx
  • Test profile (should be full-screen, and triggered by Enter button or GPIO)
    • Must have LDXE desktop (Windows-like environment) open
    • At terminal prompt, type
      • cd /home/pi/pipresents
      • python pipresents.py -b -f bottom -p Creeps
      • Once the screen has gone black, hit Enter to start playback
      • Once finished, hit CTRL-Break to exit
  • Set for auto-startup
    • At terminal prompt, type...
      • sudo raspi-config
      • Select "Enable Boot to Desktop"
      • Select "Desktop Log in as user "pi"...
      • Exit, and select reboot option
    • After reboot, and auto-login to LXDE windows, open a "Root Terminal" window
    • At the Root Terminal prompt, type...
      • cd .config
      • mkdir lxsession
      • cd lxsession
      • mkdir LXDE
      • cd LXDE
      • nano autostart
    • Edit autostart to say the following:
      • python /home/pi/pipresents/pipresents.py -b -f bottom -p Creeps
      • sudo python /home/pi/pipresents/pipresents.py -o /home/pi -g -b -f bottom -p Creeps
    • CTRL-O, Enter to save
    • CTRL-X to exit
    • At the Root Terminal prompt, type...
      • chmod 755 autostart
See less See more
  • Like
Reactions: 1
Okay - WHEW! So, if you've come this far, you should now have a Raspberry Pi ready to play your video!

  1. Put your mpeg 4 video in the root folder of your USB drive, and call it "video.mp4"
  2. Power up the Pi
  3. Wait for the bootup process to complete (scrolling text, opening X-Windows briefly, then black screen)
  4. Try playing the video by either pressing [ENTER] on the keyboard, or shorting pins 18 and 20 together on the Raspberry Pi's IO connector

Oh yeah, and if you ever need to get back to X-Windows once you've set everything up, wait until the video finishes playing, and hit CTRL-Break.

Happy haunting! And if anyone runs through this, and has any feedback (or finds a mistake), please let me know!
- Hook
See less See more
  • Like
Reactions: 1
I've been thinking about doing this ever since I got my Pi!! A $35 high def video player, triggerable via the IO pins should be of interest to the community. Add a $25 camera module and you could incorporate video recording and playback into your haunt!!

Thanks for the great (detailed!!!) how to!
  • Like
Reactions: 1
Hooked_on_Scares, thanks for writing this out in a step by step, I have been going through the pipresents manual and online instructions, which sometimes assumes a little more than I know about programming. Last year I used a video player, which I had purchased from a vendor - and it was okay, but I am determined to use this raspberry pi this year. So far so good.
Techster,

I didn't know jack about Linux before starting the project, only had a vague recollection of a few Unix commands from my college days... back when school email was text-based through Pine.

The beauty of Raspberry Pi stuff is, there's so much support on the internet, that all you really need to do is find a step-by-step, and follow it. That's what I tried to do here. I told Eric Maurin of House of Restless Spirits that I figured a Pi would be able to do it, but that it'd probably be a year-long project for me to figure out how to program it to do it. But most things you can think of doing, someone's already written a program to do it! (e.g.: PiPresents guy). No programming necessary.... just a huge amount of installing and configuring (as seen above).

Give it a shot! And hey... if you happen to find a better program (or workaround) to get the video to stay resident in RAM, and not have to delay each time it's triggered, post the fix here! :)

- Hook
See less See more
Seconding Hook's encouragement: there are a million very detailed tutorials on how to do anything on the Pi. It doesn't take long to figure out what the commands mean.

I also have no Linux experience but I've started my ScareCam project, which uses the Pi and the camera module as a DVR for instant playback. When a scare is triggered, it also triggers the Pi to start recording, and will then play it back for all to chuckle at... kinda like the roller coaster cams at the amusement park. So far I have a button hooked up to the GPIO pins triggering recording to start and a file to be saved to the root directory. Hook I can take a look at the PiPresents python scripts and see if I can get it to save somewhere else.

Thanks for all the hard work!
1 - 9 of 9 Posts
This is an older thread, you may not receive a response, and could be reviving an old thread. Please consider creating a new thread.
Top