‹ USB Soundcards Mod under the hood changes 2 ›

Cheap 4-channel Videoplayer

2013-07-30 00:18 visuals

For the dance piece Ich(a) by Zufit Simon I constructed a system with four Raspberry Pi mini-computers and buttons to trigger playback of four video streams. As the videos didn't need to run in exact frame-by-frame sync, this was a very cheap way to get four channel high-quality video playback. Total cost was about (RPi 28 * 4) + (SD card 6 * 4) + (5V power 1 * 7) ≈ 141 Euro. I chose the model A of the Raspberry Pi to keep the cost and power consumption down. The four computers share a 5V power supply of 2 amps and are powered over the GPIO pins. Video cables run 50 meters down to the stage and into separate flat-screen monitors. The monitors are built into boxes that can be piled up or rolled around independently.

The videos are stored on the 4 GB SD cards that also holds the Linux operating system. I converted the videos from DVD to MP4 using ffmpeg with the following settings...

ffmpeg -i concat:"/Volumes/MONITOR01_may2012_DVD/VIDEO_TS/VTS_01_1.VOB|/Volumes/MONITOR01_may2012_DVD/VIDEO_TS/VTS_01_2.VOB" -an -vcodec libx264 -profile:v high -preset fast -crf 18 -b-pyramid none -f mp4 MONITOR01_may2012.mp4

That'll take two chapters and convert to a single MP4 and skip the audio track (-an flag).

The Python program running on each computer is here below. It plays a video to the end and waits for a button trigger. If a button is pressed before the video is finished, it'll stop and jump to the next video - all in a cyclic fashion.

#for a Raspberry Pi running Raspbian
#this script will cycle through videos in sequence when a GPIO pin is grounded

#pinSwi (pulled up internally) - GND this pin to switch to the next video
#pinOff (pulled up internally) - GND this to shut down the system

videos= ['/home/pi/ICHA1.mp4', '/home/pi/MONITOR01_may2012.mp4', '/home/pi/BLACK.mp4', '/home/pi/FLESH.mp4', '/home/pi/TESTBILDER.mp4']
delays= [0, 0, 0, 0, 0]  #extra start delay time in seconds - one value for each video
pinSwi= 23
pinOff= 24

import pexpect
from time import sleep
import RPi.GPIO as GPIO
import os
GPIO.setup(pinSwi, GPIO.IN, pull_up_down= GPIO.PUD_UP)
GPIO.setup(pinOff, GPIO.IN, pull_up_down= GPIO.PUD_UP)

def main():
  os.system("clear && tput civis")  #clear and hide cursor
  index= 0  #keeps track of which video to play
  while True:
    omx= pexpect.spawn('/usr/bin/omxplayer -rp '+videos[index])
    omx.expect('Video')  #play
      if GPIO.input(pinOff)==False:
        omx.send('q')  #quit
        os.system("tput cnorm && sudo halt")
    omx.send('q')  #quit
    sleep(0.5)  #safety
    index= (index+1)%len(videos)

if __name__ == "__main__":

Instructions for installing

(you'll need a model B to prepare an SD card, but then move it over to the model A Raspberry Pi)

prepare the RPi

copy files from macOS

back to model B

start model A

Useful commands

(connect a keyboard to RPi model A, type pi/raspberry to log in)

sudo pkill omxplayer.bin #might need to write this without the terminal being visible


ssh-keygen -R raspberrypi.local     #useful for resetting ssh/scp after changing SD cards

It's not pretty but it's working. Some day I'll build it into a real rackmount box.




‹ USB Soundcards Mod under the hood changes 2 ›