Archive for the ‘Home Cinema’ Category

I hope I’m not jumping the gun here, but I have finally found the cause of the severe frame dropping I’ve been experiencing when playing MKVs (specifically 1080p content) on my (not so) new HTPC.

I spent some time investigating yesterday, trying out different codecs. Once I found out about a very useful overlay display in Media Portal. Pressing Shift-1 (ie – !) brings up a raft of information including the name of the audio and video decoders. So, I could really see what Media Portal was using the play the MKV file. It also has a very useful dropped frame count. So, I didn’t have to sit and watch for dropped frames myself.

The first thing I tried was updating the codec package I use (SAF) to the latest version (6.1). This seemed to work for a while, but I still got dropped frames and once it started going wrong it got progressively worse.

Next, I tried out different video decoders (Cyberlink PowerDVD 11, Microsoft DTV, ffdshow DXVA, LAV). All of them stuttered severely.

Next, I tried copying my test file to the local hard drive. Playback was perfect! I then tried playing back the same file (from my Drobo FS) on a different HTPC, playback was perfect! So, this lead me to believe something was wrong with the networking part of the new HTPC.

So, I went on to the gigabyte website and downloaded the latest version of the network adapter driver. After a reboot I played my test MKV file from the Drobo FS, ie – using the network again, and it played back perfectly. RESULT! To make sure I let it play a lot longer than my normal test, still perfect. I then played a couple of more movies and they also played back perfectly. GREAT I thought.

One problem HTPCs often have is that when resuming from sleep mode they don’t quite work perfectly. So, I switched the PC off via my MCE remote and made myself a cup of tea. A few minutes later I switched the PC back on (again via the MCE remote), played the same test movie again and it was perfect! So, I tried a few more movies and left one of them running for over an hour. Again, as near as makes any difference, PERFECTO.

I’m not counting my chickens just yet, I’ve had this happen before. So, I switched it off (via the MCE remote) again, and went to bed.

The next morning …

I switch the PC on with the remote, fire up the test movie … PERFECT! It’s actually still playing as I write this post.

So, all this hassle and many nights of messing around with codecs and power settings and I don’t know what else; And it’s all down to a dodgy network driver, the one on the CD that came with the motherboard no less!

GIGABYTE FAIL

The PC seems to wake up quicker too. What normally happens on a wake up, is the display comes on real quick but there is a delay while it sorts itself out and reconnects to the TV server. I’m not too bothered about that delay actually, but it would be nice not to have it :)

Note: When I say PERFECT, it is still dropping the odd frame. It’s only one in every 6 or 7 thousand frames and barely noticeable. I suspect that is down the the frame rate not being exactly right for 24p content. This is apparently a known issue with the Sandy Bridge CPU/GPUs.

I have been “in the process” of building a dedicated home cinema room for some time now. I shall write about that in more detail some other time.

This post is a “progress” update which will make more sense in the fullness of time, after I have written about my progress up to now in more detail.

I have been having difficulty getting my HTPC to stream movies from my server reliably for quite a while now. Somewhere in the order of 4 months! This Friday just gone I decided to take adanage of my 2 year old son’s extra long sleep during the day and do a little experimentation with my network setup.

I use a gigabit wired ethernet network with a 24 port switch and wall plates wherever I can. I suspected the stuttering problems I was having was down to the network somehow. So I tried a few things to eliminate a few possibilities. As it turned out, when I moved my Drobo to a location other than my newly created cloakroom/server room it worked perfectly. Well the few tests I performed worked where they didn’t before. So, it would seem there is some kind of problem with either the network cabling I had pulled through to that room, or the sockets I’d installed in that room.

That was yesterday, today I came to watch a few things in the cinema room and I got stuttering. To a lesser extent than befofe, but still quite bad and certainly not watchable. So, I loaded up Graph Studio to see which decoders/filters/splitters were being used to play back my test movie. As it turned out the audio decoder being used was the MPC MPA Decoder, which I hadn’t set the SPDIF passthru on. So, I did that and it was instantly better, in fact it seemed pretty much perfect to me!

So, I decided to also switch the Media Portal settings back to the defaults for the SAF 6 package I’ve been using. The reason for doing that is that Graph Studio was telling me it was using decoders other than the ones I have configured in the Media Portal configuration, so I figured “what the hell!”

It, still seems fine to me. I’ll continue to perform “extensive testing” (ie – watching plenty of movies)

Hooray! I have tonight, finally got DTS MKVs working reliably in MediaPortal. It was actually a very simple solution in the end. I did a little experimentation around using the SPDIF output in my existing audio filter. I found that if I told it to decode to 5.1 it worked fine. So it was a problem with the audio filter passing audio straight onto the SPDIF output. Since, I’d used AC3Filter in the past I simply installed that, set it up for my amp (just checking which rates my amp would support via the SPDIF check utility provided with AC3Filter), and I was away. So, I now have glorious DTS sound again, the only difference from the last time I used AC3Filter on my previous Media Centre PC is that this one can play back 1080p video files easily.

Update (3rd August 2010)
Actually they don’t work! I thought they did, but only a few select ones did. Oddly my other media PC works perfectly. So, I’ve swapped them around and the fully working one is now in the lounge. It plays everything back without any problems at all. The plan is to clone that hard drive in order to get the other PC to a known working state.

Update (4th January 2011)
I have it all working now, but only because I had an enforced upgrade of my TV Server (due to a power outage/spike which partially fried some gear). So, with MediaPortal 1.1.2 and Stand Alone Filters v4 (with hardware acceleration enabled). I have 1080p DTS MKVs playing back just fine.

I recently got myself (as a present) a nice new Denon AVR 1910 AV Receiver, which has HDMI video switching. So I duly plugged my HTPC into one of the HDMI inputs and hooked my HDTV up to the HDMI monitor out. All was well, everything worked as it did before. That is after I’d spent a few hours setting the amp up.

Whilst fiddling around with my new toy, I switched the amp to a different HDMI video input and then back to the HTPC input. Whoa, what’s this black border around the whole picture?! I have a Toshiba 42WLT66 which is a 1080i panel, that means it’s got a native resolution of 1920×1080 (albeit only capable of interlaced video). So, I’ve got my PC configured to 1920×1080 @ 25Hz. But when I checked the video settings, it had defaulted back to 30 Hz, hence the black border.

I found that if I switched the amp on first and let it go through the startup routine, then switch the TV on and then the HTPC all was well. Anything other than that order and the HTPC defaulted to 30Hz, which was useless for my purposes. So, I’ve since spent a lot of time researching different ways of fixing the problem on the web. I even installed the latest ATI Catalyst drivers and Catalyst Control Centre, but that just made matter worse. The black border was present on all three refresh rate that my HDTV supports (25, 29 and 30Hz). System Restore came to my rescue.

So, I decided to write a little piece of software to reset the refresh rate. That, when combined with the MyPrograms plugin for MediaPortal, gives me a way of setting the HTPC back to 25Hz refresh rate via my remote control

So, here is how I did it…

Firstly I needed to use a few functions in user32.dll, so I created the following class…

class User32
{
    [DllImport("user32.dll")]
    public static extern int EnumDisplaySettings(string deviceName, int modeNum, ref DEVMODE devMode);

    [DllImport("user32.dll")]
    public static extern int ChangeDisplaySettings(ref DEVMODE devMode, int flags);

    public const int ENUM_CURRENT_SETTINGS = -1;
}

The User32 class needs the DEVMODE struct …

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
public struct DEVMODE
{
    [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)]
    public string dmDeviceName;

    public short dmSpecVersion;
    public short dmDriverVersion;
    public short dmSize;
    public short dmDriverExtra;
    public int dmFields;
    public int dmPositionX;
    public int dmPositionY;
    public int dmDisplayOrientation;
    public int dmDisplayFixedOutput;
    public short dmColor;
    public short dmDuplex;
    public short dmYResolution;
    public short dmTTOption;
    public short dmCollate;

    [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)]
    public string dmFormName;

    public short dmLogPixels;
    public short dmBitsPerPel;
    public int dmPelsWidth;
    public int dmPelsHeight;
    public int dmDisplayFlags;
    public int dmDisplayFrequency;
    public int dmICMMethod;
    public int dmICMIntent;
    public int dmMediaType;
    public int dmDitherType;
    public int dmReserved1;
    public int dmReserved2;
    public int dmPanningWidth;
    public int dmPanningHeight;

    public static DEVMODE Create()
    {
        DEVMODE dm = new DEVMODE();
        dm.dmDeviceName = new string(new char[32]);
        dm.dmFormName = new string(new char[32]);
        dm.dmSize = (short) Marshal.SizeOf(dm);
        return dm;
    }
}

Since all I wanted to do was to reset the refresh rate, I just created a console application …

static class Program
{
    [STAThread]
    static void Main(string[] args)
    {
        int refreshRate;

        if (args.Length == 0 || !int.TryParse(args[0], out refreshRate))
        {
            refreshRate = 25;
        }

        bool silent = args.Length > 1 && args[1].ToLower() == "silent";

        string deviceName = Screen.PrimaryScreen.DeviceName;
        if (!silent)
        {
            Console.WriteLine("Device Name = " + deviceName);
            Console.WriteLine("Press [Enter] to proceed, or any other key to abort");
        }
        if (silent || Console.ReadKey().Key == ConsoleKey.Enter)
        {
            DEVMODE dm = DEVMODE.Create();
            User32.EnumDisplaySettings(Screen.PrimaryScreen.DeviceName, User32.ENUM_CURRENT_SETTINGS, ref dm);

            if (!silent)
            {
                Console.WriteLine(string.Format("Press [Enter] to set refresh rate to {0}Hz, any other key to abort", refreshRate));
            }

            if (silent || Console.ReadKey().Key == ConsoleKey.Enter)
            {
                dm.dmDisplayFrequency = refreshRate;
                User32.ChangeDisplaySettings(ref dm, 0);
            }
        }
    }
}

The primary screen name is fetched …

string deviceName = Screen.PrimaryScreen.DeviceName;

The User32.EnumDisplaySettings is called in order to fill in the DEVMODE struct, as all I wanted to do was to change the refresh rate …

DEVMODE dm = DEVMODE.Create();
User32.EnumDisplaySettings(Screen.PrimaryScreen.DeviceName, User32.ENUM_CURRENT_SETTINGS, ref dm);

Next, I set the refresh rate to what I want and call User32.ChangeDisplaySettings …

dm.dmDisplayFrequency = refreshRate;
User32.ChangeDisplaySettings(ref dm, 0);

It works a treat in combination with the MyPrograms plugin for MediaPortal, with the command line of “25 silent”.