Welcome to MSDN Blogs Sign in | Join | Help

DVR-MS: Adventures in Closed Captioning

I finished the code for this project months and months ago, and I had every intention of writing a full MSDN article describing the ins and outs of what I’d accomplished, but time seems to have gotten away from me. Rather than let the code languish any longer, I’ve decided to simply write up a (relatively) short blog post, making the code available for all to explore.

For those of you who have read my previous MSDN articles about Media Center, you know I’m an avid fan. I’m also really interested in exploring and expanding on the developer scenario for working with Media Center as well as with the DVR-MS files in which it saves recorded video. There is so much interesting information there, be it the actual video or audio content, or be it the metadata surrounding that content. However, there is a large amount of information available in DVR-MS files that has largely gone unnoticed and unsung, and with this post I hope to rectify that inequity.

Closed captions are an amazing source of information about recorded television shows. The metadata headers in DVR-MS files provide a great deal of information about the show, most of it based on information captured from the electronic program guide. But closed captions detail everything that goes on in a show, the lines that were spoken, interesting dialog, when music is played, and so on. Being able to harness this data makes it possible to write a wide variety of just plain cool applications that make watching and working with recorded television much more enjoyable.

To exemplify this, I’ve written a managed class library in C# (extending that which I created for my original Fun with DVR-MS article on MSDN), that parses and exposes all of the closed captioning data from NTSC non-HD DVR-MS files in a developer-friendly fashion. I’ve then layered on top of this library a few sample applications to demonstrate the power of such a library and the types of application you can have fun writing yourself.

How do I use the library?

You can download the complete sample source code and compiled binaries at http://toub.members.winisp.net/Code/ClosedCaptions.zip. It includes Toub.MediaCenter.Dvrms.dll, which provides the classes for parsing out the captions and working with them. The central class to this effort is the abstract class ClosedCaptionsParser, available in the Toub.MediaCenter.Dvrms.ClosedCaptions namespace. From this class derives the concrete NtscClosedCaptionsParser class which is used to extract the closed captioning data from NTSC files (you’ll notice that the library also includes a PalClosedCaptionsParser, but if you look inside it, you’ll see that it’s simply a shell waiting for you to implement it ;) To use an NtscClosedCaptionsParser, one simply instantiates the class, passing to the constructor the path to the DVR-MS file whose captions are to be extracted, and then calls the parser’s GetCaptions method. GetCaptions returns a ClosedCaptionsCollection, which contains the parsed ClosedCaption instances. Each ClosedCaption instance exposes four properties, three of which are TimeSpans and one of which is a string. The string is the text of the caption (most likely an individual word or sentence from the captioning), and the TimeSpans represent the times at which the data for the caption began to be received, was displayed to the screen, and was cleared from the screen. The NtscClosedCaptionsParser actually creates instances of a class derived from ClosedCaption, NtscClosedCaption, that provides two additional properties. The first of these additional properties is of the enumeration type NtscClosedCaptionType and describes the type of the caption: roll-up, pop-on, or paint-on. To understand the distinction between these types of captions, I suggest you read the free Code for Federal Regulations document 47CFR15.119. This will provide you with a PDF of the subsection titled “Closed caption decoder requirements for analog television receivers,” which is part of the book covering the Federal Communications Commision (FCC) and the section covering radio frequency devices. The other property exposed by NtscClosedCaption is Channel, which tells you with which channel of captioning this particular caption is associated (you’ll often find multiple languages on different channels interwoven, and this allows you to separate them out from each other).

So, as an example of how this can be used, here is a snippet of code that parses the captions from a DVR-MS file and writes them out to the console in a tab-delimited fashion:

NtscClosedCaptionsParser parser = new NtscClosedCaptionsParser(filename);
ClosedCaptionCollection ccs = parser.GetCaptions();
Console.WriteLine("Start\tDisplay\tClear\tText\tType\tChannel");
foreach(NtscClosedCaption cc in ccs)
{
    Console.WriteLine("{0}\t{1}\t{2}\t{3}\t{4}\t{5}",
        cc.StartTimecode, cc.DisplayTimecode, cc.ClearTimecode, 
        cc.Text, cc.CaptionType, cc.Channel);
}

A Few Words About NTSC Closed Captions

A brief tour of NTSC closed captions is probably appropriate. Note that there are a lot of intricacies involved with parsing and rendering closed captioning data, and I’ve chosen to ignore most of them. Thus, I’ve coded up a simplified parser that just deals with the text included in the stream (most of the specification is dedicated to the commands that are also included in the data, which dictate actions such as moving the cursor around the screen and changing the font color). This works very well for most, if not all, of the recorded programs I’ve tested it with, but there could very well be some recordings that cause this code to blow up. If it destroys your computer, I take no responsibility (though I would like to know about it, as I’d find it pretty amazing).

DVR-MS files are created by the Stream Buffer Engine (SBE) introduced in Windows XP Service Pack 1, and are used by Media Center for storing recorded television. They contain metadata describing the contents of the recording (title, episode title, actors, etc.) as well as a variety of data streams. A typical DVR-MS file is made up of two or three of these streams, depending on what version of Media Center created it, the type of signal being recorded, and the actual data being recorded. Most, if not all, DVR-MS files will have both an audio and a video stream. The third stream is the one that may or may not exist, though it will for almost all NTSC content recorded with a recent version of Media Center. This third stream contains the closed captioning data for the recorded television show. As with the audio and video stream, the closed captioning stream is encrypted/tagged, so it must first pass through a Decrypter/Detagger filter. If you use GraphEdit to look at the Out pin on this filter, you'll see that its major type is AUXLine21Data and that its subtype is Line21_BytePair (this may vary based on whether the content is NTSC, PAL, HD, etc.). Closed captioning in NTSC television shows is encoded into line 21 of the Vertical Blanking Interval (VBI).

There are a few approaches one could take to extract the closed captioning data from the CC stream. One approach would be to hook up a Dump filter to the CC stream, saving the CC stream’s raw contents to a file. This file could then be opened and parsed through a managed FileStream. This approach, while very simple, has some significant downsides. The streams that make up DVR-MS files are actually split up into a series of samples, where each sample contains data but also some metadata about that data. One important piece of metadata for each sample is the timecode at which that sample is supposed to be rendered when the file is played. However, when you use the Dump filter to dump the data contained within a stream, you’re simply dumping the data contents of each sample, not the metadata. Thus, there’s no way by examining the dumped bytes to determine with certainty what timecode each dumped byte corresponds to in the original file, especially if the CC stream isn’t continuous (for example, if commercials in the show aren’t captioned).

There’s another way to access the closed caption data, and this approach provides full fidelity, as it provides you access to the metadata for each sample. The Windows Media 9 Series Format SDK, provides classes and interfaces that allow you to read Windows Media files using synchronous calls. These interfaces can also be used with DVR-MS files, and as such the Format SDK allows you to process DVR-MS files using the IWMSyncReader interface. The WMCreateSyncReader function is used to create one of these synchronous reader objects.

In order to parse out the closed captions, I use an IWMSyncReader to find and walk through the closed captions stream in the DVR-MS file. This can involve reading in and looking through gigabytes of data, which means that this isn’t currently a fast process. In fact, to parse the captions from a half an hour show can take a minute or more on my laptop (though I’m running on battery power right now, on the plane on the way back from PDC 2005, so that might be slowing down the process further).

The closed caption stream is divided into a series of two byte instructions, some of which are data and some of which are command codes that detail how to process the data. For example, one command might inform the processor to render the current caption to the screen, and another command might ask the processor to clear the currently displayed caption. My parser is a very simple state machine that loops through the data looking at each byte pair, processing and reacting to each as they occur. There is a whole list of command codes which I’ve special cased in a switch statement: if any of those are found, the command itself is ignored and instead a space is added to the output text. If the command is 0x942f (end of caption) or 0x942c (erase displayed memory), it is treated as the end of the current caption, and whatever text seen up to this point is stored into a new ClosedCaption instance. This instance is then added to the collection of captions, and the text buffer is erased to prepare for the next caption. With the exception of special characters (which occupy two bytes and begin with either 0x11 or 0x19, both of which I’ve ignored and treated as commands) such as musical notes and registered marks, each text byte is inclusively between 0x20 and 0x7A and represents its ASCII equivalent. As such, if a byte isn’t part of a command, I simply cast it to Char and add it to the current text buffer (which will eventually be stored in a ClosedCaption instance when an end of caption or erase displayed memory command is received).

Two-bytes of closed captioning data are sent with every frame of the video, and so determining the time code at which to display a caption can be calculated based on in what frame it was sent (frames that contain no useful closed captioning will contain 0x8080 as a filler). There are two ways to compute the time code based on the frame: dropframe and non-dropframe. Non-dropframe is computed simply by dividing the frame number in which the closed caption instruction was sent by the number of frames per second; for NTSC, this is 29.97 frames per second, and for PAL, 25 frames per second. Dropframe, on the other hand, is used for most broadcast signals and attempts to account for the non-integer 29.97 value using a scheme similar to that employed for leap years (i.e. the earth actually spins 365.25 times in a year, so rather than worry about the quarter day each year, it’s simply rounded off and turned into a 366th day once every four years). Instead of computing the time code based on 29.97 frames per second, it’s computed based on 30 frames per second. This results in 18,000 frames in ten minutes, as opposed to using 29.97, which results in 17,982 frames in ten minutes, a difference of 18 frames every ten minutes. So, when computing timecodes with dropframe, the first two frames of each of the first nine minutes out of ten are ignored, thus eliminating the problem of having an extra 18 frames. Thus, if you use non-dropframe to decode a broadcast that used dropframe, by the end of each 10 minute cycle the timecodes could be off by a little more than half a second. For simplicitly, I’ve decided this is an acceptable discrepancy and have coded my timecode computation method to use non-dropframe. Feel free to change it if this bothers you.

To help with the speed issue I mentioned previously, by default the ClosedCaptionsParser caches a serialized version of the parsed ClosedCaptionCollection into a NTFS Alternate Data Stream associated with the DVR-MS file. After the captions have been parsed successfully once, by default any attempts to parse the captions in the future will first attempt to retrieve the cached captions from this stream. So, while this operation is very fast on all subsequent parsing operations, parsing a DVR-MS the first time can cause significant wait time.

Navigation

For me, one of the most interesting scenarios this capability presents is enhanced navigation. Most folks today with PVR capabilities are stuck in the television-watching mindset of fast-foward and rewind. But what about search? Search is huge! What if you could jump to a place in the video where a particular line was said? What if you want to show someone that really funny joke in the episode of Friends you recorded last night? Closed captions make that possible.

I’ve dubbed this first sample application I’ve implemented “Search and View,” and it does exactly what its name implies. The application hosts the Windows Media Player ActiveX control in order to play a DVR-MS file. When a file is selected to be played, the captions are parsed from the file and are displayed in a list box, allowing individual captions to be selected. When a caption is double-clicked, the video jumps to the location in the video where that caption was displayed to the screen, allowing you instance access to any spoken dialogue in the video. Moreover, there’s a search box on the form that provides very simple searching capabilities. You can enter a search term and have the list of captions narrowed to only those captions that include the search term. Obviously, there are a plethora of ways in which this application can be expanded upon and improved, but I happen to think it’s pretty darn cool as is. Thanks to Derek Del Conte for working with me to flush out the idea for this sample.

Search

If you’re like me, you record many episodes of a few different shows, and sometimes it can be difficult finding the show you’re really interested in watching. What I really needed was a way to do an intelligent full-text search on all of the videos on my hard disk in order to narrow down my files to only those I’m interested in... oh wait, I already have that: Windows Desktop Search. In order to use Windows Desktop Search to allow me to search for recorded videos based on that funny dialogue I want to play for my fiance, I implemented an IFilter for DVR-MS files. This IFilter is written in managed code using COM interop to expose the necessary functionality to Windows Desktop Search so that it can index all of the closed captions contained in my recorded DVR-MS files. I can now simply type into the Desktop Search text box a phrase from a show I previously recorded, and voila, I’m instantly provided with the DVR-MS file I should view. Wow.

Note: I mentioned earlier that it can be very slow to do the initial captions parse for a DVR-MS file. The way it’s currently implemented, this can cause problems for Desktop Search, which expects the IFilters it uses to be timely in their responses. If an IFilter takes too long to process a file (some number of minutes), Desktop Search does the right thing and assumes the IFilter has hung, aborting the indexing for that file. Additionally, the way I currently parse the file, I do all of the parsing in one fell swoop, which precludes Desktop Search from throttling the indexing; a robust IFilter would handle this much better, but, well, this is sample code. The IFilter will run very quickly if the captions have already been cached from a previous parse. Also note that the Desktop Search team recently released their own sample for how to implement managed IFilters.

Saving Captions When Converting To Other Formats

In my Fun with DVR-MS article, I demonstrated how it’s possible to use DirectShow to convert from DVR-MS files to other media formats such as WMV and WMA. However, those samples did not preserve the closed captions. And how could they; after all, WMV and WMA files don’t contain streams for captions, right? They do something even better. Both WMV and WMA files allow you to use the WM/Lyrics_Synchronised metadata header to store a collection of strings, each of which is associated with a particular time in the video file at which the string should be displayed. Sound familiar? Synchronized lyrics are visible in two different ways in Windows Media Player. The first, and most obvious, is through the synchronized lyrics editor that’s part of the Advanced Tag Editor in Media Player.



But these lyrics wouldn’t do any good if you couldn’t view them along with the media at the appropriate time. In fact, you can. If you enable captions/subtitles for a video (the option is available from the Play menu in Media Player), Media Player will show you the synchronized lyrics along with the video at the appropriate time. So, I’ve augmented the ConvertToWmv and ConvertToWma applications I provided in the Fun with DVR-MS article to extract the closed captions from the original DVR-MS file and to save them as synchronized lyrics into the metadata headers for the generated Windows Media files.


Summarizing Video Files

This one is admittedly a bit far fetched, but I still think the idea is neat and wanted to see how it would fair. Microsoft Word has the ability to provide automated summaries for documents. You specify how much the text in the document should be summarized, Word analyzes the textual content, and it provides a new document that is some percentage in size of the original text (25% by default, I believe). Wouldn’t it be neat if we could do the same thing for video files? I decided it’d be fun to use Word’s AutoSummarize feature to implement this for videos. First, I extract the captioning from a DVR-MS file. I then programmatically dump that textual content into a Word document and ask Word to summarize it for me. The summarized text is then mapped back to the original captions (in a slightly haphazard fashion, I admit) as parsed from the file in order to determine which captions should be kept as part of the summary. The RecComp class, as described in the Fun with DVR-MS article, is then used to create a video summary including the segments that contain the summary captions. Useful? Unsure. Cool? Yup, or at least I think so.

Other Ideas

At over 3500 words, this post didn’t end up being as short as I’d planned, but hey, the more the better I guess. There are so many neat things you can do with captions, I’m sure this only scratches the surface. Some additional ideas for things I’d implement if I had the time:

  • An add-in for Media Center that displays a list of captions for the current video and lets you jump to a caption. You can discover the recorded show that’s currently playing using code from my Time Travel with Media Center article.
  • An app that combines Desktop Search and my Search and View app, allowing you to search your whole disk for a particular phrase, show the video, and jump right to the phrase in the video.
  • A really powerful Tablet PC-based remote control for Media Center. An add-in in Media Center could expose through remoting not only the AddInHost, but also all of the captioning information. The Tablet could then expose an interface that allows you to navigate the show on your Media Center based on traditional navigation controls but also based on searching and selecting closed captions.
  • A speech-based navigation engine that buillds up a grammar based on the closed captions and lets you navigate the current show purely by speaking a line from the show.
  • A transcript generator. Grabs images from the video and includes them in a Word document along side the closed captions at the correct point within the document.
  • A Windows service that monitors for when new shows have been recorded and automatically starts the process of extracting the closed captions and saving them. This will then make it very fast for other applications to work with the captions, as they’ll already be parsed and available. Of course, in a sense this is one feature the IFilter provides in concert with Desktop Search.
  • In some circumstances, you can distinguish commercials from actual content based on the type and content of the closed captions... not that I'm suggesting anything.
  • A summary video generator that searches for keywords and uses IStreamBufferRecComp to generate a new summary video containing portions of the video with the specified keyword.

I’d love to hear what else you come up with and any feedback you might have (again, though, this is all unsupported, so while I’ll try to help where and when I can, I make no guarantees about anything). In the meantime, I hope this is helpful.

Happy programming!

-Steve

Published Saturday, September 17, 2005 12:51 AM by toub
Filed under: ,

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

Saturday, September 17, 2005 3:14 PM by Heath Stewart

# re: DVR-MS: Adventures in Closed Captioning

Wow! Very nice. I especially like the IFilter. You should clean it up a little (make it robust, as you mentioned) and post it on http://addins.msn.com/. I think that's a wonderful idea and certainly makes videos more discoverable since metadata contains little about the content of the video.
Sunday, September 18, 2005 12:41 AM by toub

# re: DVR-MS: Adventures in Closed Captioning

Thanks, Heath. Glad you like it! I do plan to rework the IFilter a bit when I have some more spare time; I'm constrained slightly by the interfaces exposed from sbe.dll, but it should be doable. In the meantime, the IFilter does work fairly well, so I hope it's useful to folks.
Wednesday, October 19, 2005 2:41 PM by Ryan Hirschey

# re: DVR-MS: Adventures in Closed Captioning

Stephen,

Your XPMCE tools (especially the metadata tag editor and the DVR-MS Editor) are simply awesome. Both have proven very useful in optimizing my Media Center experience. I certainly hope Bill and Steve are keeping you happy. We want you around writing this blog for a long time to come... :-)

One question I have on the DVR-MS Editor. After I edit a file to remove commercials, I notice the KB/second rate in the output file is less than the original. Is there anything that is "lost" as a result (closed captioning, audio/visual quality, etc.)? I have also noticed that the Sonic DVD writer seems to have trouble recognizing the output file if I try to burn it to a DVD, complaining of an encoding issue. Is there a workaround for this?
Monday, November 14, 2005 2:46 AM by Yakov

# re: DVR-MS: Adventures in Closed Captioning

hi, see if you can help me.
i'm looking for away to grab the closed caption data as string data from real time video stream. that mean i can get the text data of the closed caption when i'm waching video from my capture device.
any suggestion would be appriciate.
thanks
Wednesday, November 23, 2005 12:26 PM by Stuart

# re: DVR-MS: Adventures in Closed Captioning

I have been using the DVR-MS Editor, it's very good, however My question relates to the transcoding to wmv, is there any way to increase the quality of the wmv file? it seems to be set pretty low, 800mb dvr-ms = 18mb wmv, I have read though you r articles but I can't see any mention of increasing the quality of the wmv.

thanks
Wednesday, November 23, 2005 12:39 PM by Stuart

# re: DVR-MS: Adventures in Closed Captioning

oops, found your answer on another post

Sure, just specify a Windows Media Profile (.prx) as the second arg on the command line and that profile will be used instead of the poor-quality default. You can easily create profiles using the Windows Media Profile Editor that's included with the Windows Media Encoder, available for free on the Microsoft site.

excellent :)
Friday, January 06, 2006 3:01 PM by Alex Sirota

# re: DVR-MS: Adventures in Closed Captioning

What an awesome idea... Now what would be really interesting is to somehow start capturing the closed caption info and make it available in a peer to peer fashion so you could actually set favorites to record based on content rather than just by name.

The real power in this is that the metadata currently available for a show is not that complete... Plus the credits, if available in the closed caption, basically summarize the entirety of the show to the most complete level imaginable. After all apart from the video, the titles and audio are all that is left...

Once that is done automatically and in peer to peer fashion you could do things like:

- record certain types of commercials, provided they are CC'd

- record certain types of show based on keywords and other phrases

The notion of intelligent recording would be revolutionized by making CC info available as part of the digital stream.
Wednesday, February 08, 2006 1:58 PM by Aaron Stebner's WebLog

# Programmatic access to closed captioning data in Media Center

One of the folks I talked to at CES 2006 last week asked me about how to use Media Center extensibility...
Thursday, February 09, 2006 2:00 PM by Jonathan Rachlin

# re: DVR-MS: Adventures in Closed Captioning

Very interesting article.  Your listing of closed-captions is exactly what I've been looking for.  

However, I need to know -- I have a Toshiba Satellite A75 notebook (3.2 Ghz), but it does not include Windows Media Center.  What do I ultimately need in order to create the files for doing this -- to create the dvr-ms files?  Can I install appropriate capture devices on a laptop, and create the appropriate files with some readily available software, or do I need to buy a computer with Windows Media Center installed?  

Many thanks, and again, this ia a really cool application.

Jon Rachlin
Friday, February 10, 2006 3:12 PM by toub

# re: DVR-MS: Adventures in Closed Captioning

Jon, glad you liked the article.  DVR-MS files are created by Media Center, and as of right now, I know of no other system that saves recorded content as DVR-MS.  Note that Media Center will be included in some versions of Windows Vista.  As for capturing TV signals, you'll need a capture card of some sort, and companies like Hauppauge do make USB tuner devices, so you could certainly pick one of those up for your laptop.  All that said, what I described above could probably be accomplished for other file formats as well; I just based this on DVR-MS because I like the format and have a Media Center at home.
Thursday, March 02, 2006 5:22 PM by Service Station, by Aaron Skonnard

# Holy DVR-MS!

Sunday, March 19, 2006 1:22 PM by RHR

# MCE won't output TV's CC

I want TV or DVR-MS can output TV's cc but I don't want MCE's CC becuaes I not read small CC and no background, I would output CC available?

Sunday, March 19, 2006 1:24 PM by RHR

# DVR-MS copy BurnDVD, WMV, AVI, etc..

DVR-MS copy to BurnDVD, WMV, AVI, MEPG won't work CC,

Any idea?

Sunday, May 21, 2006 3:14 PM by Josh

# re: DVR-MS: Adventures in Closed Captioning

Hi! interesting stuff, there!
I have a tricky one for ya all: If I have website with an embedded WMP and want to enable the viewer to turn on and off his or hers cc without opening the WMP, how do I do That!?
Monday, May 22, 2006 4:37 PM by toub

# re: DVR-MS: Adventures in Closed Captioning

Josh, unfortunately I don't think it's currently possible to control that setting programmatically through the WMP API; there may be a way, and if you find one, I'd be interested in hearing about it.
Thursday, May 25, 2006 11:42 PM by Amber Lopez

# re: DVR-MS: Adventures in Closed Captioning

Steve,

I am not sure I am on the right page, but your article seemed interesting!  I just got a Lenovo 3000 C100.  I alos have Dishnetwork 625 DVR.  

I know there is a way to get my tv to recognize my laptop, and vice versa.  I also know that there is a way for me to download my recorded shows on my dvr to my laptop for me to view.

Could you either please help or direct me to the right direction?  I have googled my brains out.

Mind you I am not as sharp nor smart as therest of thee.

Thanks!
Amber
Tuesday, May 30, 2006 9:55 AM by Jon Rachlin

# re: DVR-MS: Adventures in Closed Captioning

I just bought a new Media Center notebook  (see above post), and have tried your program on Spanish tv shows.  It works very nicely, with one exception.


The extended characters of the EIA-708B don't show up in your parser, even though they show up in the captions on tv.  For instance, the word niño shows up as nio.  

I notice that in the NTSCClosedCaptionParser, you are only looking for the letters of the English alphabet: you have a line of code --

if (b >= 0x20 && b <= 0x7a)

Do you have any ideas about how to handle this?  
I tried changing the code to

if (b >= 0x20 && b <= 0xff)

but it didn't work.  Maybe I'm looking in the wrong place.


Again, thanks for a great article.  I bet you didn't think that one of its uses would be to improve one's Spanish.

Jon Rachlin
Wednesday, May 31, 2006 7:30 PM by toub

# re: DVR-MS: Adventures in Closed Captioning

Hi Jon- Glad you enjoyed the code and are finding it useful!  The code was really meant to be an approximation of 608b, and as such if you look at the spec and compare it to the code, you'll see that I've omitted some things.  For example, as you saw, I only pay attention to values <= 7a, since those pretty much map to their ASCII equivalents and thus I can get close to correct results with minimal results simply by casting the value to a Char.  If you look at the spec though, you'll see that the  is 0x7E, but it's not in ASCII, which means you won't get  by casting 0x7E to a Char, which is probably why this didn't work for you when you extended the comparison range.  You could try adding code to explicitly convert certain values into Chars and see if that helps.  In general though, as I said, I intended this to be enough of a prototype/proof-of-concept to get basic applications up and running, but it's definitely not (nor was it intended to be) a 100% compatible implementation of the specification.  Hope that helps!
Thursday, June 01, 2006 4:10 PM by Jonathan

# re: DVR-MS: Adventures in Closed Captioning

Interesting ideas.  I have an issue that seemed simple, but there are no viable solutions to it -- is there any way to take these extracted CCs and burn them onto DVDs with the video for use on a settop player.  I have run into many brick walls trying to research this topic, and was wondering if you had any insights as to how to address this.  This would be an immense asset to hard of hearing users that use MCE.

Thanks
Thursday, June 01, 2006 5:40 PM by toub

# re: DVR-MS: Adventures in Closed Captioning

It's probably possible using a DVD editing application that allows you to add captioning.  I believe commercial apps let you do this, though I've never tried, and I'm not sure if any have SDKs or object models against which you can program.  You could certainly extract the closed captions along with time codes, so if you found a program that let you burn them to DVD, you could output them in whatever format was necessary for the DVD app to load.
Friday, July 07, 2006 2:38 AM by Mike Lanza

# re: DVR-MS: Adventures in Closed Captioning

I want to hire someone to implement a simple custom system that would generate a text file with timecodes and captions, then upload these timecode/caption pairs into a database.  Also, we'd want some other stuff (auto-transcoding the video file, uploading the transcoded file, etc.), , but the cc generation is where I'm stuck right now.  See www.click.tv to see what we're driving at.

Does anyone have any ideas who could do this job quickly and efficiently?
Saturday, July 29, 2006 2:41 AM by masik

# re: DVR-MS: Adventures in Closed Captioning

Great article. I came across this from Green Button forum when I was directed to read this artichle for my question I had posted. I did not find answer to my question, which was while buring DVD of MCE recorded programs, CC data is not being written to DVD. In other words, DVDs created by ClickToDVD sw (from Sony on VAIO) of the MCE recorded TV shows, do not have CC function, even thought the CC exists in the recording on MCE. How would I know where to look and debug this problem? Any help form you is appreciated?

Thanks in advance.
Saturday, July 29, 2006 10:09 AM by toub

# re: DVR-MS: Adventures in Closed Captioning

Hi Masik-

It's not a problem that requires debugging; the feature you're looking just wasn't implemented in the program you're using (I'm not aware of any programs that implement it).  You can probably get the functionality you require by using a professional DVD creation application, many of which allow for the creation of subtitles, but most of those, even if they accept DVR-MS files as input, probably wouldn't extract the CC information from the DVR-MS and use it for the DVD subtitle track; you'd probably need to write your own tool to extract the CC data into a format consumable by the DVD application.  A good place to start, then, would be with the sample code I've provided here.

Good luck.
Sunday, September 17, 2006 11:22 AM by Jesper

# re: DVR-MS: Adventures in Closed Captioning

Hi, very nice site. I have here a dvd that includes closed captions. These are shown when playing in media center 2005. Is there a way to extract the captions to .srt or .sub format? Maybe a hint on how to do it?  
Monday, September 25, 2006 7:02 PM by Mircea

# re: DVR-MS: Adventures in Closed Captioning

Great work. Every article of yours brings so much to the table.

I have though a problem situated before the CC stream gets into the dvrms file and because of this I can’t use the code in your examples. Hoping that you might have that kind of knowledge here's what's happening. While Live TV, the CC stream misses letters or words. This happens, for every line and it's sometimes worse, sometimes not so worse. Only once, recently, for one show I couldn't believe, CC was flawless, but it was just one time. In the recorded file the situation is the same so, it's not a matter of displaying them wrongly. A lot of people told me that Hauppauge (the brand I own) makes bad drivers and this causes the problem. I don’t think so, because using the same hardware configuration (where MCE fails on CC), I tried another PVR-TV application (Chris TV) which displays 24/7 flawless CC. This leads me to believe that's something in particular with the way MCE reads or interprets the CC from the cable signal. Now, believe me I searched hundreds of websites and I lost my hope to find an answer as it’s a long time now since I’m doing this. Any hint or recommendation of who or where to ask further would be welcomed.

Regards.
Tuesday, September 26, 2006 8:39 PM by toub

# re: DVR-MS: Adventures in Closed Captioning

Mircea, I've never heard of this problem before, so unfortunately I don't have a good answer for you.  I did forward your question to folks on the MCE team, and someone there might have a better idea of what's happening.  Out of curiosity, what version of MCE are you using?  If you upgrade to Vista (currently at RC1), do you have the same problem?
Tuesday, October 10, 2006 6:18 PM by TYC

# re: DVR-MS: Adventures in Closed Captioning

Hey, I just found these tools to convert DVr-ms closed caption into .scc files, pretty cool.  Good article BTW.

http://www.geocities.com/mcpoodle43/SCC_TOOLS/DOCS/SCC_TOOLS.HTML#dvr2scc

Tuesday, October 10, 2006 8:52 PM by Mircea

# re: DVR-MS: Adventures in Closed Captioning

Stephen, sorry for taking so long.

I didn't try it on Vista yet  as it's a "production" machine and I need to make some preparations before.

Oh by the one that I'm using it's a MCE 2005 and updated on an automatic fashion.

I was thinking of calling MCE support but as I worked myself in Perf I know the many possible scenarios a ticket can go through. Maybe by e-mail ... anyway.

Thanks for the answer though, as I know you would've helped if you can. I'll take this as one of my longest cases :( and I don't care about the survey as I'm my own customer :).

Please, keep up the good work.

Wednesday, October 11, 2006 7:53 AM by TYC

# re: DVR-MS: Adventures in Closed Captioning

I'm curious too, how to convert the captions from ExtractCloseCaptions.exe to an .ssa or .srt subtitle format.  I'll do the wmv as a last resort but I'd prefer just to use one of those subtitle formats

"

I have here a dvd that includes closed captions. These are shown when playing in media center 2005. Is there a way to extract the captions to .srt or .sub format? Maybe a hint on how to do it?  

"

Wednesday, October 11, 2006 9:38 AM by Stephen Toub

# re: DVR-MS: Adventures in Closed Captioning

ExtractCloseCaptions is just a sample wrapper around my underlying sample library for extracting close captions from NTSC DVR-MS files.  If you look at the library, it gives you back a .NET collection of the captions, and ExtractCloseCaptions just iterates through them and writes them to the console.  You can write your own app to iterate through them and do whatever you want with them, including writing them to whatever format you desire.

Thursday, October 12, 2006 8:00 AM by TYC

# re: DVR-MS: Adventures in Closed Captioning

Thanks for the quick reply Stephen, I'll try and figure out how to do this!

Saturday, October 14, 2006 1:31 PM by Jesper

# re: DVR-MS: Adventures in Closed Captioning

Does somebody know if there is a collection or object holding the closed captions when they are being shown during playing in MCE2005? If that is the case, i would you like to use it in a program which i code myself to output the closed captions from a dvd to a file.

Friday, November 03, 2006 6:43 AM by Murali

# re: DVR-MS: Adventures in Closed Captioning

Hi Stephen,

I am trying to extract CC text from TV Tuner

(ATI TV Wonder USB 2.0). Not succeeded in

setting up the filter graph with ATI provided filters.

What is the minimum set of filters required

to extract CC text? I am not interested in the

video as the software I am building has to

analyze CC text alone.

Thanks a ton in advance,

Murali

Friday, November 03, 2006 10:43 AM by toub

# re: DVR-MS: Adventures in Closed Captioning

I've never used an ATI TV Wonder USB, and I unfortunately don't know anything about the drivers and filters assocated it.  Regardless, best of luck with your project.

Thursday, November 09, 2006 4:55 PM by Nick

# re: DVR-MS: Adventures in Closed Captioning

Hi Stephen,

So I'm using converttowmv to convert from .dvr-ms files to .wmv files in Vista RC1, but the output video looks very strange. It basically has a greenish tinge and it looks like part of the video is reflected and distorted in the lower part of the frame. Using the standard .prx or another custom one that I made doesn't seem to make a difference. Any ideas/suggestions for what might be going on? I thought that it might have to do with the frame size, which is why i tried the custom .prx that didn't resize the frame, but that didn't do it.

Thanks,

Nick

Sunday, November 19, 2006 11:53 PM by toub

# re: DVR-MS: Adventures in Closed Captioning

To be honest, I haven't tried converttowmv on Vista yet, though I plan to shortly.  I'll let you know if I run into a similar issue, and if I do, if I end up with a solution.

Tuesday, November 28, 2006 8:39 PM by jeff

# re: DVR-MS: srt subtitles

Wondering if anyone out there could make this so extractclosedcaptions outputs to srt format...see (http://forum.videohelp.com/viewtopic.php?t=314307) for an example. I am not a programmer otherwise I am sure its not too difficult....raakjoer_AT_gmail.com

Leave a Comment

(required)
required
(required)