Fun with DVR-MS Follow-up

I've received some very nice feedback on my DVR-MS article... I'm glad people are finding it so informative!

I did want to call out one thing about the sample code.  Buried in the middle of the article (when discussing WmvConverter) is a sentence:
"This code will allow you to convert non-DRM'd, NTSC, SD content stored in DVR-MS files into WMV files."

Lots of acronyms 😉  I probably should have called this out towards the beginning of the article where people might see it before downloading the sample code (and I'll see about getting that added; for now, this blog post will have to suffice).  There are some issues with PAL and HD content that will probably cause the sample code to fail when run on these formats.  So while the general concepts discussed in the article apply to both PAL and HD, there are some workarounds required to get the code to work correctly with those formats.

Luckily, Alex Seigler of dvr2wmv fame has derived and implemented such workarounds in his production-quality dvr2wmv.dll (available at and linked from in the article).  If you're looking for sample code and an overview of all of these processes, use the article.  If you're looking to use something like this for production purposes, use dvr2wmv

Comments (24)

  1. Sean McLeod says:

    What are some of the issues with PAL recordings that we would run into?

  2. Stephen Toub says:

    Hey Sean-

    Alex Seigler (dvr2wmv) and I are now working on a follow-up article that discusses the issues and workarounds. Stay tuned… 🙂

    Do note that most of the samples included with the article, such as the DVR-MS Editor and metadata accessing code, should work fine with PAL. The problems come into play when attempting to process the actual PAL video stream, so it affects the transcoding code. The article is still accurate with regards to PAL, there are just some additional steps that are probably necessary to get transcoding process to work… that said, feel free to try it with PAL recordings, and if it works for you, excellent 🙂


  3. Sean McLeod says:

    Cool, looking forward to the follow-up article.

    Any chance the Managed DX team will take the work you did on creating the managed wrappers to DirectShow and bundle it in the next DX SDK?


  4. Stephen Toub says:

    It would certainly be nice if a future version of Managed DirectX provided additional support for DirectShow 🙂

  5. Sean McLeod says:

    Looking at the DirectShow graphs with the Line21 closed caption filter I guess one potential feature is to index the contents of the closed caption text for recorded shows for subsequent searching. Similiar I guess to what Google does for their movie search facility.

  6. Jon Galloway says:

    Great article! Well worth a very close read. I’ve dabbled with DX and MCE enough to really appreciate the depth you went into while keeping the artilce reasonably short. Very well written!

  7. Alex Leskiw says:

    When editing a dvr-ms file, there always seems to be short audio or video artifacts in the final saved file like a few frames of video from a commercial(maybe 1/2 second or less). The same happens with the audio. I have had to convert the dvr-ms to mpeg and use an mpeg editor to get frame level accurate editing and then convert the result back to dvr-ms but I lose closed captioning and MetaData in the process. Is there a way to make the splice segments accurate to the frame level? I noticed the dvr-ms file has an attribute "DVR Index Granularity" with a DWORD value of 500. I assume this is 500 milliseconds? Is this why we can’t edit to the frame level? If so, is there a way to generate a finer granularity? Could the IWMIndexer Interface of the WMFormat SDK be used to generate a finer index? Thanks for your time.

  8. The Index Granularity value is in milliseconds, and hence the half second accuracy for splices. As of the current version, I don’t believe it’s possible to edit at the frame level, at least not in a supported way.

  9. Larry says:

    I’ve converted some to mpeg but the Episode info is not in the file name so i lose the episode info and have to guess. How can I extract just the text that tells the Episode information so I can name the file with this info for ref?


  10. Larry, check out the DvrmsMetadataEditor class in the code download for the Fun with DVR-MS article. You can use it to extract the title and episode title. In fact, I believe I do this in the ConvertToWmv sample app, but it’s been a while since I looked at it.

  11. Chris Dimopoulos says:

    Has anyone find a solution with the IStreamBufferMediaSeeking::SetPositions Bug.

    I’m trying to Seek a Positions and I can’t get accurate results.

    It’s Usually 5 Frames out.

    The Problem is with the pCurrent :

    HRESULT SetPositions(

    LONGLONG *pCurrent,

    DWORD dwCurrentFlags,

    LONGLONG *pStop,

    DWORD dwStopFlags


    I would apriciate any help.


    Chris Dimopoulos,

  12. luc prigent says:

    I get some problem of quality with dvr 2 wmv

    I use pal VCR or cbr.

    A 6 GB file give a 8 MB file.

    IT’s too much compress and the movies lost in quality (l’image est saccadée)

  13. luc prigent says:

    I get some problem of quality with dvr 2 wmv

    I use pal VCR or cbr.

    A 6 GB file give a 8 MB file.

    IT’s too much compress and the movies lost in quality (l’image est saccadée)

  14. t_anbazhagan says:

    The link is not available on the Microsoft site. Can you suggest if you have posted the same anywhere else?

  15. I’ve asked the same question as I’m not sure what happened to it… I’ll post a new link when I have one.  Thanks for the interest.

  16. Slowpork says:

    Hello Steven,

    I ran "Search and View" utitity on

    and I notice its timing is a little off comparing to what I see on MCE, so I think I should report this to you.   Btw, thanks for your article!



    00:00:00,195 –> 00:00:01,498

    HEY, ROX.


    00:00:01,499 –> 00:00:02,398



    00:00:02,498 –> 00:00:02,999



    00:00:03,000 –> 00:00:05,701

    IT WAS.


    00:00:05,702 –> 00:00:06,503



    00:00:06,603 –> 00:00:07,004



    00:00:07,102 –> 00:00:10,007


  17. Thanks.  How did you capture the MCE timings?

  18. Slowpork says:


    When I view on MCE, CC shows when actor/actress speaks.

    But when I encode .dvr-ms to .mpeg2 and extract a separate .srt, and play with Media Player Classic, which is a player that can reads CC (.srt file), CC comes a little faster before actor speaks.  Thus, I assume the timing is off  since it doesn’t show at same spots as in MCE.

    Here is how I extract .srt file from .dvr-ms  

    Thanks ! 🙂

    using (StreamWriter writer = new StreamWriter(outputName, false, Encoding.Unicode))


    TimeSpan previousCleartime = TimeSpan.Parse("0");

    TimeSpan tmptime = TimeSpan.Parse("0");

    NtscClosedCaption previousCC = new NtscClosedCaption();

    foreach(NtscClosedCaption cc in ccs)



       if (i > 1)


    a = previousCC.StartTimecode.Hours.ToString("00")

       + ":" + previousCC.StartTimecode.Minutes.ToString("00")

       + ":" + previousCC.StartTimecode.Seconds.ToString("00")

       + "," + previousCC.StartTimecode.Milliseconds.ToString("000");

    b = previousCC.DisplayTimecode.Hours.ToString("00")

       + ":" + previousCC.DisplayTimecode.Minutes.ToString("00")

       + ":" + previousCC.DisplayTimecode.Seconds.ToString("00")

       + "," + previousCC.DisplayTimecode.Milliseconds.ToString("000");

    c = previousCC.ClearTimecode.Hours.ToString("00")

       + ":" + previousCC.ClearTimecode.Minutes.ToString("00")

       + ":" + previousCC.ClearTimecode.Seconds.ToString("00")

       + "," + previousCC.ClearTimecode.Milliseconds.ToString("000");


    //writer.WriteLine("{0}t{1}t{2}t{3}t{4}t{5}", cc.StartTimecode, cc.DisplayTimecode, cc.ClearTimecode, cc.Text, cc.CaptionType, cc.Channel);

    writer.WriteLine("{0}", i – 1);

    if (previousCleartime >= cc.StartTimecode)


       writer.WriteLine("{0: (###) } –> {1}", a, b);




       writer.WriteLine("{0: (###) } –> {1}", a, c);


    writer.WriteLine("{0}", previousCC.Text);



  19. RonBoyd says:

    Thursday, July 12, 2007 2:05 AM by Anbazhagan

    # re: Fun with DVR-MS Follow-up

    The link is not available on the Microsoft site. Can you suggest if you have posted the same anywhere else?

    Thursday, July 12, 2007 11:24 AM by toub

    # re: Fun with DVR-MS Follow-up

    I’ve asked the same question as I’m not sure what happened to it… I’ll post a new link when I have one.  Thanks for the interest.

    Was there any follow-up on this?


  20. Not yet… still trying…

  21. Henry says:

    Toub — any progress on the comments posted by slowpork on July 24 regarding the wrong timings on the extracted CCs?  Thankx for your help.

  22. Napsil says:

    There are  tons of information to be known about this. You made some great points that answered my questions.

Skip to main content