Sep 142012
 

In the last week in August (2012), the Raspberry Pi Foundation started selling MPEG2 codec licenses for the Pi. Basically without this you can’t do anything worthwhile with MPEG2 – the DVD file format. Although it’s an old codec, a lot of people have media libraries with MPEG2 files in, and some TV is still broadcast in MPEG2.

You can use this license code to unlock the hardware decode functionality (for MPEG2) of the Pi’s GPU (Graphics Processing Unit). The Pi’s GPU is 95% of the main chip. It’s a real powerhouse for its size. So it’s great to be able to unlock some of its capabilities.


(640×400 video available at end of this post)

In order to use MPEG2, you need to buy an MPEG2 codec from THE Raspberry Pi shop FOR £2.40
You will receive a code and instructions by email. Install the codec unlock code by adding it to your /boot/config.txt file

You also need to have fairly recent firmware (from around 3rd week in August, or later). You can get this with…

sudo apt-get update
sudo apt-get upgrade

Once that’s done, you need to reboot (sudo reboot) and attach your external USB DVD drive. It needs to be externally powered. The Pi won’t be able to provide enough power to run a DVD drive through the USB ports.

Once connected, type…

df -h

This will show you all the drives connected. One of them should be your DVD drive.

df -h shows all drives connected

cd /pathto/yourdrive

if your drive is mounted at /media/DVD VIDEO RECORDING, change “/pathto/yourdrive” to “/media/DVD VIDEO RECORDING” (if it has spaces in, like mine, you’ll need to enclose it in quotes).

ls -l to list the files and sub-directories in the current directory

then you want to see what’s on the DVD, so
ls -l
should show you a couple of folders. We want the one called VIDEO_TS, but it may be different for different types of DVD format.
cd VIDEO_TS

Then list the files.
ls -l

There should be a list of files ending with .VOB. Choose the one you want (VTS_01_1.VOB in my case) and type
omxplayer -o hdmi -r VTS_01_1.VOB (change VTS_01_1.VOB for your chosen filename).

omxplayer command to play a .VOB file on local hdmi screen

Then sit back and relax. When you’re done watching, press Q to quit. If it crashes on quitting (mine does sometimes), you’ll have to ssh into your pi to reboot it (sudo reboot).

You can find some other omxplayer keyboard commands here https://github.com/huceke/omxplayer#using-omxplayer

Don’t Expect 100% Reliability

It won’t work every time. Mine works better when I call it up via ssh rather than the main console. I have no idea why, but when on main console, omxplayer regularly locks up on quitting. Running it through ssh, this doesn’t happen.

It may not work well with YOUR drive. I won’t be able to help with that – sorry.

It won’t work with encrypted DVDs – like the commercial, copy-protected ones you buy. This will only work with your own recordings. There is a way to watch encrypted DVDs in linux, but I haven’t sorted it out on my Pi yet. Hopefully a future video will detail that process. I’m also planning to do a blog post about watching a DVD with OpenELEC some time soon, so watch this space. :)

  10 Responses to “Play a DVD on Raspberry Pi with Raspbian, omxplayer and the MPEG2 codec”

  1. […] week I published a blog and video of watching a DVD in Raspbian using omxplayer. At that time, as far as I could make out, nobody had managed to watch a commercial encrypted DVD, […]

  2. My player is not coming up on df -h

    • Mine is somewhat temperamental too. Sometimes an unplug and replug fixed it. But I haven’t used the DVD drive with the Pi in a while.

    • I may be able to help you out there… try this as root (sudo otherwise)

      df -vh

      this will do a verbose, human readable usage statement.

      You also might be able to do it with the generic /dev/cdrom or /dev/sr0

      Try it out!

  3. I get the following message:

    tvservice-client; Failed to connect to TV service: -1

    Now what’s wrong?

  4. I was looking at this site to see if there was a smarter way to play commercial DVD’s on a Pi. For what its worth, I have just recently managed to read a commercial DVD using the dedicated media streamer OPENelec on my Pi3 using a Liteon usb disk player. I also had a lot of trouble trying to get OPEN elec to identify the usb drive consistently. II found that if I inserted a disk into the player with the Pi switched OFF, (which is possible with an external powered usb hub) and then switched the Pi ON, the disk mounted correctly. After that I could load and unload disks and play them.

  5. How do you install OPENelec? I did a sudo apt-get install openelec and my Raspberry Pi 3 terminal said it couldn´t find openelec. What now?

  6. Can you get around the reliability problem with the main console by using ssh from the same machine (ssh to self)?

  7. Frankly, you´re talking Greek to me. I´m not much of a geek concerning computers. I did the df -h and my Liteon DVD/CD ROM is not discovered by my Raspberry Pi 3. It seems that we´re using the very same type of DVD/CD ROM drive. I´ve got it plugged into one of the USB ports but the Pi 3 does not recognise it. I´m at wits end with this thing.

  8. Maybe I can get DVDs to play on a smartphone this way? Actually it IS possible to play encrypted disks, just Pi foundation didn’t enable it because the “Big Three” aimed a sueball at them. This is why you have to buy a license, all the money goes into the war chest and further development of Raspbian/hardware.

Leave a Reply to W Rusty Lane Cancel reply