How to Setup HDMI Digital Playback in Linux

Like many people, I have an HDTV in my house that supports HDMI input devices, such as Blu-ray players. I also like to watch streaming content over the Internet, downloaded videos, and listen to music all from my TV and home theater system. Unfortunately, I do not have a Boxee box or a Roku box. All I have is a Blu-ray player that supports very few video formats and only offers a few streaming options, such as Netflix.

Fortunately, I can run Boxee from any computer, but rather than buying a dedicated box just for that, I can use my Eee PC, which has HDMI output. Many laptop manufacturers are adding HDMI out connectors to their devices specifically for this purpose, so that customers can display their content on big screen televisions.

If you happen to be one of those people and have chosen Linux for your laptop or computer with HDMI out, this brief tutorial should help you get video and sound working.

Initial Preparation

Generally speaking, if your computer or laptop has an HDMI connector, it will play fullscreen HD videos. All you need to do is configure Linux to use it. From my experience, current versions of most Linux distributions will treat an HDMI output just like a VGA out, needing very little configuration. It should auto-detect your external screen, even if it does not immediately display anything. You can use a tool like XRandR, Disper, or nvidia-settings to easily setup the resolution settings you want.

For example, your XRandR or Disper string may look like this:

xrandr --output HDMI-0 --mode 1280x720 --right-of DVI-0

or

disper -S -r 1280x720

Audio Setup

HDMI video was the easy part. Unfortunately, various Linux audio systems view an HDMI audio output in different ways. If you are using Ubuntu or another distribution that uses Pulseaudio, you should use the Pulseaudio Volume Control program. To use it:

1. Press Alt+F2, type “pavucontrol”, and press Enter

2. Once the control window opens, click on the “Configuration” tab

Pulseaudio Volume Control

By default, the Profile will be something like “Analog Stereo Duplex”. “Analog” refers to your device’s normal speakers.

3. Click the drop-down menu

4. Select “Digital Stereo (HDMI) Output” from the list.

Now all audio will be routed through the TV’s speakers.

In KDE, any players that use Phonon, such as Dragon Player or Amarok, use KDE’s configuration settings, and you can select the HDMI output from there as well. To do this:

1. Open System Settings

2. Click on “Multimedia”

3. Click the “Phonon” side tab

4. For Music, Video, and any other output you want, select “Internal Audio Digital Stereo (HDMI)” and click the “Prefer” button until HDMI is at the top.

KDE Multimedia settings

No Pulseaudio or Phonon

If you only need to turn on HDMI audio for a particular application, such as XBMC, simply configure the individual application to use the HDMI output.

XBMC digital audio configuration for HDMI

For other applications that do not have built-in digital playback support, you will need to configure Alsa manually. Boxee, for example, should work just like XBMC, but there appears to be a bug that prevents digital output. The first thing you need to do is find out which device number your HDMI out is using. From a terminal, type:

aplay -L

Look for devices with “hw” in front, and one of them should include HDMI that looks similar to this:

hw:CARD=NVidia,DEV=3
HDA NVidia, NVIDIA HDMI

As you can see in this example, my audio card is “NVidia”, and the device number is “3”. Assuming you only have one card, the card number will be 0.

Next, create a text file in your home directory called “asoundrc-hdmi”, and include the following (replacing “hw:0,3″ with your actual device number):

pcm.dmixer {
type dmix
ipc_key 1024
ipc_key_add_uid false
ipc_perm 0660
slave{
pcm "hw:0,3"
rate 48000
channels 2
period_time 0
period_size 1024
buffer_time 0
buffer_size 4096
}
}
 
pcm. !default {
type plug
slave.pcm "dmixer"
}

Save the file. If you already have a default .asoundrc file, you should back it up and copy the asoundrc-hdmi to .asoundrc

mv .asoundrc asoundrc-backup
cp asoundrc-hdmi .asoundrc

If you want to switch to this setting every time your media program starts, you could create a script:

#!/bin/bash
mv /home/user/asoundrc-hdmi /home/user/.asoundrc
sleep 3
/opt/boxee/Boxee&
wait
mv /home/user/.asoundrc /home/user/asoundrc-hdmi

HD Playback

If you have a low-powered device (i.e. Atom Dual Core 330 processor and Nvidia ION graphics) that is advertised as supporting HD playback but does not seem to play HD videos well, you may need to configure VDPAU support. Using your package manager, install the “libvdpau1″package. Then, in your video player, select vdpau output rather than “xv”. This should give you hardware accelerated HD video support. In Boxee, go to “Settings -> Media -> Advanced” and check “Enable hardware assisted decoding when possible”. The default “Render method” should be VDPAU.

Boxee accelerated video with VDPAU

For Adobe Flash, you can download the new Flash player 10.2 Beta which supports hardware accelerated playback. Now all of your HDMI video and audio should run smoothly, and you did not have to purchase a media center box to get it.