Tag Archives: MPC-HC

5.1 channel audio through ordinary headphones using MPC-HC

Blown-Away Man

Though I have owned a surround sound system before, I don’t currently have the space for one. I was recently considering buying gaming headphones with support for Dolby Digital 5.1 channel audio which I could also use for watching films. With some more reading I discovered that these hardware solutions will only work with a Dolby Digital source (AC-3). The problem is that I have a lot of content with DTS audio which the chips in these products don’t support, not to mention MP4 files with multichannel AAC audio.

Reading the specs of these headphones, I discovered that they license a technology called Dolby Headphone – some clever signal processing developed by Lake DSP in Sydney. Early 5.1 channel headphones actually contained multiple tweeters mounted at different positions inside each ‘can’ which apparently weren’t very convincing, but this better approach is more of an emulation – one that relies on the fact that you only have two ears. It’s able to model the audio delays and reflections of a room containing a 5.1 setup, plus it seems to boost up the low frequencies so you’re really aware of the LFE channel. I don’t really understand why there isn’t much awareness of Dolby Headphone. It’s not at all new – look at this 1998 press release!

What’s also not very widely known is that Dolby Headphone can be encoded in software, through the likes of PowerDVD’s audio decoder, regardless of whether your sound chip is Dolby Headphone certified (as some now are). It’s also not particularly processor intensive – my Sony Vaio P can play H.264 movies and process DH with its Intel GMA 500 GPU and meagre 1.33GHz Intel Atom Z520 CPU.

 

What does Dolby Headphone sound like?

Listen for yourself – plug in some headphones and try these DH encoded samples. The choice of movie trailer isn’t exactly showcasing the 360 degree soundstage, but it was quite tricky to encode so I didn’t want the hassle of sampling a scene from an actual film. I can assure you that the action sequences in District 9 for instance sound a whole lot better with Dolby Headphone enabled.


These samples are 192Kbps MP3 files for size reasons. The slight metallic high-end ringing to the deep bass is an encoder artifact from the conversion to MP3 using the LAME encoder, and it was still present when I tried 320Kbps. The channel test clip was taken from http://www.lynnemusic.com/surround.html and the I Am Legend trailer was from http://www.h264info.com/clips.html.

 

How to get it working for AC-3, AAC, and DTS multichannel sources

In a previous post I explained how to setup Media Player Classic Home Cinema to use a third party h.264 decoder with DXVA support. MPC-HC has several key advantages as a media player – it’s open source, it’s lean, it’s extremely configurable, and it plays pretty much any format. I use it for my Sony Vaio P to keep CPU use as low as possible on its rather limited Intel Atom processor. Many people use MPC-HC for their Home Theatre PCs, hence this article.

A guide for configuring Dolby Headphone using PowerDVD’s CyberLink Audio Decoder already exists (with files):
http://www.head-fi.org/forum/thread/405417/guide-dolby-headphone-in-mpc-zoom-player

However that information isn’t sufficient. The complication is that when this decoder is used outside the PowerDVD software, it only works with DTS audio streams even though it should also support AC-3. Reading around, it seems that the AC-3 support works in Windows XP but not in Vista nor in Windows 7.

The next piece of the puzzle can be found here on the forum for Zoom Player, a commercial media player:
http://forum.inmatrix.com/index.php?showtopic=7224

The important point is that the CyberLink decoder can accept a multichannel LPCM input, so you can use another decoder (ffdshow tryouts in this case) to convert the source bitstream into LPCM first, then feed that to the CyberLink decoder. This means that multichannel AAC audio found in MP4 containers could have Dolby Headphone applied too. The above post describes how to do this for Zoom Player, but we’re interested in MPC-HC. The next obstacle is figuring out how to link multiple decoders together in MPC-HC – something I couldn’t find any info about despite spending hours searching online.

The key to understanding this is knowing how the modular Windows DirectShow media layer works. If you’ve already played with MPC-HC you will be familiar with adding and removing filters, as well as the concepts of ones that are built into MPC-HC and those that are external. All these DirectShow filters have ‘pins’ which are their inputs and outputs – their connection points in other words. Each pin has a defined list of media types it will and won’t accept. As long as you comply with this, they can be threaded together to create a ‘graph’. The simplest way to illustrate this is with a screenshot of the aptly named GraphStudio, and this example shows the combination of filters I used to make one of the sample audio clips earlier in this post:

So how can we construct a similar sequence in MPC-HC? In the end I finally found the crucial bit of information in a single sentence of the excellent self-explanatory and unofficial All the things you may want to know about Media Player Classic – HomeCinema:

When a video file is loaded in MPC-HC, MPC-HC will run through this list from top to bottom and load the relevant filter(s), create a graph from them and play the file.

Bingo! All you need to do is explicitly list them in the right order in MPC-HC’s External Filters window and MPC-HC should thread them together, compatible pins permitting. Sure enough, it works.

Would you believe it, there is yet another hitch – the CyberLink Audio Decoder expects LPCM input channels to be in a certain order, one that differs from the default order in ffdshow. This is trivial to fix, though it will mess things up if you rely on ffdshow to decode other media formats.

 

The guide

You’ll need MPC-HC obviously, the CyberLink Audio Decoder will need to be installed (from PowerDVD), and you’ll need ffdshow tryouts installed (I used the SVN release, since the beta is years old).

Once ffdshow is installed, open up its Audio Decoder configuration utility from the Start Menu. In the Output section select 16bit LPCM and apply.

Disable the Mixer and configure the Swap Channels menu as follows. Note the different order:

Open MPC-HC and hit O to bring up the options menu. In the Internal Filters section de-select AAC, AC3 and DTS from Transform Filters on the right.

UPDATE – Contrary to what I had originally written here, do not disable the built-in audio switcher! I hadn’t understood that this is needed for when you have a video file with multiple audio tracks. If it’s not enabled then all audio tracks play simultaneously. You could consider disabling Regain volume if you want to minimize the amount of additional processing.

Audio switcher settings

In the External Filters section make sure that ffdshow is set to prefer, and is listed above CyberLink Audio Decoder (also set to prefer). Use Add Filter… to set Microsoft DTV-DVD Audio Decoder to Block.

Remember that DTS audio bitstreams don’t require the ffdshow treatment. To avoid having to reconfigure this for different movie formats we can customize the recognized media types for the ffdshow filter. As per the screenshot above, select ffdshow Audio Decoder then scroll down until you find MEDIASUBTYPE_DTS and delete it. DTS files will now skip ffdshow and will be entirely handled by CyberLink Audio Decoder. If you ever need to revert this change click Reset List.

Open a movie file in MPC-HC, then select Play -> Filters -> CyberLink Audio Decoder and you will be able to select Dolby Headphone like so:

On the next tab you can choose between three DH modes. I found a nice succinct guide to the three modes here:
http://www.head-fi.org/forum/thread/444681/headphones-with-good-sound-stage-better-with-dolby-headphone-or-no-need-for-it#post_6003214

Sadly it seems that every time you load a new file into MPC-HC you need to re-enable Dolby Headphone (the setting doesn’t stick for some reason). Also, owing to the channel order swapping in ffdshow you’ll find that in ordinary stereo mode you’re only getting the Front Left and Front Center channels. As a result you’ll probably want to de-select the Swap Channels setting in the ffdshow Audio decoder tool when you’re not using headphones. A small price to pay though… Enjoy!

 

Further reading

There is a guide to using Dolby Headphone for listening to two channel music in the audio player foobar2000 here:
http://www.head-fi.org/forum/thread/447089/5-1-headphone-experience-foobar-configuration-for-all-stereo-music-files

I’ve given it a try and I don’t really think it’s worth it. When I had a actual surround system I used to play all my music on Dolby Pro Logic IIx and it sounded very good using all the speakers. It meant you could be sitting anywhere in the room and still get nice separation and so on. However, creating those additional channels only to merge them back down to two channels often doesn’t seem to add much since they were virtual to start with. In side by side listening comparisons I often preferred the original stereo mix, but admittedly it does seem to vary with the way they’ve been mastered (remember, to hear the original stereo you have to remove all selected DSPs, not just DH).

DXVA H.264 playback on Intel GMA 500 with subtitles (Windows 7)

Update – This guide was updated on 04/04/2012

Out of the box, Windows 7’s Windows Media Player (WMP) will play HD video using the Intel GMA 500 and DirectX Video Acceleration (DXVA) to do the decode. Using the Matroska Splitter you will also be able to play MKV files. However, they may occasionally stutter and use a fair amount your humble Atom Z series CPU’s power (around 40-50% of 1.33GHz), and you won’t be able to use subtitles.

The PowerDVD H.264 decoder on the other hand will use about 10-20% less CPU, is less prone to locking up, and by using Media Player Classic Home Cinema (MPC-HC) you gain subtitle rendering support. Apparently PowerDVD does itself support MKVs with subtitles but on the several occasions I have attempted this with the trial version it has locked up and crashed. If you don’t have the PowerDVD decoder, you can use the ‘ffdshow tryouts’ open source decoder which is a very good alternative, but seems to suffer some screen tearing during high motion scenes while subtitles are enabled.

Ingredients

  • Media Player Classic Home Cinema (MPC-HC 1.60.4014 at the time of updating this document) – don’t confuse with Media Player Classic, this is a separate version
  • Matroska Splitter (optional) – this reads the MKV container format. MPC-HC has its own implementation included but you could use this if you want to play MKV files in Windows Media Player
  • Optional DirectVobSub subtitle renderer for Windows Media Player (will not work for MKVs), useful for Xvid/DivX files though
  • PowerDVD’s H.264 decoder CyberLink Combo MPEG-2/H.264/VC1 Decoder v.1.0.4960.3320
  • or ffdshow tryouts decoder – don’t use the beta release, it doesn’t have the DXVA decoder. I tested with the SVN build.
  • DirectX End-User Runtimes (June 2010) – required for the EVR Custom Presenter renderer which is needed for subtitle compositing

Method

Firstly disable Aero.

If you want to have subtitles in WMP for Xvid/DivX movies then download and register vsfilter.dll. To do this, copy the DLL to C:\Windows\System32 and open a Command Prompt using right-click & “Run as Administrator”. Then type
regsvr32 c:\windows\system32\vsfilter.dll

If later on you want to remove this, just open the Command Prompt as Administrator and type
regsvr32 /u c:\windows\system32\vsfilter.dll

When it’s registered you can open an Xvid AVI file in WMP and, as long as there’s an SRT subtitle file with the same filename as the AVI then you will see your subtitles. There will be a new icon in the system tray which will allow you to toggle subs, as well as choose the language if there are several sets of subs.

Now install Haali Splitter if you want MKV support in WMP and other players. When you load a MKV, it behaves in a similar way to VSFilter (icon in systray), except it’s even more versatile since MKV containers can have different soundtracks too.

Next, install MPC-HC.

Now use WinRAR to extract the DirectX End-User Runtime file you downloaded. In WinRAR, select File > Open, then change the filename dropdown from All archives to All archives including self-extracting. Browse to your downloaded directx_Jun2010_redist.exe and open it. Inside you will find some more archives. Drag and drop to extract the file Jun2010_d3dx9_43_x86.cab, then open this in WinRAR too. Extract the file d3dx9_43.dll into the folder C:\Program Files\Media Player Classic – Home Cinema.

Finally, install the Cyberlink H.264 decoder or ffdshow. During setup ffdshow will offer a choice of decoders to use, pick libavcodec (not ffmpeg-mt).

Now we need to configure MPC-HC. Load it then go to View -> Options.
Go to Playback, and make sure Auto-load subtitles is set (assuming you want them). Note that you can also set language code preference orders for audio and subs:

Auto load subtitles

Move to the section called Output. If you will never use subtitles select EVR and don’t touch anything else.
If you do want subtitle support, use EVR Custom Presenter, reduce the EVR buffers from 5 to 4, and check the Alternative Vsync and D3D Fullscreen boxes. With the default settings the additional load of compositing subtitles brings the framerate down below 24fps, however by using these last two options we can just maintain 24fps.

Output settings

Now select the heading Internal filters and uncheck both H.264 options on the right. This stops MPC-HC using its own support for those features, since we’re going to use external modules for those. If you’re using the CyberLink Video Decoder version I posted above you can optionally uncheck the MP4/MOV and MKV source filters which will cause the CyberLink ones to be used instead (it doesn’t seem to improve performance).

Internal filters

Under the heading External Filters click Add. Then browse to the CyberLink Video Decoder and add it. Make sure to set it to Prefer on the right as shown. If you’re using ffdshow then instead add ffmpeg DXVA video decoder an set to Prefer.
If you installed the Vsfilter.dll subtitle driver (some other media players/codec packs will register this) we need to add DirectVobSub (auto-loading version) too, but select Block on the right. This prevents it from loading, since we’re using MPC-HC’s subtitle renderer. Apparently the way DirectVobSub renders is fundamentally incompatible with DXVA:

External filters

Close MPC-HC for the settings to take effect. At this point it’s a good idea to associate .mkv files with MPC-HC. If videos are launched by double clicking like this, when you pin MPC-HC to your Start Menu it will have that child menu showing you the last ten or so files you launched which is very useful.

Start an H.264 encoded MKV in MPC-HC and as it starts to play, right-click on the video window and select Filters -> CyberLink Video Decoder. Check that DXVA is selected. I believe that HAM mode uses OpenCL on GPUs that support it (the GMA 500 doesn’t) which if I remember was recommended for ATI GPUs, the early ones having glitchy DXVA implementations apparently. If you’re using EVR Custom Presenter you wont be able to do this with D3D Fullscreen enabled, so toggle it and reload MPC-HC to verify this step.

CyberLink decoder filter settings

Close and reopen MPC-HC and you should be done! Though using D3D Fullscreen reduces tearing and seems to keep the framerate higher when using the EVR Custom Presenter renderer you cannot right-click and see the normal MPC-HC GUI elements. You have to use Ctrl-C to exit playback to modify settings. Two essential keyboard shortcuts are A to switch audio track, and S to switch subtitle track, though shortcut keys do exist for just about everything, and can be customised in the Player > Keys menu in Options.

If using ffdshow you also need to enable hardware acceleration by running Start Menu > All Programs > ffdshow > DXVA video decoder configuration:

DXVA decoder settings

ffdshow’s built-in subtitle rendering seems to produce smeary artifacts on the picture so ignore those options and use MPC-HC’s subtitles instead.

If you have a video that won’t playback nicely with this setup then it’s likely that the bitrate is too high for the GMA 500 to cope with (a straight 1:1 rip from Blu-ray for instance) or perhaps the file has not been encoded to be fully DXVA compliant (quite likely with older stuff). Framerates over 24fps cannot really be played unfortunately.
There are some H.264 movie trailers available here for testing.
In my experience the GMA 500 in my VAIO P will play most 1080p content perfectly well, even outputting to a TV at 1920 x 1080. If in doubt about whether it’s dropping frames, while using EVR Custom Presenter you can press CTRL-J several times to view the frame rate (get rid of the graph and verbose text – they slow it down even more!).

Further reading

This handy guide explains in detail what all the options in MPC-HC mean.

Continue to DXVA VC-1 playback on Intel GMA 500 or learn how to get a surround sound experience from ordinary headphones.