Workaround for Media Center Black Screen of Death

I’ve come up with somewhat of a workaround for the Media Center Black Screen of Death as discussed here:

http://thegreenbutton.com/forums/t/84740.aspx

My current solution, until either Microsoft or ATI comes up with a fix, is to attach a “task” to one of the events that the ATI drivers log in the system event log. All the task does kill the Media Center process when the ATI driver logs that the video device is no longer connected. Since Media Center is no longer running when the television is turned on, the Black Screen of Death doesn’t appear.

First download this zip package, which contains two files:

MediaCenterBlackScreenOfDeathWorkaround.zip (1.52 kb) 

And extract the files to some temporary location.

Next you need to make sure your ATI driver is properly logging events. I’ve only tested this with the driver that ships on the Windows 7 DVD, which is version 8.632.1.2000 and this version seems to have event logging enabled by default. If you’re using a different version, double click on the “EnableATILogging.reg” file that you extracted to import the registry entries into your system’s registry.

At this point you might want to test to make sure the ATI driver is properly logging events so go ahead and reboot, run Media Center, play a video and then turn off your television while the video is playing. Wait 10 seconds or so, turn the TV on, close out Media Center using your favorite method of keyboard or mouse hackery and then load up the Windows Event Viewer by hitting the Start button and typing “event viewer” into the search area. Click on the arrow next to Windows Logs to expand the Windows Logs branch and finally click on System.

The event Source you are looking for is “atikmdag” and the Event ID is “43029”. There should be four of them near the top of the log but if you’re having trouble finding one, in the right column is an Action called “Find…”. Click on that and type in “display is not active”. If no events were found, something is wrong. Either the registry key wasn’t imported properly or the ATI driver on your system isn’t logging properly. You can try re-importing the key and rebooting and repeating the previous steps to generate log messages but if you’re still not seeing Source “atikmdag” with Event ID “43029” messages then give up now because this workaround requires the ATI driver to be logging properly.

The final step is to attach a custom task to the 43029 event so hit Start and type in “Task Scheduler” to bring up the Windows Task Scheduler. In the Action column on the right, click on “Import Task…” and then navigate to the temporary folder where you extracted “System_atikmdag_43029.xml”. Select that file and click on Open. This will import the Task I exported from my Media Center machine into your machine. The next dialog box will let you customize the task and the only thing you should have to change is the user account that the task runs under. In the “General” tab, click on “Change User or Group…” and type in the username of the user that Media Center runs as. Generally this will be the user you’re logged in as to complete this workaround. Finally click on “OK” to complete the importing of the Task and then reboot your machine just to make sure all the changes took hold.

Although this workaround does effectively let you enjoy Media Center using only remotes, since there is no event logged when the display becomes available again, you have to run Media Center manually each time the television is turned on. This isn’t much of an issue since you can just push the Start button on your Media Center remote, but it’s better than digging out a keyboard and/or mouse and manually trying to figure out how to close Media Center. Seeing the Windows desktop each time the television is turned on doesn’t have a very set-top-boxy feeling so I’m still actively searching for a solution to run Media Center when the display becomes available.

One possible solution for starting Media Center could revolve around “sleep mode”. If the user always wakes the computer up from sleep when they turn the television on, a task attached to the log message generated when the computer resumes could be set to run Media Center. The current issue I’m having, however, is with “Away Mode”. If Media Center is currently recording something and the user pushes the power button on the remote, the computer won’t go into sleep mode, instead it goes into away mode. Away mode isn’t a real sleep mode, the computer just turns off the video giving the user the illusion that the “box” has been turned off or put to sleep. Unlike, sleep, exiting away mode has logs no event so there’s nothing to attach a task to.

Ironically turning the television on triggers “device disconnected/connected” sounds in Windows but doesn’t seem to generate any type of “video device connected” logs anywhere in “Windows Logs” or “Applications and Services Logs”. Applications and Services Logs even has a category for “Hardware”, which is suspiciously empty. And despite “Microsoft\Windows” having like a zillion subcategories, I wasn’t able to find a single event that could be used as a reliable way of running Media Center when the television is turned on. Also, ironically, despite having an EnergyStar logo and unlike a normal computer monitor, the television here doesn’t go into standby mode when the HDMI signal is removed. Instead it just shows a scary blue screen.

Anyway, hopefully this half-of-a-solution will help some of you get back to enjoying Media Center without spending money on extra hardware to fix this issue. Meanwhile, let’s keep bugging ATI and Microsoft to get out a fix for this because it seems like it should be something that’s simple to fix, just remove any code that puts of a black overlay in front of Media Center! Why there’s even code to do something like this is beyond me.

On the Path to the Ultimate Media Center Media Library (Part 1)

Introduction

For the past few months, I’ve been working on and off with the Media Browser team to help create the ultimate media library solution for Media Center. I’ve come to realize that Media Browser’s folder based system has some major drawbacks and I’ve been unable to convince the team to switch to a better storage system. So I’ve decided to completely rethink the idea of a “Media Library” and build my own solution.

The Problem

The real problem is that there isn’t a standard movie file format or television file format. Most, if not all, of the Media Center plugins, and the Windows 7 Movie Library, require each movie to be in its own folder. Additional files such as backgrounds or cover art are also generally placed in these folders. Metadata for movies is provided by the de facto standard “My Movies” XML file, a “dvdinfo.xml” file or an entry in a database. Metadata for television episodes isn’t standardized and varies from application to application.

Forcing each movie or television show season to be in a folder adds an extra level of complexity to library management. No other type of digital entity (photos, documents, etc) requires a unique folder. Even an entire music collection could exist in a single folder, the embedded metadata dictates how the player application will organize for presentation to the user.

All modern video containers support metadata, however the level of metadata support varies:

  • AVI supports almost no useful metadata.
  • WMV supports more metadata but not quite enough.
  • DVR-MS/WTV support fairly extensive metadata but is missing a few critical items like “Season Number”. (It may be possible to add additional custom metadata to this container. Must investigate further.)
  • MP4 supports a weird collection of metadata, seems to have an emphasis on music, does support “Season Number” and “Episode Number” but is missing stuff like “Directors”, “Actors”, “Crew”, etc.
  • MKV supports almost no default metadata but has an extensible tag based system that can be customized on a per-file basis. Also supports Chapters.

The Matroska Hydra

Of all the relevant container formats, Matroska seems to be the most popular and already supports embedded metadata via “tags”. Matroska also has the advantage of supporting “attachments”. Currently these attachments are mostly used for subtitle fonts but there’s nothing stopping us from using them for cover art or background images.

However, Matroska isn’t perfect as there still isn’t full support in Windows. The filters/splitters that are available only implement the minimal features to make the files playable.

Currently missing from Haali’s implementation:

  • Fast forward and rewind
  • Subtitles require VSFilter
  • Subtitles disable DXVA
  • Subtitles, audio tracks and chapters aren’t switchable from Media Center
  • x64 version not officially supported / hard to find
  • Property Handler for Windows Explorer / Desktop Search

Currently missing from DivX Lab’s implementation:

  • Chapter switching
  • Subtitles
  • Audio track switching
  • Property Handler doesn’t fetch metadata, only runtime

I have not tested Gabest’s splitter but I’m going to assume it has fewer features than either Haali or DivX Labs as it is much older and I believe it to be no longer being developed.

The Long Road Ahead

Before we can even begin to embrace Matroska as the ultimate container format for movies and television, we need to implement some lower level services.

  • IFilter so Windows Desktop Search can index metadata
  • Property Handlers so Windows Explorer can display properties (and maybe edit)
  • Libraries to obtain and add metadata to existing Matrosta files
  • Libraries to remux other containers into Matroska files

After creating these base items, we can do some really cool stuff like create a “Movie Library” using Windows 7’s Libraries feature. This would allow searching for more than just filenames from Windows Desktop Search. For example, I could search for “Bruce Campbell” and get a list of all movies I have starring Bruce. Property Handlers should also allow us to extract attachments from a Matroska file allowing us to use cover art as icons instead of thumbnails generated from a frame of the movie. The Media Center plugin would no longer need a database since Windows Desktop Search effectively becomes the database.

Conclusion

The remaining blog posts in this series will chronicle the research and development I’m doing while creating this “Ultimate Media Library”. The pace of the work I’ve done up to this point has been very slow so I would expect the frequency of posts in this series to be anything but frequent. I plan for the entire project to be open source however there’s nothing worth posting yet. If anyone has any ideas or would like to get involved, feel free to get in touch with me on Twitter or via this site or whatever.

Fun With ToDVRMS v1.0.1.0

I managed to get a hold of the “Early Access” version of Andy’s ToDVRMS tool specifically to test out the WTV file creation features. So far, every h264 encoded Matroska file I’ve tried converted to WTV and played back properly in Media Center.

There are a few issues however:

  • ToDVRMS doesn’t support much metadata embedding and the few commands I tried didn’t work (-title, –year) with the exception of –m which flags the file as a “IsMovie” (this means the file will show up in the Media Center Movie Library).
  • There’s no direct path for converting scene subtitles (SRT, SSA, ASS, etc.) to “line 21”. Line 21 is apparently the only subtitle system supported by WTV and even though I was able to find tools to convert SRT files to SCC and then from SCC to “raw” (supposedly the format “line 21” uses), ToDVRMS doesn’t have an option to use subtitle files from any source other than a stream in the original MKV file. MKV only supports a handful of subtitle formats and “raw” wasn’t one of them so I was unable to get any subtitles working.
  • “Forced subtitles” are going to be an issue. Unless there’s something to “force” a subtitle track to play by default (like Matroska has), the only solution for forced subtitles will be to transcode the file with the subtitles “burned” into the stream.
  • DTS doesn’t work at all. ToDVRMS crashes when trying to convert a file with DTS audio. This was expected as I don’t believe WTV supports DTS anyway.
  • I’m assuming MKV “chapters” won’t work but I didn’t test this as there are no command line options to enable chaptering and WTV probably doesn’t support chapters anyway.

Things that did work:

  • Multiple audio tracks. I have a copy of Akira with the original Japanese track and a dubbed English track. I was able to switch tracks using the “i” button on the remote and sliding over to the “language” area.
  • No transcoding was required. The WTV container supports h264 streams.
  • Fast forward and rewind on the remote work as expected when playing from Media Center. The fast forward and rewinds buttons didn’t work in Media Player, but we don’t really care about Media Player, do we?

I have no idea if these will play on Extenders as I don’t have one to test with (no 360 either) but, based on what I’ve read, they should play fine on any Extenders that support h264.

How-To Disable DXVA for ATI Cards to Fix Pixilation and Corruption in High Bitrate h264 Files

I originally posted this as a reply on The Green Button:

http://thegreenbutton.com/forums/p/77948/387265.aspx

And now I’m posting it here for mostly personal reference.

I have problems with at least four 1080p and three 720p h264 files. The problem is basically what netscan02 said: ATI cards have issues with some higher bitrate files. I'm using the default video driver that comes on the Windows 7 DVD (which is apparently the same as the driver in the "Catalyst 9.5" package). I have not tried any of the newer Catalyst releases as I would rather let Windows Update handle driver updates instead of chasing new Catalyst releases.

My "solution" ended up being to disable DXVA for h264 using "DXVA Checker": http://bluesky23.hp.infoseek.co.jp/en/

All you have to do is download DXVA Checker, extract it somewhere, run it, hit the little button in the upper right corner under the close button (X), hit Video Acceleration Settings (or CTRL-V) and toggle "HWUVD_DisableH264". There should be a check mark in the checkbox to the left and a "1" in the Value column if you clicked in the right place.

Keep in mind that this disables DXVA for h264 streams so you're going to see quite a bit of CPU usage when playing ANY h264 files from now on. This may not be an issue as DXVA gets disabled if your files have subtitle streams anyway.

There may be other solutions but this one gets your stuff working without mucking about with 3rd party nonsense. (Well other than our favorite trilogy of Haali (for MKV's), AC3Filter (for DTS) and VSFilter (for subtitles).)

How-To Set Up a Build Machine to Compile Media Center Projects

  1. Depending on the requirements of the project, install the appropriate version of .NET Framework.
  2. Install Media Center SDK. Either the Vista or 7 version should work.
  3. If your build machine is Windows Server 2008, find an already running Windows Vista installation and copy Microsoft.MediaCenter.dll, Microsoft.MediaCenter.UI.dll and ehres.dll from “C:\Windows\eHome” to a folder on the server. (Note that additional assemblies may be required depending on what is referenced in the project.) If the build machine is Windows Server 7, copy the same assemblies from a running Windows 7 installation instead.
  4. Use GacUtil.exe to register Microsoft.MediaCenter.dll and Microsoft.MediaCenter.UI.dll into the Global Assembly Cache. GacUtil.exe ships with several Microsoft products and each one installs it into a different location. The .NET Framework SDK registry entry claims the SDK installs to “C:\Program Files\Microsoft SDKs\Windows\v6.0A” but that isn’t always true. If the SDK is installed as part of Visual Studio, the SDK will be at that path, but if it is installed as part of Windows SDK for Windows Server 2008 and .NET Framework 3.5, the SDK will be at “C:\Program Files\Microsoft SDKs\Windows\v6.0”. (Note the lack of an “A” at the end of the path.) If the SDK is installed as part of Microsoft Windows SDK for Windows 7 and .NET Framework 3.5 SP1, the SDK will be installed to “C:\Program Files\Microsoft SDKs\Windows\v7.0”. GacUtil.exe will be in the “bin” folder in the root of the SDK folder.
  5. Copy Microsoft.MediaCenter.UI.dll to “C:\Program Files\Microsoft SDKs\Windows Media Center\v6.0\Tools” so McmlVerifier.exe can find the assembly. If the project uses resources from ehres.dll, copy it to the same location.

Note that depending on how the project handles the McmlVerifier task, you may need to write a custom BuildTask to handle multiple build environments.

At this point you should be able to compile Media Center projects from the command line on the server using MSBuild. If your command line build works properly it should also work properly from a Continuous Integration server.