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.

How-To Configure Windows 7 Public Libraries (Recorded TV) From Explorer

By default, Windows 7 ships with a number of pre-configured “Libraries” that exist on a per-uses basis. Each user has their own set of Libraries and each of those Libraries includes both a public folder and private folder intended as storage for file types based on the name of the Library.

Libraries

Users of Media Center and Windows Home Server’s “TV Archive” plug-in may notice that there’s a second type of Library that exists on a system-wide basis instead of a per-user basis. So far, the only “Public Library” that exists by default is for “Recorded TV”. However, Public Libraries don’t appear in a user’s list of Libraries and the Recorded TV Library is only visible in Explorer after a user has configured a TV Tuner from within Media Center.

RecordedTVLibrary

This behavior makes sense for networks where only a Windows Home Server is used for storing Recorded TV, however in this age of home networks and multiple PC’s, Recorded TV is frequently stored on multiple machines and/or multiple folders on those machines.

Fortunately, there’s a fairly easy solution:

  1. From Windows Explorer, navigate to: C:\Users\Public\Libraries
  2. Create a shortcut for the “Recorded TV” Library in that folder
  3. Move the new shortcut to a location easily accessible from Explorer (such as Favorites)
  4. Select properties for your newly visible Recorded TV Public Folder and configure as desired

This solution will allow you to configure the built-in Recorded TV from within Windows Explorer on machines that don’t have a tuner card installed.

Thanks to Ed Bott for tuning me into the location of system-wide Libraries.

The Holy Trinity of Matroska (.mkv) Filter Packages for Windows 7

Now that 7 has been released, goofy codec packs are no longer needed, except for special circumstances. The “Holy Trinity” of MKV filter packages is:

Some Matroska files do use additional codecs, usually for commentary audio tracks, so you might also want to pick up FFDShow-tryouts. When installing FFDShow, deselect everything except for the additional codecs you need, generally this will be “Vorbis” and “Theora”.

Registering VSFilter.dll is a bit of a pain since there’s no installer. First extract VSFilter.dll to your favorite codecs folder. I generally use “C:\Codecs”. Next, load an Administrative command prompt by typing “cmd” into the search area, right clicking on “cmd.exe” (which will be a returned result from the search) and selecting “Run as administrator”. Then at the c: prompt, type “cd c:\codecs” or “cd ” followed by whatever folder you store your codes in. Finally, at the c: prompt again, type “regsvr32 VSfilter.dll”. If everything went right, you should get a dialog box that says the filter was registered successfully. Now when you load up your favorite Matroska file, enjoy subtitles! Note that you can change subtitle tracks and audio/video tracks by right clicking on the Matroska icon in the System Tray.

Update: x64 users will need a 64-bit version of VSFilter. I haven’t tested this build but Shark007 seems to know what he’s doing so hopefully it will work for you. (Confirmed to be working by Jere_Jones.)

Comprehensive Report of Relevant Container and Codec Support in Windows 7 and Media Center

Containers

  FF/RW Subtitles Selectable audio tracks Useful metadata Chapters
AVI No No No *** No No
MP4 Yes No * No **** No ***** No
TS No No * No **** No ****** No
M2TS No No * No **** No ****** No
WTV Yes Maybe ** Yes Yes No *******

* Despite the spec requiring this, Microsoft decided not to implement MPEG-4 Part 17 “Timed Text”.

** According to this Microsoft Whitepaper, WTV supports most standard types of “captioning” however captioning isn’t what we normally think of as “subtitles”.

*** Note that AVI does support multiple audio tracks, however there is no way to change tracks and all tracks play at the same time, mixed together.

**** Only first audio track plays. There is no method for selecting alternate tracks.

***** MP4 does support metadata but Media Player and Media Center don’t recognize it. Tagging an MP4 based TV episode in the Zune software generates Windows Media style “WM/TagName” tags as a sub-tag of a custom MP4 “Xtra” tag, however, despite the use of Windows Media tags, TV episodes and movies do not show up in the Media Center Recorded TV area or Movie Library.

****** Zune software won’t recognize TS or M2TS files so I’m not able to test Windows Media tags on these files since no other known software can generate such tags.

******* It may be possible to simulate “chapter” support by using Microsoft’s “iTV” system but this looks like a lot of engineering work and the work versus payoff probably isn’t worth it.

MPEG-4 Video Codecs

  Part 10/AVC/H264 Part 2/ASP/DivX/XviD
AVI Yes Yes *
MP4 Yes Yes *
TS Yes No **
M2TS Yes No **
WTV Yes ***

Note that I didn’t cover MPEG-4 Part 2/SP (Simple Profile) because it is a low quality codec designed for low-end devices such as mobile phones and portable media players.

* Most, but not all, MPEG-4 Part 2 Profiles are supported. Nothing using "DivX 3” is supported.

** These containers do not support MPEG-4 Part 2 by design.

*** As of this moment, I’m unable to convert anything other than AVC/H264 to WTV. I assume MPEG-2 files will work but I didn’t test due to lack of material to test with and increasing irrelevance of the codec for our purposes. Plus we already know MPEG-2 works because all TV broadcast in the US uses MPEG-2.

Audio Codecs

  MP3 AAC AC3 DTS
AVI Yes * Yes No
MP4 Yes Yes No *** No
TS No Yes Yes No ****
M2TS No Yes Yes No ****
WTV No No ** Yes No *****

* Although I’ve read that AVI supports AAC, I wasn’t able to test due to lack of content.

** I was able to create a WTV file with an AAC audio track but the file won't play in Media Center at all. It does, however, play in Media Player with some issues. The sound works and, according to GraphStudio, is being decoded by “Microsoft DTV-DVD Video Decoder”. The only real problem is that moving the slider around causes the video playback to become corrupted and sketchy. According to the PBDA whitepaper linked to above, WTV should support AAC so I’m quite confused as to why AAC has issues in WTV.

*** The AC3 decoder included with Windows 7 is DirectShow based but the MP4 container source is handled with Media Foundation, which has no AC3 decoder, so AC3 doesn’t work despite being part of the MPEG-4 ISO specification.

**** Despite DTS being part of the specification requirements for TS and M2TS files, Microsoft hasn’t implemented a DTS codec in either DirectShow or Media Foundation. The mildly good news is that if you have a TS/M2TS file with multiple audio tracks, the first track that is supported is the one that plays.

For example, my ripped copy of Big Trouble in Little China has five tracks:

  1. H264 video
  2. DTS main audio
  3. AC3 main audio
  4. AC3 director commentary
  5. SRT / Timed Text / Presentation Graphic Stream

However, the only streams that actually play are (1) the main H264 video and (3) the main AC3 audio. Note that there is no method to change to (4) director commentary from within Media Player or Media Center.

***** I was able to create a WTV file with a DTS audio track but the file won't play in Media Center at all. The strange thing is that the file did play in Media Player and the System Tray icon appeared for “ac3filter” but only when I have “ac3filter” set to handle SPDIF audio. I suspect it may be possible to get DTS working in WTV with some major hacking and/or DTS may work via SPDIF passthru, however I have no SPDIF hardware to test this theory.

Comments

MPEG-2 was not covered because it isn’t efficient enough, the files take up way too much space and everyone already has their collection in either H264 or DivX/XviD already anyway

Interestingly, WTV doesn’t seem to be Media Foundation based since WTV files can be loaded in GraphStudio but TopoEdit won’t touch them. H264 in WTV is handled by “Microsoft DTV-DVD Video Decoder” which is, according to the PBDA whitepaper, both a DirectShow filter and Media Foundation Transform, so apparently there simply isn’t a Media Foundation Source to handle WTV files.

At the very least, Microsoft should be supporting MPEG-4 Part 17, or Timed Text, as the ISO specification does require it. Microsoft is a very “accessibility” centric company and not supporting subtitles in MPEG-4 media files seems very not-accessible to those with hearing problems. Plus a lot of us have ripped media with community based subtitle solutions (SRT, ASS, etc.) that could easily be converted to MP4 and take advantage of Timed Text.

Conclusion

This is a good start but I don’t think we can really call MPEG-4 “supported” out-of-the-box. The lack of subtitles or “Timed Text”, no DTS codec and no support for standard metadata really make Windows 7’s MPEG-4 support feel unfinished. I’m also confused as to why some Part 2 (ASP) files didn’t work. It seems like DivX 3 should work since the code was apparently based on code that leaked from Microsoft that was eventually used as one of the WMV codecs. Even more confusing is why some XviD files wouldn’t play despite DivX and XviD being based on the Part 2 ASP specifications.

Media Foundation is supposed to be the successor to DirectShow, and from what I can tell, Media Foundation is a much cleaner system and supports some nice features, like transcoding, but without support for WTV files, AC3, DTS and hit-or-miss MPEG-4 support, it feels very unfinished as well.

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 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.