LOGO

Add MPEG-2 and VC-1 Codec Support to Raspberry Pi

March 13, 2013
Add MPEG-2 and VC-1 Codec Support to Raspberry Pi

Enhancing Media Playback on Your Raspberry Pi

To broaden the range of media formats your Raspberry Pi can handle, manual activation of the MPEG-2 and VC-1 codecs is necessary. This process unlocks the ability to play DVDs and a wider variety of other video content directly on your Pi.

Enabling MPEG-2 and VC-1 Codecs

The Raspberry Pi doesn't come with these codecs enabled by default due to licensing restrictions. However, they can be easily activated through the Raspberry Pi Configuration tool.

Here's how to proceed:

  • Open the Raspberry Pi Configuration tool. This can typically be found in the Preferences menu.
  • Navigate to the 'Interfaces' tab.
  • Locate the options for MPEG-2 and VC-1.
  • Enable both codecs by selecting the checkboxes next to them.
  • Click 'OK' to save the changes.

Post-Activation Steps

After enabling the codecs, a system reboot is generally recommended to ensure the changes are fully applied.

Following the reboot, your Raspberry Pi will be capable of decoding MPEG-2 and VC-1 encoded video streams. This allows for smooth playback of DVDs and other media utilizing these codecs.

Enjoy expanded media compatibility on your Raspberry Pi with these simple steps!

The Necessity of Codec Licenses for Raspberry Pi

Initially conceived as an instructional tool, the Raspberry Pi prioritizes affordability. To achieve this, the Raspberry Pi Foundation has actively reduced production and licensing expenses. A key aspect of this cost reduction involved foregoing the acquisition of expensive, comprehensive licenses for the MPEG-2 and VC-1 video codecs.

This omission doesn't signify an inability to decode media formatted with these codecs. Rather, it indicates that, without a valid license, the Raspberry Pi hardware cannot legally execute these codecs by default.

However, the Raspberry Pi Foundation has facilitated the purchase of individual, reasonably priced licenses for each codec, addressing this limitation.

Determining if a License is Required

Consider whether the following scenarios apply to your Raspberry Pi usage. If so, you may benefit from acquiring one or both of these licenses:

  • You utilize your Raspberry Pi as a media hub or for general computing tasks.
  • You intend to:
  • View DVDs, either directly from a connected drive or from .ISO image files. An MPEG-2 license is necessary for decoding the video content on DVDs.
  • Play a collection of AVI files. Although AVI is a container format, many such files employ MPEG-2 encoding, thus requiring the corresponding license.
  • Access content ripped or recorded via Windows Media Center (e.g., movies or TV shows in the WMV format). The VC-1 license is needed for this purpose.

If you are uncertain about the file types you possess, there are straightforward methods to verify. Attempt to load the file within your Raspberry Pi media center.

If the video track fails to display, resulting in a black screen while the audio plays, it likely indicates an unsupported MPEG-2 encoded video.

For a more definitive assessment, employ a utility such as MediaInfo to analyze the file. MediaInfo will identify the specific video codec used in any video file you examine.

Our tutorial on using MediaInfo can provide step-by-step guidance.

Essential Requirements

This guide presumes you already possess a Raspberry Pi and have a preferred operating system installed. We will specifically utilize Raspbmc throughout this demonstration, anticipating that many users have followed our previous Raspbmc installation guide.

The instructions provided, encompassing both command-line operations and manual configuration, remain relevant regardless of the Raspberry Pi distribution you are currently employing.

Two distinct approaches will be detailed: manual license code addition and utilizing the integrated tools within Raspbmc.

Necessary Components

To proceed, ensure you have the following items readily available:

  • An MPEG-2 license (approximately $4) and/or a VC-1 license (around $2), obtainable from the official Raspberry Pi store.
  • Access to the Raspberry Pi's command prompt, either directly on the device or remotely via SSH.

Initially, we will guide you through the process of retrieving the board's serial number and acquiring the necessary licenses. Subsequently, we will demonstrate how to integrate these licenses into your Pi, either manually or through Raspbmc’s built-in functionality.

The following steps will enable you to unlock support for a wider range of video formats on your Raspberry Pi.

Acquiring the Necessary Licenses

To obtain the required licenses, you must first identify the unique serial number associated with your Raspberry Pi board. This identifier isn't physically printed on the hardware itself.

Instead, it's embedded within the device and needs to be retrieved through the command-line interface.

Retrieving the Serial Number

Access the command prompt either directly on the Raspberry Pi or remotely using an SSH client like PuTTY. If a keyboard is connected, exit the Raspbmc interface by selecting the power button in the GUI’s lower-left corner.

Press the ESC key to load the command prompt, bypassing the Raspbmc GUI boot sequence.

Alternatively, connect remotely by launching your SSH client and entering the IP address of your Raspberry Pi unit.

Upon accessing the command prompt, whether locally or via SSH, you will be asked to log in. The default credentials for Raspbmc are username 'pi' and password 'raspberry'.

Once logged in, execute the following command: cat /proc/cpuinfo

The system will display a series of lines, but focus on the final line labeled Serial. This line contains the unique 16-digit serial number for your device.

Copy this serial number carefully, as it will be required for license purchase.

Since licenses are tied to individual Raspberry Pi boards, repeat this process for each board requiring a license.

With the serial numbers collected, you can proceed to purchase the licenses directly from the Raspberry Pi Foundation.

Purchasing the License

Visit the Raspberry Pi Foundation’s dedicated purchase page for either the MPEG-2 license or the VC-1 license. Input the serial number of your Raspberry Pi into the designated field provided beneath the price.

Add the desired license to your shopping cart. Replicate this process for all licenses needed across all your devices.

While the Foundation states that license delivery via email may take up to 72 hours, our experience indicates a faster turnaround, typically around 24 hours.

The email will contain a unique code for each license, formatted as follows:

decode_MPG2=0000000000

decode_WVC1=0000000000

The '0000000000' portion represents your individual 10-digit alphanumeric license code.

Installing the Licenses

Having obtained the necessary license codes, the next step involves integrating them into your Raspberry Pi to unlock enhanced media playback capabilities.

Manual license installation: This method is applicable to all Raspberry Pi installations, including those utilizing Raspbmc.

To install the codecs manually, begin by powering off your Raspberry Pi. Subsequently, remove the SD card and mount it on a computer equipped with a text editor.

Raspberry Pi SD cards typically contain a FAT-formatted mini partition. This partition houses essential startup files, including the config.txt configuration file, which is readily editable. [Note: If a config.txt file is absent in your operating system build, simply create a new one.]

Locate the file and create a backup copy, renaming it to config.old. This safeguard ensures a restoration point should any issues arise during the editing process. Open the original config.txt file using your preferred text editor (Notepad++ is used here).

how-to-add-mpeg-2-and-vc-1-video-codec-support-to-your-raspberry-pi-5.jpg

The appearance of the configuration file may vary slightly depending on your Pi’s operating system. Ensure existing entries remain untouched. Then, copy and paste the license entries received via email into the file.

how-to-add-mpeg-2-and-vc-1-video-codec-support-to-your-raspberry-pi-6.jpg

Save the modified config.txt file and safely eject the SD card from your computer. Reinsert the SD card into the Raspberry Pi and power on the device.

how-to-add-mpeg-2-and-vc-1-video-codec-support-to-your-raspberry-pi-7.jpg

License addition through the Raspbmc tool: If you are using Raspbmc, you can bypass the manual config.txt editing process. A built-in tool within Raspbmc simplifies this task.

Navigate to Programs --> Raspbmc Settings from the main interface of your Raspbmc device. Within Raspbmc Settings, select the System Configuration Tab and scroll down to the Advanced System Settings section.

how-to-add-mpeg-2-and-vc-1-video-codec-support-to-your-raspberry-pi-8.jpg

Click on MPEG2 and VC1 to input your license number. Omit the "decode_MPG2=" and "decode_WVC1=" prefixes from the string provided by Raspberry Pi. Enter only the 10-digit string following the equal sign into the corresponding codec slot.

After entering the codec licenses, return to the main interface and reboot your device using the power selection menu in the lower left corner.

Codec testing: The most straightforward way to verify the new codecs is to play a media file that previously failed to play. Confirm that it now plays without issue.

Alternatively, for a more technical verification, open the command prompt and execute the following commands:

vcgencmd codec_enabled MPG2

vcgencmd codec_enabled WVC1

The Raspberry Pi will indicate whether the codec is enabled. Here’s an example of the MPG2 check output from a test machine:

how-to-add-mpeg-2-and-vc-1-video-codec-support-to-your-raspberry-pi-9.jpg

With the command prompt confirming proper license recognition and previously unplayable files now functioning correctly, you are now equipped to enjoy a wider range of video content encoded in MPEG-2 and VC-1 codecs.

Do you have a specific Raspberry Pi topic you’d like us to cover? Share your suggestions in the comments or email us at tips@howtogeek.com.

#Raspberry Pi#MPEG-2#VC-1#video codec#multimedia#how to