How to Build a Cheap Car Movie Player Using Raspberry Pi

Watch Movies in the Backseat of Your Car

If you’re a parent, you know that long trips in a car with children can be… trying. Why not build a relatively inexpensive, in-car media player? The idea of a TV screen in the car is not at all new. In fact, you can right now drop a few thousand dollars and have one installed that plays DVDs from your dashboard. Or, you can spend significantly less and build something yourself that plays practically anything you can think of.

Raspberry Pi, is small, efficient, and it plays movies very, very well, thanks to its dedicated hardware support for video codecs. Here’s what you need to hack it together for those long car trips that need a little entertainment. Your Reliant (in Terms of Power) Automobile Really, any make or model of car should work for this, with one caveat: power. A bit of a history lesson is probably appropriate here. Once upon a time, it was cool to smoke cigarettes, and car manufacturers felt like they were doing their customers a major service by providing an on-demand heat source that they could use to light their smokes. This device works by connecting a thin coil of nichrome wire to a high current from the car’s electrical system. You’d push the handle in, the current would heat up the coil, and in a few seconds, the lighter would heat up (it would actually glow orange/red hot) and then the handle would pop out. You could then press the tip to your cigarette and enjoy the act of giving yourself lung cancer on the go.

Today, most people choose not to use those cancer sticks, but these “cigarette lighter” receptacles remain. Why? Because these ports provide 12 volts of electricity, and we have a lot of power-hungry gadgets that need juice. While some new vehicles provide dedicated USB (or even pronged power outlets), most of them still provide these standard, 12 V “cigarette lighter” plugs. In fact, a lot of cars that have them available intend for them to power only compatible accessories and don’t actually include the actual lighter (many even include an explicit message that states “this is not a cigarette lighter”).

These 12 V receptacles will power the parts for this hack. You’ll need three of them to do it the way described here. You might be able to get away with using only two, but you’d have to power your Raspberry Pi from a powered USB hub that also powers devices connected to the same Raspberry Pi, and that isn’t usually very reliable.

If you need more receptacles than your car has available, there are a few ways to hack around that. You can get a socket splitter, which will expand a single socket out to two. Some socket splitters even add a USB port in addition to the two sockets. With that setup, you could run everything that this hack needs off one 12 V receptacle. Other ways to get the power to your devices involve more complicated hardware setups or custom electrical wiring, so we’re not going to cover them here.


Your Car Is a Special Snowflake

Keep in mind that some cars might have these receptacles wired up differently. For example, on the Dodge Caravan, some of the 12 V ports are wired to the ignition and provide power only when the car is turned on. Other ports provide power directly from the battery and will have juice even when the engine isn’t running. Every make, model, year, and variant of vehicle will have its own eccentricities in this regard, so you should consult your owner’s manual to understand the ground rules.

Assuming you don’t have a USB power port available (either via a splitter or included in your car), you’ll need to get a 12 V-to-USB converter. These are a lot more commonly available (and a lot less expensive) than they used to be, but the fact is that you get what you pay for with these converters. A good rule of thumb is that if they’re free, they’re junk.

Let us elaborate on that a little bit before you go off to rage-trash your free converters that you picked up as swag at your last tech conference. Most of these converters assume that you are plugging in a phone or a tablet into them. In fact, they even assume you’re plugging in an Apple phone or tablet. Apple devices charge over USB at 1 amp of current, so these cheap/free converters often don’t offer up more than 1 amp of current, nor do they try very hard to make that current very clean or regular. This results in a slow charge for most other devices. Although other devices (such as your Android phone or tablet) will take 1 amp, they generally prefer 2.1 amps of current or even more, depending on the device, and as a result, can charge faster. These cheap converters also have a nasty tendency to be assembled poorly, resulting in a quick converter death if it overheats (or just has pieces fall off).

As a result, we recommend that you connect your Raspberry Pi to a high-quality converter that provides 2.1 amps of current. We’ve seen good results from the Mediabridge High Output Dual USB Car Charger on the 2.1AMP port, but anything with a dedicated 2.1AMP port (and a total rating of at least 3.1 amps) should do the trick. We do not recommend that you use a 12 V converter cable designed for charging a phone (especially not a third-party provided cable), because they often have the same problems as the cheap converters do. Acceptably poor for a phone, but no good for an “always-on” Raspberry Pi. As always, your mileage may vary (YMMV), so don’t rush to post an angry but it works for me rebuttal online. Things that shouldn’t work sometimes do.

The touchscreen used in this Raspberry Pi hack comes with a power cable to connect directly to a 12 V receptacle, so you won’t need to worry about it. However, because you need a powered USB hub to prevent the Raspberry Pi from using too much power (and simply turning off or behaving erratically), you will need to get an inverter.

In this context, an inverter is a device that takes the 12 V DC power coming from the “cigarette lighter” and changes it to an AC power outlet (the amount of wattage provided varies by the unit). These inverters vary in quality (and functionality), but because you need to plug only one thing into it, 200 watts should be enough. We have successfully used a number of 300-watt inverters on the market. If you want to spend the money, you can get a pure sine-wave inverter that provides an exact replica of AC household power with two ground fault protected outlets and will likely work for years reliably and silently. This comes with a cost, though, as they run about $175. Instead, you can get a modified sine-wave inverter for $20–30. These do not work as reliably, but they should work to power a USB hub. They’re also a lot louder and hotter, usually with fans running all the time.


Storage for Your Favorite Movies

The next thing you’re going to need is a place to put your digital video files or movie files. While you could put a few of these onto the SD card running the Raspberry Pi, that space will fill up quickly (and these files are usually quite large). You’ll also need to factor in the fact that you’re installing this in a moving car. That rules out a traditional portable hard drive, because it has moving parts and is not usually very tolerant of a lot of bumps. Instead, you’re going to use a solid state drive (SSD). The technologies behind SSDs have been around since the 1950s, but since then, they’ve gotten much bigger (in capacity), much smaller (in size), and much cheaper (in cost). SSDs are basically big blocks of memory without any mechanical moving parts. This makes them very fast, but more importantly for this hack, they work perfectly through every bump and bounce of your car. You can connect an SSD to the Raspberry Pi over USB.

Purchase a drive that is designed to be external, or buy an internal SSD and put it in an external USB chassis. At this point, the majority of these USB chassis units are USB 3.0, due to the high speed (up to 5 Gbit/s at half duplex, twice that at full duplex). This is fine, but the Raspberry Pi can only communicate across its USB bus at USB 2.0 speeds (up to 480 Mbit/s), and USB 2.0 is limited to half-duplex rates. Because USB 3.0 is backward-compatible to USB 2.0, this is not a problem, but you won’t get USB 3.0 speeds out of the drive.

Whether you buy a premade external drive or use a separate chassis, you want to make sure it draws its power from the USB port, not from an external adapter. If it did that, you’d have something else you needed to plug into the inverter, and that really isn’t necessary. You should also remember that you cannot boot your Raspberry Pi from this SSD. You’ll just be mounting it as a storage partition where you will put your movies.



You could use a TV or a monitor that connects to the Pi’s video outputs (either HDMI or composite), but then you’d have to interface with the Raspberry Pi through a keyboard or a mouse, and that’s not ideal in a moving car (definitely not if you want your kids to use this setup from the backseat). Instead, this hack uses a touchscreen.

Since the Raspberry Pi can decode hardware video using output devices like HDMI or composite outputs, you’ll need a touchscreen that is connected to them (instead of just over USB). The part we found for this came from a company called Chinavasion, with the highly descriptive name of 7 Inch HD Touchscreen Car Monitor. This nifty little unit supports HDMI input at 1720×1440 (not quite 1080p, but still, not shabby), but it also has an integrated touchscreen with Linux support. It is not super cheap (about $150 at the time of this writing), but it is designed for us in a car, so it comes with a native 12 V power cable.


Powered USB Hub

You’ll need a powered USB hub. Hypothetically, you could try to get away with just plugging your touchscreen and SSD into the Raspberry Pi directly, but practically, we’re telling you not to try that. Your Raspberry Pi is far more likely to simply turn off when you try that, and you won’t be able to attach any other components, like a keyboard or mouse (for debugging the setup) or a wireless network controller (for downloading files or connecting to the Internet from a coffee shop on the road).

The brand or model doesn’t matter so much here. The most important detail is this: it needs to be externally powered. You need to be able to plug it into the wall, or in this case, into the inverter plugged into the 12 V receptacle. Many inexpensive USB hubs are not externally powered and draw their power from the USB cable that it uses to connect to your computer (in this case, the Raspberry Pi). Since you’re trying to work around the power limitations of the Raspberry Pi, this really will not work.

You will be connecting two devices to the USB hub: your touchscreen and your portable SSD, so make sure your hub has enough juice coming from its power adapter to provide .5 A to two ports.


Software for Raspberry Pi

Technically, you could use almost any Linux distribution here, but we strongly recommend using RaspBMC for this purpose. This customized version of Debian with XBMC preinstalled is ideal for the needs of this hack. XBMC is a robust and featureful suite of software that provides a GUI interface for a media center. RaspBMC has been customized specifically to support the hardware decoding and output features of the Raspberry Pi.

Connect your Raspberry Pi to your touchscreen (video to the HDMI port) and your external USB hub. Plug the touchscreen’s USB cable into the USB hub, along with a normal keyboard and mouse. You’ll need these input devices at first, because the touchscreen won’t work yet. Then insert a new SD card into your Linux laptop and install RaspBMC onto it.


What About OpenELEC?

If you want to use something other than RaspBMC, OpenELEC will probably work, but you’ll need to build a custom kernel for it that has support for touchscreens. You should now have a shiny (and Raspberry-tinted) RaspBMC session displaying on your touchscreen.


Enabling Touchscreen Support

If you touch the touchscreen now, you will probably notice that it does respond, but not properly. The mouse cursor will jump around, seemingly at random. It isn’t really random, though; it just isn’t properly calibrated yet. The good news is that it is already detected, and the proper Linux kernel drivers are loaded (RaspBMC is very clever). To calibrate the touchscreen, you will need to SSH into the RaspBMC session to enable the touchscreen. To determine the IP address of your Raspberry Pi, navigate (with the mouse) over to the System menu (it is the farthest item to the right), then to the System info tab. It will print out a page of system information details, including a field labeled “IP address.” From your Linux laptop, SSH into that IP address as the pi user. We’ll assume the IP address is in these examples, but you should of course replace it with your actual IP address:

$ ssh pi@

The default password is raspberry. Once you successfully SSH in, RaspBMC will prompt you to set your locale and keyboard settings. For Americans, it’s en_US.UTF-8 UTF-8. If you don’t know your locale setting, you can enable “All locales” at the top, but it will eat up space on the SD card.

After this finishes, you can set the time zone, and finally, it will drop you to a shell prompt, where you can get down to the business of calibrating the touchscreen.

First, go ahead and stop XBMC:

$ sudo stop xbmc

Download and install the touchscreen library and calibration script:

$ wget –no-check -O tslib_1-1_armhf.deb “https://docs.google.com/uc?export=download&id=0B4lrG9aRe-8MUlRaRW5LcXNDaDA”

$ sudo dpkg -i tslib_1-1_armhf.deb

$ wget –no-check -O ts_calib.sh “https://docs.google.com/uc?export=download&id=0B4lrG9aRe-8MOV94Nl90SExsVE0″

$ chmod +x ts_calib.sh

You’ll need to configure the ts_calib.sh calibration script before it will work properly. Specifically, you need to know the device name for the touchscreen’s event device.

The easiest way to determine this is to run ls -l /dev/input/by-id:

$ ls -l /dev/input/by-id

total 0

lrwxrwxrwx 1 root root 9 Sep 12 21:19 usb-Logitech_USB_Keyboard-event-if01 -

> ../event3

lrwxrwxrwx 1 root root 9 Sep 12 21:19 usb-Logitech_USB_Keyboard-event-kbd -

> ../event2

lrwxrwxrwx 1 root root 9 Sep 12 22:23 usb-Logitech_USB_Optical_Mouse-eventmouse

-> ../event4

lrwxrwxrwx 1 root root 9 Sep 12 22:23 usb-Logitech_USB_Optical_Mouse-mouse -

> ../mouse2

lrwxrwxrwx 1 root root 9 Sep 12 21:19 usb-eGalax_Inc._Touch-event-mouse -

> ../event1

lrwxrwxrwx 1 root root 6 Sep 12 21:19 usb-eGalax_Inc._Touch-mouse -> ../js0

The touchscreen in this example is an “eGalax Inc.” touchscreen, so the event device is event1. Edit ts_calib.sh with your favorite text editor, and change the TSLIB_TSDE VICE line to reflect the proper event device.

For the setup in this example, it should look like this:

export TSLIB_TSDEVICE=/dev/input/event1

Save it to disk, and then run it (as root):

$ sudo sh ./ts_calib.sh

xres = 1280, yres = 720

The touchscreen display should flash, then display a calibration screen with a crosshair. Carefully tap the crosshair with the included stylus (or, if you’ve already lost the stylus, the tip of a click pen with the ink tip not pushed out). It will move around the screen to all four corners, then to the center. When you finish, it will print the calibration values out to the terminal, and the calibration is done.

Now you need to use uinput-mapper to map the touchscreen input to an input device that xbmc finds friendlier. To be specific, it lets you map specific touch behaviors to various mouse click types.

Download the software and the configuration, and install it into the /scripts directory:

$ wget –no-check -O uimapper.tar.gz “https://docs.google.com/uc?export=download&id=0B4lrG9aRe-8Malg2VkM0YW1CT28″

$ wget –no-check -O uimapper.conf “https://docs.google.com/uc?export=download&id=0B4lrG9aRe-8MM2RIWFh1WjJWUW8″

$ sudo mkdir -p /scripts

$ sudo tar -xf uimapper.tar.gz -C /scripts

Edit uimapper.conf with your favorite text editor, and correct the UIMAPPER_DEV line to

reflect the event device you found earlier:

env UIMAPPER_DEV=”/dev/input/event1″

Save out the file, and move it (as root) into position inside /etc/init. This will allow uinput-mapper to start when the RaspBMC instance boots:

$ sudo mv uimapper.conf /etc/init

You need to tweak the internal uinput_mapper configuration a bit before it will work properly. Open /scripts/uinput_mapper/configs/touchscreen.py in a text editor (as root) and change this line:

sres = subprocess.check_output(“tvservice -s”, shell=True)

to look like this:

sres = subprocess.check_output(“/opt/vc/bin/tvservice -s”, shell=True)

Without that change, the uinput_mapper upstart service will fail to find the tvservice binary and silently fail. Your touchscreen should be ready.

Reboot your Raspberry Pi to test it:

$ sudo shutdown -r now

When it comes back up, try touching the screen. The cursor should move to where you touched. If you want to “touch” a click, touch and hold for a half-second and then release. It will take some getting used to. This setup should work simultaneously with any other attached input devices (such as a keyboard and mouse), so if you want to have an “override” console, you can add that easily. If you need to debug the uinput_mapper service, first stop the xbmc service:

$ sudo stop xbmc

If you do not do this, XBMC will hold the uinput_mapper device, and you won’t be able to access it with anything else for debugging. You can install the evtest utility from the Raspbian repository and use it to debug the events that the touchscreen is registering:

$ sudo apt-get install evtest

$ evtest

No device specified, trying to scan all of /dev/input/event*

Not running as root, no devices may be available.

Available devices:

/dev/input/event0: eGalax Inc. Touch

/dev/input/event1: eGalax Inc. Touch

/dev/input/event2: Logitech USB Keyboard

/dev/input/event3: Logitech USB Keyboard

/dev/input/event4: Logitech USB Optical Mouse

/dev/input/event5: uimapper – touchscreen


Select the device event number [0-5]: 5

Input driver version is 1.0.1

Input device ID: bus 0×3 vendor 0×42 product 0xbebe version 0×1

Input device name: “uimapper – touchscreen”


Supported events:

Event type 0 (EV_SYN)

Event type 1 (EV_KEY)

Event code 106 (KEY_RIGHT)

Event code 273 (BTN_RIGHT)

Event code 320 (BTN_TOOL_PEN)

Event code 330 (BTN_TOUCH)

Event type 3 (EV_ABS)

Event code 0 (ABS_X)

Value 0

Min 0

Max 2047

Event code 1 (ABS_Y)

Value 0

Min 0

Max 2047

Event type 4 (EV_MSC)

Event code 4 (MSC_SCAN)



Testing … (interrupt to exit)

When evtest prompts you to select the device, choose the uimapper device and then touch away (and hold touch and double-touch). You will see the different signals that uinput_mapper is generating as a result of your touches. If you do not see a uimapper device at this screen, it means that the uinput_mapper service is either stopped or not running properly.


Adding your Favorite Videos or Movies

If you have not already done so, put your videos on your SSD. The SSD can be formatted for any filesystem that RaspBMC understands (NTFS, FAT, ext2/3/4, etc.), and your video files can be in any directory or folder hierarchy that you want. Just be aware that XBMC will force you to navigate through those folders to play your videos, so we recommend keeping it as shallow as possible. You can also add music or pictures in this same way.


Supported Encodings

By default, the Raspberry Pi hardware supports hardware decoding of only H264/ MPEG-4 video encoding. RaspBMC will try to play files that are encoded with other video codecs, but it might have to fall back to software decoding to do so, and the performance of that will be poor.

When you plug the SSD into the USB hub, if RaspBMC is running, it will automatically detect the additional drive, and you will be able to select that source for your videos (or music/pictures). You should test it out now to make sure you can successfully playback videos. The touchscreen has small speakers that will play the HDMI audio being output by the Raspberry Pi.


Putting It All Together

Now that everything works properly, you just need to put it in your car. Plugging in the power should be straightforward: you plug the touchscreen into one 12 V receptacle, your power inverter (to household AC power plug) into another, and then plug the Raspberry Pi into a third one (or a USB port if it is available). The SSD and the touchscreen USB connectors should be plugged into the USB hub, and the USB hub should have its interconnect hooked to the Raspberry Pi. The touchscreen HDMI connector should be connected directly to the Raspberry Pi.

The touchscreen includes mounting plates, so you can mount it directly to the car seat, but if you are crafty, you can make a container that will hang over the back of the headrest of a front seat that encapsulates all of this loose hardware. It is also possible for you to hide it all away in your car by hacking it into the empty spaces (or carving out empty spaces). There is no one right way to do this, and it’s dependent on your vehicle’s design, so we leave it up to you to figure out what works best for your car.

Raspberry Pi Hacks

GD Star Rating
Be Sociable, Share!
  • more How to Build a Cheap Car Movie Player Using Raspberry Pi

 © 2012 Cool Gadgets Definitive Guide.

Cool Gadgets Definitive Guide is your latest source for cool gadgets and gizmos news and reviews. Find cool gadgets and the latest gizmos, a cool gadget blog featuring smartphones, gizmos and cool stuff for geeks. We have avid readers and feature the latest gadgets in United States of America, United Kingdom, Canada, Australia, Ireland, South Africa, New Zealand, Philippines, Singapore, India, Hong Kong, Puerto Rico, Nigeria, India, Pakistan, Russia, China, Brazil, Saudi Arabia, Japan, Malaysia, Germany, Dubai, Italy and Ghana.