andy vt's tools & blog

automating lazy

This Blog


andy vt's blog

November 2007 - Posts

  • DVRMSToolbox For Vista - (Early Access Release) is now available for Early Access members. 

    - Added DirectShow.Net code for future migration
    - Added WOL functionality to the addin
    - Fixed a bug in the way external processes are shelled
    - Comskip 0.79.111 included
    - New file detection mechanism for playback.  Addin no longer uses RM to detect playing files.


  • DVRMSToolbox For XP - Public Release

    - Added file cleanup options to the FW
    - Updated Mencoder to Version 12
    - Added Quiet option to ConvertWithFfmpeg
    - Added ConvertWithWMEncoder to advanced actions
    - Fixed a bug in ConvertWithGraph where OutputFile was not set to the file created
    - Comskip version 0.79.111 (supports live detection) included
    - Added Sleep action
    - Added Profile inheritance feature to settings tool
    - Set tab order in settings tool
    - Added prevent standby option to Processing settings
    - SA version 0.9.2
    - Fixed a bug in the way external processes are shelled

    Bin | Source 

  • Transcoding Forum

    Just added a new forum for discussing transcoding files for devices and formats.  It will should be easier to have one place to find information on this topic.
  • Media Broker - Streaming TV

    Back in February I started thinking about what was the biggest missing piece of an all PC based Media Center solution.  I got thinking about this again after a recent post by Charlie Owen about how they could better document Microsoft's approach to the "Connected Home".  It's a great idea, but the scenarios listed are very telling in that he completely left off the multiple WMC home.

    As much as I want to rant about how that doesn't make sense, that's not the point of this post.  The big thing that I couldn't do with the Media Broker idea was streaming tv content (live or recorded).  After some research this doesn't seem like a huge problem.  I've narrowed it down to two approaches.

    1. Windows Media Format: The same guys who provided a managed wrapper around DirectShow started doing the same thing with the Windows Media Format interfaces.  I've got a working sample that transcodes dvr-ms to wmv for broadcast, but because I'm targeting local network broadcast it would be more practical (unless you've got a quad core) to just stream the MPEG data using the library.  Fortunately MS provided access to most of the WMF interfaces in the WM ASF Writer DirectShow filter so it should be possible to do this.  Unfortunately I haven't been able to get it to work.  The biggest issue is setting the audio media type in the ASF profile.  If I ignore audio and just write the video (which does work without complaint), the file won't playback.  This is probably a codec issue, the SDK tells me to retrieve the codec info from the source header and write it to the target, but there isn't any codec info in the DVR-MS file.  The main benefit of this solution is everything necessary (except the glue) is on every Windows machine, and it could be free.  Assuming I can get it working, I'm hoping that the MC SDK could work with this solution easily.
    2. Third Party Streaming: This is definitely the easiest approach.  Elecard sells a couple filters that make this very easy, they even include a sample that can stream MPGs with AC3 audio in their SDK.  Some minor modifications should make it work for DVR-MS files.  The major drawback here is that I doubt that it could be free.  There are other issues, the main one is client graph construction (I don't know how to force MC to create the necessary graph).
    Right now I'm just messing around; but I am curious what the different perspectives are out there on how useful something like this would be.

  • Updated DVRMSToolbox For XP- (Early Access Release)

    Rolled a fix from in how external processes are run into 
  • Comskip - Live Detection - ini settings change

    If you're using comskip for live detection there's been a change in the suggested value for the live_tv_retries setting. 

    The value should be set to 300 (instead of 120), and if you're using comskip on SD ATSC content you may want use 600.  If everything is working correctly you can get try stepping it down. 

  • Creating DVR-MS files

    It's been a long time since I've bored anyone with some programing, but given the dearth of information on use the Stream Buffer Engine (SBE) to create DVR-MS files (especially using managed code) I figured it was time to share; maybe save someone else the pain of figuring this out.

    The code for this application can be downloaded here.  Also this application uses the awesome DirectShow.Net library; so any derivative works must comply with it's licensing (LGPL). 

    FixDVRMSDuration is a very simple application that takes one DVR-MS file and uses DirectShow to stream the contents directly into another file.  It was created to address issues with some files that had incorrect duration values.  Unfortunetly the published interface for writing meta data (IStreamBufferRecordingAttribute) doesn't support writing the Duration value so this was the easiest way to address it.

    The basic outline of the application looks like this:

    • create a graph
    • add the sbe sink filter
    • add the source file to the graph (in this case a dvr-ms file)
    • enumerate output pins on the source filter to render them (it's important to connect the pins before configuring the sink)
    • configure the sbe sink
    • run the graph

    The only tricky bits are related to configuring the sbe sink filter so I'm going to skip the rest of the DirectShow stuff. 

    First step is to create an instance of the StreamBufferConfig object.  We need to use two interfaces that the object implements IStreamBufferConfigure3 and IStreamBufferInitialize.

                IStreamBufferConfigure3 config = (IStreamBufferConfigure3)new StreamBufferConfig();
                IStreamBufferInitialize init = config as IStreamBufferInitialize;

     When the SBE creates a file, it stores the configuration data in a registry location, so we need to create a new key.  Creating it in HKCU ensures that anyone can use the program, and using a GUID makes sure there's no naming collision.  Unfortunately the initialization interface requires a pointer to the key, so it's not possible (without using reflection) to get that from the managed RegistryKey class, so we can use the managed class to create the key and pinvoke RegOpenKeyEx to get the pointer.

                string keyName = string.Format(@"Software\SBERender\{0}", Guid.NewGuid().ToString());    
                RegistryKey rk = Registry.CurrentUser.CreateSubKey(keyName, RegistryKeyPermissionCheck.ReadWriteSubTree);
                int result = RegOpenKeyEx(_registryHive, keyName, 0, STANDARD_RIGHTS_READ | KEY_QUERY_VALUE | STANDARD_RIGHTS_WRITE, out registryKey);
                 hr = init.SetHKEY(registryKey);

    Once we set the registry location, we can tell the SBE where to write the backing files.  The SBE was designed to create different types of recordings; when creating a temporary file (Live TV) the content is written to a file with the sbe extension located in this directory, when a permanent file is created (Recorded TV) the SBE still creates a sbe file in the this directory but the content is actually written to a dvr-ms file which can be located in a different directory.

                 hr = config.SetDirectory(Path.GetDirectoryName(target));

    Honestly, I'm not sure why this next line is required.  But without it bad things happen.  Found out why this was necesary (in the documentation for IStreamBufferSink::LockProfile); "Windows Vista or later: This method requires administrator privileges, unless you first call IStreamBufferConfigure3::SetNamespace with the value NULL."  Working with the SBE isn't hard, but the documentation is very opaque so figuring out the sequence and necessity of the calls was a PITA.

                 hr = config.SetNamespace(null);

    Now that we've created the configuration, it's time to let the sink filter know about it.  Retrieving the IStreamBufferInitialize  interface from the sink and passing the pointer to our registry key does exactly that.
                 IStreamBufferInitialize init2 = sink as IStreamBufferInitialize;
                 hr = init2.SetHKEY(registryKey);

    We get a glimpse into the DVR-MS's ASF heritage when we lock the profile to create the backing file. 

                 hr = sink.LockProfile(Path.Combine(Path.GetDirectoryName(target),string.Format("{0}.sbe",Path.GetFileNameWithoutExtension(target))));

    Recording is controlled through the IStreamBufferRecordControl interface which we get by calling CreateRecorder on the sink filter.  In this case we want a permanent (dvr-ms) file so we tell the recorder to create a Content recording.

                 object objRecorder;
                 hr = sink.CreateRecorder(target, RecordingType.Content, out objRecorder);
                 IStreamBufferRecordControl rec = objRecorder as IStreamBufferRecordControl;

    If we've setup the graph correctly it's time to start the recording.  Pass in 0 to start immediately.

                 long start = 0;
                 hr = rec.Start(ref start);

    Because of our application of the recording functionality, this is where we run the graph.  Before stopping the graph it's necessary to stop the recording, pass in 0 to stop immediately.  If the graph is stopped before the recording is, an error is generated.
                 hr = rec.Stop(0);

    While this application is very simple, it does open the door to more interesting applications that generate dvr-ms files for existing content (DVD to DVR-MS for e.g.). 

  • WMC does publish the graph

    Somewhere in the progression from beta to RTM (I don't remember exactly when) playback graphs stopped being published to the ROT in Vista.  Or at least that's what everyone (myself included) reported.  It turns out that WMC never stopped publishing, something in the platform changed and you need to register proppage.dll* now.  As long as your application is running in the same context (admin/non-admin process token) as WMC it can pull the graph.  I wonder if you can still mess with it like you could in XP.

    * I don't know if this is "by design" (probably not), but the version of proppage.dll that ships in the Windows Platform SDK actually doesn't work.  You need to find an alternate source for the dll to make it go. 

  • Busy Profile - Automatically switch ringing profile

    Busy Profile switches your ringing profile (On, Vibrate, Off) based on Busy Time from the calendar.


    After installing the application, run from Programs, configure profiles, Enable (from the Control menu), then click Done to save settings.

  • DVRMSToolbox for XP (Early Access Release)

    - Added file cleanup options to the FW
    - Updated Mencoder to Version 12
    - Added Quiet option to ConvertWithFfmpeg
    - Added ConvertWithWMEncoder to advanced actions
    - Fixed a bug in ConvertWithGraph where OutputFile was not set to the file created
    - Comskip version 0.79.111 (supports live detection) included
    - Added Sleep action
    - Added Profile inheritance feature to settings tool
    - Set tab order in settings tool
    - Added prevent standby option to Processing settings
    - SA version 0.9.2
  • AT&T Tilt

    This is my first exposure to WM6 so many of my comments are about it and not the device because in some cases I’m not sure if the change was because of WM6 or because of the new device.  I have to admit bias for this form factor and overall I really like the Tilt, it has a much better feel vs. the other devices I’ve had a chance to try out.  That said, there’s nothing truly revolutionary about it, the differences are very evolutionary but add significant polish to the previous generations.  This is especially true when compared against an 8125, less so against the 8525 with the new ROM version.

    The device is much better looking, and even though it may be slightly heavier vs. the 8125 it fits in the hand (and pocket) much better and feels more lighter.  It did take me a few days to get used to the orientation of the device.  Where the 8125 was very ambidextrous as a one handed device, the Tilt is much more oriented to the left hand.  While it was difficult to get used to at first, I’m glad they picked a hand, because without some custom software (smartskey) the 8125 was difficult to use one handed (it was necessary to use the touch screen a lot).  The scroll wheel is really nice, although I found it difficult to use predictably at times.  This could just be me (and my lack of coordination with the left hand), but I often accidently scrolled when pressing the wheel in to select.  I do think this is something that can be overcome with use, so it didn’t bother me too much.  With the scroll wheel, start, and ok buttons it is possible in to not have to use the touch screen to navigate most tasks.  I found the button layout to be opposite what I expected, although this could just be conditioning from the 8525.  The full length stylus is so much better than the flimsy one that comes with the 8125/8525, but with the advances with the buttons I don’t often need the stylus.

    The built in GPS is a great feature.  It works great with Google Maps and my Navigation software, but not at all with Live Search.  I don’t know how much value other users will get out it (I actually bought an external GPS for my 8125), but it was one of the features that sold me on the device, and when combined with Google Maps it’s a really quick, cheap, easy way to get directions or figure out where you are.

    For me the battery life was very good, about the same if not slightly better than the 8125 (1 ½ - 2 days).  The only time I had any issues with battery life was the first day I had the device when I was using it constantly.  Even then it, had enough charge to get me into the office.  My experience is probably skewed by two factors however, I don’t use the phone much and I can only get an Edge connection in my house.  The Tilt seems to have a similar issue to the 8525 (and Treo) where the 3G connection uses the battery much quicker than Edge.  This can be easily addressed with a little reg hacking; HTC added a 3G button to the Wireless Manager (it's hidden by default) toggling to Edge give the device the best battery life of any PPC device I've ever used.  Leaving it Edge only I got 3 1/2 days out of the battery before plugging it in.  If I were really daring I might have been able to get 4 days before the battery died.

    I really like that it uses a standard mini-USB connection for charging, and can charge completely off of a PC USB connection.  It charges slower than plugging it into an outlet, but the flexibility in where you charge it (not needing to carry the charger around) is a huge bonus over a device like the Treo.  

    I really only have two complaints about the physical device.  I used the flash on my 8125 as a flashlight all the time, there’s no flash on the Tilt; and the back cover is ridiculously difficult to take off.  Both of these things are more annoyances than anything else, and I can see the back cover thing as not that bad because the SIM slot isn’t behind the battery (it’s on the back of the screen) and on my 8125 the back was always coming off because it had the opposite problem.  

    From what I could tell WM6 is an evolutionary change as well.  I didn’t find a huge number of new features vs. the latest 8525 ROM.  There are new features, like Internet Connection Sharing (ICS) vs. the 8125.  Annoyingly AT&T hides ICS by removing the shortcut and putting the nasty modem emulator (the same method as the 8125 had) out in the open.  The link in the comm manager application goes to the modem instead of ICS too.  Strangely AT&T removed other features from both WM6 and Tytn II (HTC’s version of the device) ROMS; native live mail support and the HTC Home pluggin to name two.  Also missing was the RDP client was, but I’m not sure if that was AT&T or if it was not part of the WM6 ROM to begin with.

    There are some subtle enhancements to the PIM applications, like better busy time display, more intuitive softkey usage (delete is mapped to the left key by default), more options for scheduling downloading from other email accounts  and [my personal favorite] the field keeps focus when switching screen orientation on new items.  One oddity is that the Forward action is nested under the Reply tree making it difficult to find, but that’s a relatively minor issue.  

    I did find the device to be unstable at times, nothing out of the ordinary for a WM device (certainly not as bad as pre-MSFP WM5); but I was hoping that it most of those issues would have gotten sorted with WM6.  One issue that I was really hoping was fixed that wasn’t (and is fixed in the Palm implementation of WM5) is intelligently limiting the types of input allowed in fields that only accept a particular type of input.  For e.g. the device will let you input letters into a phone number field.

    Other enhancements:

    • Indicator lights for caps and function buttons (you could enable a similar feature with a reg hack on the 8125)
    • Radio is much “quieter”, I don’t get anywhere near as much interference to nearby electronics
    • Wifi associates with an AP much quicker, and the traffic handoff (switching from cellular to wifi) seems to happen faster and more consistently
    • Sliding action is much smoother, I don’t often tilt the device all the way but I usually give it a slight tilt when using the keyboard to reduce glare
    • Additional button (PTT) that can be remapped (with some registry hacking) to give quick access to another application
    • USB 2.0 connection makes copying files to the device much quicker (this is great for syncing videos)
    • The dictionary (spelling/typing assistance) is much better at adding previously used words to the lexicon
    • Backlight is more intelligent; e.g. it doesn’t display full brightness level when the device is locked
    • HTC Task Manager allows for more control when managing running applications
    • Touchflo is a nice, but unnecessary addition
    If you're a fan of this form factor, as I am, you will love this device. 

    Posted Nov 01 2007, 07:18 AM by babgvant with 2 comment(s)
    Filed under:
@2008 andy vt
Powered by Community Server (Non-Commercial Edition), by Telligent Systems