How To Add MPEG 2 To Your Raspberry Pi Media Centre

Ads by Google

raspberry pi mpeg2Cueing up some videos to enjoy on my Raspberry Pi yesterday, I made a startling discovery – it wouldn’t play MPEG videos! Has this happened to you? Are you running a RaspBMC media centre on your Raspberry Pi computer, or enjoy viewing videos through the desktop? Have you noticed that certain video files cannot be played back?

If so, you’re not alone. Many people have run into trouble with the fact that while the Raspberry Pi will happily transcode high definition videos, it seemingly cannot playback MPEG-2 videos. The reason for this is not a hardware failure or even a software failure, however – rather, it is all down to licencing.

Many media players on Windows, Mac OS X and Linux distributions will allow you to enjoy MPEG-2 without any licencing issues, though – so what is going on? What makes the Raspberry Pi so different that it requires a licence to playback MPEG-2 videos, and how exactly does this license work?

MPEG-2 Licencing & The Raspberry Pi

Other operating systems include the cost of the various codecs within the price of the operating system. In the case of Linux distributions, free versions of media encoders and decoders are used instead. But hang on – the Raspberry Pi runs a Linux distribution, so why isn’t the MPEG-2 codec free?

The answer is simple. The Raspberry Pi is designed to be used for education, and while there are many who enjoy its multimedia capabilities, the developers decided to remove MPEG-2 in order to keep costs down. If you want to use MPEG-2, it is there for you to unlock for a small fee. Of course, you might not want to; after all, there are many uses for a Raspberry Pi beyond playing back videos.

Ads by Google

How To Get The MPEG-2 Licence

In order to install the MPEG-2 licence on your Raspberry Pi, you will first need to find out your device’s serial number. This can be found in the documentation that you included when you first received the computer, but if you don’t have this to hand, don’t worry, you can interrogate the motherboard.

raspberry pi mpeg2

Boot the Pi and open a command prompt in Raspbian. Enter:

cat /proc/cpuinfo

The serial number will be displayed last in the resulting text, so copy this down and visit where you will see a short form field in which to enter the serial. Do so and click Add to cart to proceed.

To purchase the MPEG-2 licence you will need to spend $3.50 (or £2.40) – not exactly a fortune, and still pennies next to the $25 price of the computer!

Installing The MPEG-2 Licence On Your Raspberry Pi

With the order made, you will need to wait up to 72 hours for your licence to be received by email (if it doesn’t arrive, you should email the Raspberry Pi people, but the process is usually reliable and efficient).

When the licence key arrives you will find it in a text file as a single line, something similar to:


raspberry pi mp3g2 license hack

In order to use this on your Pi, you will need to edit the config.txt file, which can be found in /boot. Simply add the licence as a new line of text as shown above, then save and close.

If you have multiple SD cards for different OS versions – perhaps one for Raspbian and one for RaspBMC – you will need to add the licence to each.

Reboot your Raspberry Pi to complete the procedure, and you will then be able to enjoy MPEG-2 videos.

Could I Try a Hacked Codec?

There are – apparently – hacked versions of the codec available online, but really when you consider what might be necessary (for instance, running software to spoof the device serial number) and the fact that the licence is so cheap, this really isn’t worth it.

raspberry pi mpeg2

After all, the Raspberry Pi is a low-cost piece of kit designed with lofty ambitions – to promote IT literacy. The sale of the codec raises money so that the non-profit Raspberry Pi Foundation can work towards its altruistic aims. So don’t go ripping off a codec that costs less than a bottle of beer – pay for it, and help change the world!

Ads by Google
From the Web

11 Comments - Write a Comment



wish i had raspberry pie in india prices for a raspberry unit is high so i cant afford it!

Christian Cawley

Really? That’s a big shame, hope you can find a way to get one soon.



I am waiting for minimum one GB Supporting in Raspberry pi.
So i hope it will come soon.


Jeff R

If you use RaspBMC only, like me, and lack any real coding practice, there is a field in System Settings to add an MEPG2 license code. Be aware that if you watch a ripped DVD, there will be a pause between .vob files – not a clean switch like a real DVD.


Keith Swartz

Good info. You guys keep giving us more and more on Raspberry Pi… THANK YOU! Look forward to MUCH more!


Chris Marcoe

Yup…I’ve had that happen. Couldn’t figure out why it was doing that. But, Reddit to the rescue. found out and decided I’m not using my Pi as a media center. Instead, i’ll be automating our chickens!!!


Frederick Blosser

The article didn’t really say why you couldn’t add a linux MPEG-2 codec to the
Raspberry Pi. It doesn’t seem like it would be very hard to add a free MPEG-2
codec since the Raspberry Pi can run many versions of linux. Could someone
explain why a linux MPEG-2 couldn’t be ported to the Raspberry Pi very

Christian Cawley

Well this piece is about MPEG-2 on a RPi media centre distro. Sure, there *might* be a way in which you could port.

But that would be theft.

If you’ve bought a computer for under $50 and got the OS free, are you really going to do that?

Are you going to stand in the way of the Raspberry Pi Foundation’s altruistic cause to defeat the IT skills crisis?

Why would you be that guy?

Ralf Buschner

The CPU would be a bit slow for soft decoding MPEG2. With the key, the RPi does hardware based decoding in the GPU – and since the GPU is closed source, a free codec or driver can’t access it the same way.

Frederick Blosser

Thank you for your informative answer Ralf. This is close to what I thought the answer might be.

I can’t believe the way Christian went off on me by saying “But that would be theft.” and “Are you going to stand in the way of the Raspberry Pi Foundation’s altruistic cause to defeat the IT skills crisis?”
I have no intention of doing either of these things. I am 100% supportive of the Raspberry Pi Foundation’s mission. I think that the Foundation and the Raspberry Pi are fantastic and I wish nothing but the best for them. The original question should have been more general in nature. Like, how hard would it be to port a program written for the PC, to the RPi and get it to use the hardware based decoding in the GPU, so that it would run at a decent speed. Probably very hard to do. Sorry if anyone got upset with the question.



I whole heartedly support the RPi foundation aims and ÂŁ2.40 is a small amount to ask for an official codec. BUT…. having to wait up to 72 hours for it to arrive!!!!
Am I a good boy and wait or do I get a hacked version that can be used now? a question that must be asked by anyone that knows a bit about linux. I will wait as I like to do the correct thing but I do wonder if this delay is entirely necessary when increasing the price by ÂŁ2.40 at point of purchase for those that want the licence would be a better idea

Your comment