How To Add MPEG 2 To Your Raspberry Pi Media Centre

Christian Cawley 04-04-2013

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 How To Make Your Raspberry Pi Into a Home Theater System Four weeks on and I’ve been playing with my Raspberry Pi in various ways, from using it to browse the web and standard day-to-day computing tasks to playing around with the various configurations that are... Read More 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 The Top 5 Amazing Uses For Your Raspberry Pi Computer I’ve recently received my Raspberry Pi after a long wait – and I’ve got quite a few plans for it. The problem is, I’m not totally sure which project I want to attempt first. While... Read More 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.


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 Optimize The Power Of Your Raspberry Pi With Raspbian As befits a man with too much tech on his hands, I’ve been playing with my Raspberry Pi recently, configuring the device so that it works to its fullest potential. It continues to run as... Read More 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!

Related topics: Media Player, Raspberry Pi.

Affiliate Disclosure: By buying the products we recommend, you help keep the site alive. Read more.

Whatsapp Pinterest

Leave a Reply

Your email address will not be published. Required fields are marked *

  1. S pal
    June 21, 2018 at 4:37 am

    i want make my raspberry pi3 disabled kb & mouse only operated by lirc so i want to display images which would kept in encrypted and at the booting that will make a temporary file, from that file the images will display. i don't know how it could be done.
    So i need help.

  2. Damjan
    March 17, 2018 at 8:56 am

    The pi store is not working, I am unable to buy a license, does anybody know an alternative place to obtain (buy) the license key for MPEG?

  3. Kikinaak
    May 20, 2017 at 10:38 pm

    The mission of the pi is great, but this decision I strongly disagree with on principle. The thing is aimed at students and hobbyists, why set it up so you have to pay an extra fee to enable an onboard hardware function? That isnt how open source is supposed to work, in spirit or in practice.

    On the other claw, for those using this as a learning platform, heres a purely conceptual exercise. Simple scripting can do some wonderful things. Things like checking the output of a command against a known phrase, and do other things if they dont match. Things like incrementing a value and writing it to an ini file, then rebooting. Once properly set up, the pi could do these amazing things while you are off doing other things, like sleeping. It could even use the LEDs that come with many of the kits to let you know when the values do match. Aint automation great?

  4. robert
    August 4, 2013 at 1:17 pm

    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

    • Kjeld Flarup
      February 4, 2017 at 7:54 pm

      I had mine within three hours.

  5. Frederick Blosser
    May 22, 2013 at 5:38 am

    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
      May 22, 2013 at 7:38 am

      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?

      • Jane D'Armond
        March 19, 2016 at 11:44 pm

        Potentially this is true, in the small number of jurisdictions where software patents are enforceable. The EU for example, is not one of those places. As such - using an open source clean room re-implementation of that technology would not be theft under any definition of the word for an individual residing in the EU or other jurisdiction which denies software patents.

        Ralf's answer is more accurate; and the charge is reasonable for this purpose as Broadcom would be liable for MPEG licensing due to it's international nature.

        However as of the Pi 3 (and plausibly, the Pi 2) this is no longer directly necessary as the CPU should be able to handle running libav or ffmpeg at viable speeds for SD content - MPEG2 is not used above these resolutions anyway.

        The hardware decoding will still be more efficient, and users in the US and similar jurisdictions should still be purchasing licences regardless; but I thought it was worth clarifying, as this page is still a top search result on Google.

    • Ralf Buschner
      May 22, 2013 at 4:59 pm

      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
        May 23, 2013 at 6:16 am

        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.

  6. Chris Marcoe
    April 6, 2013 at 5:04 am

    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!!!

  7. Keith Swartz
    April 6, 2013 at 1:30 am

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

  8. Jeff R
    April 5, 2013 at 6:55 pm

    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.

  9. Vinod
    April 5, 2013 at 10:29 am

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

  10. vineedcool
    April 5, 2013 at 7:56 am

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

    • Christian Cawley
      April 5, 2013 at 8:41 am

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