David’s Video Player

Introduction

David loves watching videos, but is unable to handle a DVD player, iPad or computer mouse.  This page describes his adaptive video player.  David can select and play any of his videos using a one button adaptive switch.  This player requires no training. It will work for anyone and any switch.

What it does

The device is a video jukebox.  The videos are stored on one or more flash drives.  The user has one switch.  Pressing the switch starts the next video in a list.  The user keeps pressing the switch until the desired video starts playing.  When the end of the list of videos is reached, the list starts over.  A second switch can be added to step backwards through the video list.

How well does it work?

You can see it in action here. 

David uses his video jukebox every day. It has changed our lives and his.  He loves his independence and, meanwhile, caregiving is much easier.  There are two versions of the system.  The first version was in operation for nearly 10 years.  (See comparison.)  The new version is smaller and easier to manage; it is described here so others can use it.

How do I get one?

There is no commercial source for the video jukebox.  You have to make one, or get help making one.  The biggest job is converting DVDs to video files for storing on a disk.  The rest requires a computer nerd and a little bit of wiring.  It is my intention to provide all the necessary information to make one. The following describes how to make a system. However, there is a newer version with detailed instructions that can be seen on my builder web page: https://hackaday.io/projects/hacker/445506

Overview of how to make a PlayVideo system

Here is an outline of how to make one.

  1. Use the shopping list (bill of materials) I provide to buy a Raspberry Pi 3, plastic boxes, some electronic parts, wire, flash drives and a microSD card.
  2. Find someone handy with a soldering iron and a hand drill to make the interface box.
  3. Download some free software tools and my “image” of the Raspbian operating system that has been configured to run PlayVideo.
  4. Burn the image onto a microSD drive.
  5. Learn how to rip/convert all your DVDs and other videos into MP4 files.  I am not going to provide very much detail on that process.  It is the same as ripping a video for an iPad or other pad device.
  6. Put the MP4 files on one or more flash drives.
  7. Use my instructions to figure out how to make a special text file (list.txt) that sets the order videos will play.  Copy the file onto the flash drive.
  8. Plug the power, amplified speakers and HDMI monitor into the Raspberry Pi.  Plug an adaptive switch into the interface box.  Hit the START button and cross your fingers.

Hardware features of PlayVideo

Pi with interface - small
On the left are two plastic boxes held together with Velcro. On the right is a keyfob for wireless operation.

PlayVideo has 3 components: a Raspberry Pi 3 computer (bottom box in photograph), my interface (top box in photograph) and a wireless keyfob.  Wireless keyfob operation is optional.  The keyfob in the photo has 4 buttons.  David is able to use 2 buttons, forward and backward.  The interface box has two 1/8″ phone jacks for using standard adaptive switches.  Thus, this interface supports either wired or wireless pushbuttons.  For David, I remove the guts from the keyfob and install them into a gamepad.  The modified gamepad is a lot of work.

The Raspberry Pi 3 does not come with a power-on or power-off switch like most computers.  The red pushbuttons (labeled START and STOP) provide a convenient power on/power off feature.

Aside from the piggyback interface box, the only connections are a HDMI cable and a cellphone charger power cable.  If you like, you can plug amplified speakers into the audio jack of the Raspberry Pi.  Hidden on the bottom of the Raspberry Pi is a microSD card slot.  It holds the operating system and all of the software. I supply an image file to burn an 8 or 16 GB SD card completely configured and ready to operate.

Programmers can change the configuration or modify the C++ program by plugging a mouse and keyboard into the USB ports of the Raspberry Pi.  The source code and compilers are pre-installed on the SD.  Updates can be found on GitHub.  A 64 GB flash drive holds about 25 videos in MP4 format.  Up to 4 flash drives can be used to store videos.

Inside interface - small

This photograph shows the inside of the interface. It has 7 wires that carry signals to the Raspberry Pi.  There is a small circuit board for receiving the wireless keyfob switch.  There are also 2 transistors wired near the mini phone jacks.  The transistors and circuit board are only for wireless operation.  The wireless option is rather inexpensive (about $10) if you don’t mind the effort of wiring it into place.  You can build the box without the wireless feature.

The box is much simpler without the wireless option.  If you only need one adaptive switch, the box can be assembled with 5 wires and no circuit board.  In either configuration most wires connect to the GPIO header of the Raspberry Pi 3.  The START button goes to a small header that must be soldered onto the Raspberry Pi circuit board.

Building your own PlayVideo

Parts

The next two tables provide ordering information for assembling the PlayVideo hardware.  Note that a TV or computer monitor that accepts an HDMI input is required.  If that device does not have speakers, separate amplified speakers are also needed.

The parts lists here are for building a system that supports wireless (keyfob) switches.  Parts with an asterisk (*) in the Quantity are needed only for wireless switches.

Adafruit Industries

Quantity Part Number Description
1 3055 Raspberry Pi 3 – Model B – ARMv8 with 1G RAM
1 3082 Aluminum Heat Sink for Raspberry Pi 3
1 2256 Pi Model B+ / Pi 2 / Pi 3 Case Base – Smoke Gray
1 2244 Raspberry Pi Model B+ / Pi 2 / Pi 3 Case Lid
1* 1096 Simple RF M4 Receiver – 315MHz Momentary Type
1* 1391 Keyfob 2-Button RF Remote Control – 315MHz
 1  3002 Short Feather Male Headers – 12-pin and 16-pin Male Header Set
 1  2222 GPIO Header for Raspberry Pi A+/B+/Pi 2/Pi 3 – 2×20 Female Header

Amazon.com

Note that some of these part numbers are to purchase more parts than needed to build one PlayVideo system.  Specifically, only 2 of the 5 pushbuttons, 2 of the 20 female mono sockets, 1 of the 2 wall chargers, 1.5 feet of the 16 foot spool of wire, and 2 of the 10 transistors are needed.  This order shows 2 SanDisk flash drives.  The number of flash drives you will need (1 to 4) depends upon how many videos you want to include and the sizes of the video files. You can prepare the video files and determine their total size before buying more than one flash drive.

Quantity Part Number Description
1 B001T9CU40 Sandisk 16GB MicroSDHC Memory Card
2 B00FJRS6QY SanDisk Cruzer Fit CZ33 64GB USB 2.0 Low-Profile Flash Drive
1 B01EWXIJBM Ocharzy Plastic Black Electronic Project Box, 4 Pcs (3.94 x 2.36 x 0.98 inches)
1 B01481OB9W Uxcell AC 250V/2A 120V/5A 3 Terminals Spdt Momentary Tactile Tact Pushbutton Switch 5Pcs
1 B017CBO4MO 4 Pack CESS 1/8 Inch 3.5mm Female Mono Socket Panel Mount Chassis
1 B01EQWU9EO AXGIO Wall Charger 2pcs 2.4A 12W Portable USB Power Adapter for Apple
1 B016CJ4RCO ECHOGEAR 8′ Ultra Slim Flexible HDMI Cable – High-Speed
1 B00VU7PTKI iXCC Element 6 Feet Micro USB to USB 2.0 Charge and Sync Cable, USB A to Micro B Cable
1  B01FW9ALZW Raogoodcx 16ft/5m 10 Wire Rainbow Color Flat Ribbon IDC Wire Cable
1* B01DUDNMOO Doradus 10 Pcs 2N7000 N-Channel Transistor Fast Switch MOSFET TO-92

The current pricing for all the parts is about $163, which includes two 64 GB flash drives.  If you do not build a wireless version and already have a 2 A cell phone charger for this application, the cost is $30 less.

Interface box construction

About 7″ of colored ribbon cable connects the upper box (interface box) with the Raspberry Pi 3 in its case.  A notch in the plastic box and its lid allow the wire to exit the interface box.  There is an open slot for the wire as part of the Raspberry Pi case design.  A two-pin header must be soldered onto the Raspberry Pi board.  For some reason the board comes without this header.   The circuit board is marked RUN and a standard 2 pin header can be soldered (carefully) to the board. I found a link with a nice photo here: https://raspberrypisig.github.io/blog/hardware/2017/01/08/reset-switch-for-raspberry-pi/ .

I prefer schematics over pictorial drawings, so here is a schematic that shows how to wire the interface box to the Raspberry Pi 3.  Wireless Switch Schematic. The other option is to build the simpler box that only supports wired switches Wired Switch Schematic. Warning (July 2018), the new Raspberry Pi 3 B+ board has slightly different connections for the START switch. An updated schematic is coming soon.

Two wires from the start push button connect to the RUN header.  The remaining wires connect to the 40 pin GPIO header.  The connector I included in the parts list has 40 pins (2 rows of 20 pins), but only a small segment of it is needed.  You can cut it in half, or even smaller.  A 2 rows by 5 pins header would be sufficient.  The plan is to strip and solder the ribbon cable wires to the proper 5 pins of the GPIO header, as shown in the schematic.

If soldering the header wires is too challenging, you can use header jumpers.  See https://www.adafruit.com/product/266.    Plug one end of the jumper onto the correct GPIO pin and cut the other end off for soldering inside the interface box.

Here is a simple drill template and a label for the interface:  Wireless switch box drill template.  When assembling the interface box, omit the wireless receiver board and the two transistors if you are only using standard adaptive switches.  If you want to include the wireless option, the pin configuration of the transistors is here.

2N7000

The three solder lugs of the push button switches are labeled (C, NO, NC).  You want to use C and NO (common and normally open).  You also use only two of the three connections to the phone jacks.  The “ground” (sometimes called “ring”) connection sticks out the side of the connector.  The other pin you will use is the one furthest from the ground pin.  Be very careful when wiring the 5 volt pin of the GPIO header.  That pin is only needed for the wireless receiver board.

Installing the customized Raspbian PlayVideo

Download the PlayVideo compressed image file from GitHub. Look for the latest release (as of this writing, PlayVideo.29-Oct-2017.zip).  Unzip it.  The image has the Raspbian operating system completely configured to run PlayVideo on startup.  It is also configured with the development tools to change and recompile the PlayVideo program.

The next step is to download a program for transferring the image onto an 8 or 16 GB micro SD card.  I use Win32 Disk Imager .  After imaging the SD card, eject the SD card from your PC and install it in the Raspberry Pi 3 (while the power is disconnected).  Apply power to the Raspberry Pi to see if the system starts and if PlayVideo tries to load a video.  The load will fail without a flash drive, but it is a good test.  Next, test to see if holding down the STOP button causes the system to shut down.

The list.txt file

PlayVideo requires a flash drive named VIDOES.  The videos to play must be on that flash drive and, preferably, are stored as .mp4 files.  You can use three additional flash drives.  You must name them VIDEOS2, VIDEO3 and VIDEOS4.  See Preparing a library of video files, below.

There is one more requirement, the flash drive must have a text file called list.txt.  The text file has specific requirements.  It’s main purpose is to guide PlayVideo, telling it which videos to play and in what order.  In doing this, it tells PlayVideo how many videos are spread across how many flash drives.  The list.txt file also helps equalize the loudness of the different video files, since users are unlikely to be good at managing a volume control.

Components of the list.txt file

The list file is read one line at a time.

Blank lines and comment lines

Blank lines will be ignored.  Any line starting with an asterisk (*) is also ignored.  The asterisk is used for comment lines.

Video file line

A video file line starts with an integer numeric value, which should be between -6000 and 0.  -1000 is quieter than -500.  -6000 is the quietest (-60 dB).  The number that sets the volume is an attenuation factor.  -100 is 1 decibel (dB) of attenuation. It is to help reduce the volume of louder videos to equalize playback volume. The maximum negative value is -6000. If you want to think of it as a volume control:
Off         -6000
1%        -4000
5%        -2600
10%        -2000
20%        -1400
30%        -1000
50%        -600
75%        -250
90%        -90
100%        -1

The volume value is required.  It is followed by spaces or tabs, which is then followed by the file name.  The file name can contain spaces.  It must exactly match the file name on the flash drive.

The order of the video file lines determines the order of the videos when stepping forwards or backwards through the videos.

Disk change line

An at sign (@) is used to change which disk has the next video file(s) in the list.  The @ sign is followed immediately (no spaces) by the disk name.  Note, the initial disk is called VIDEOS.  The file does not have to start with the command @VIDEOS, but it could.

Example list.txt file

 * DVD List file. The filename of this file must match the environment variable DVDLISTFILE
 * A start "*" at the start of a line indicates a comment.
 * Empty lines will be ignored
 * Each line starts with a volume number (in decibels), one or more spaces, and then a file name.
 * DVD video files must be in the same directory as this list file.

@VIDEOS
-100 Stevie Ray Vaughan Tribute.mp4
-100 Hornsby Live.mp4
@VIDEOS2
0 Lyle Lovett.mp4
@VIDEOS
0 Pat Metheny We Live Here.mp4
0 Clapton Unplugged.mp4
-200 Cars.mp4

In the above list file, the first 5 lines are comments.  The first disk to look for video files is the default disk, VIDEOS.  The initial @VIDEOS command is optional and no @ command is needed if all the videos are on one flash drive.  The first video file to play is “Stevie Ray Vaughan Tribute.mp4” and it is played at a volume of -100, slightly quieter than default.  The 3rd video in the list (“Lyle Lovett.mp4”) is on the disk named VIDEOS2.  Since we want to play Pat Metheny We Live Here.mp4 right after playing Lyle Lovett.mp4, we need to switch back to the first flash drive (VIDEOS) using the @ command.   The last video is “Cars.mp4”.  The video selection after Cars would be back at the top of the file (Stevie Ray Vaughan Tribute).

If your flash drive named VIDEOS is large enough to hold all of the music, then you can simply omit the @VIDEOS and @VIDEOS2 commands. They would not be needed.

The limit to the number of file entries is set in the PlayVideo program.  At the time of this writing, the number of file entries is limited to 299.  The number of videos is limited by the number of 64 GB flash drives used. (The latest version of PlayVideo support 96 GB flash drives.)  The number of flash drives used has a practical limit of 4 because there are 4 USB sockets on the Raspberry Pi 3.  Presumably a powered USB could extend the number of drives.

Preparing a library of video files

There are two time-consuming steps to make a  video library for PlayVideo.  The videos must be “ripped” and compressed to MP4 format, and they must be stored on a flash drive with the list.txt text file.  Here is a condensed list of steps.

  1. Purchase a 64 GB or 96 GB USB flash drive.  Name it VIDEOS.  You must use that name for the drive. If you are using more than one flash drive, name the subsequent drives VIDEOS2, VIDEOS3, VIDEOS4, etc.
  2. Rip DVDs to MP4 format. I use Amazon Kindle as the target device. This can be a complicated process.  There are both commercial and free programs, often called video file converters. I use Handbrake (https://handbrake.fr/).
  3. Copy the MP4 files onto the USB flash drive.
  4. Create a text file with this name “list.txt”. Each line of list.txt describes one video.  Each line has one entry with a number followed by the video file name.
    number    name-of-video
    The number sets the volume level as described above.
  5. Save list.txt on the USB flash drive named VIDEOS along with the video files.
  6. Plug the USB flash drive into one of the USB ports of the Raspberry Pi 3.

Technical features of PlayVideo Software

Flow chart

When the Raspberry Pi starts up with the PlayVideo software installed, a series of configuration files make sure that the GUI loads and a lxterminal is spawned with exactly one copy of the Main program running (see diagram, above).  The Main program looks at environmental variables to see where the thumb drive is mounted, typically: /media/pi/VIDEOS.  The file list.txt is created by the user to list all the video files in the order they should be selected.  That file is read first. It also has an audio level associated with each video to help keep all the files at a reasonable listening level.  The List Manager object is initialized with this list and then keeps tabs of which video is playing and which one to play next.

The Main loop watches for a button press (interrupt) and responds by asking the Player object to kill the current omxplayer process, then spawn a new player to play the next video in the list.

2 thoughts on “David’s Video Player

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.