How To Add MPEG 2 To Your Raspberry Pi Media Centre
Cueing 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.
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.
Boot the Pi and open a command prompt in Raspbian. Enter:
The serial number will be displayed last in the resulting text, so copy this down and visit www.raspberrypi.com/mpeg-2-license-key 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:
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.
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!
Affiliate Disclosure: By buying the products we recommend, you help keep the site alive. Read more.