Saturday, July 5, 2008

ATSC closed captioning under Kaffeine

Spent a good portion of last night reading about the various specs for closed captioning under ATSC (a/65, a/53, EIA-608, EIA-708). Pretty interesting stuff.

There are actually two separate versions of CC info sent in digital television, the first being the old fashioned "line 21" closed captioning with a single font, limited to Latin characters, and little control over how it is rendered (originally used for analog NTSC). The newer version of the protocol, which is targeted at digital, is much more advanced in that it supports eight fonts, different font colors/backgrounds, UNICODE characters, and control over where it is rendered on screen.

It's an area that I still needed to get working under Kaffeine.

Unfortunately both EIA-608 and EIA-708 are specifications that have to be paid for (a little over $100 each). It's annoying when a FCC mandated standard isn't freely available.

After digging into the code, it turns up though that Kaffeine relies on Xine to do the subtitle parsing and rendering (Kaffeine just lets you pick whether to turn it on/off and which stream to view). This is good in the sense that any work I do will benefit other applications that use libxine, but it's bad because it's another project I have to figure out how to build from source, and it appears I have already broken my Ubuntu box trying to compile it.

On the upside, there is already partial support for both EIA-608 and EIA-708 in libxine because it's used for DVD playback. So in theory I just have to get xine to detect the presence of CC from the PMT block. Once I do this, Kaffeine should "just work" without any changes. If this works out, I won't have to buy the EIA specs at all.

Why the hell did the ATSC bury the CC data in the video stream, instead of separating it out into another MPEG program stream like DVB does?

On a sidenote, debugging Kaffeine is a bitch:
  • I don't know the ins/outs of libtool so I had to "make install" to get debug libraries
  • I ran around in circles for half an hour only to realize my debug libraries weren't being used. I was running the kaffeine binary out of my working directory, but it was using the libraries that shipped with Ubuntu
  • Kaffeine forks at startup so I have to run it in one window and then attach to the running pid ("--sync" doesn't appear to work)
  • KDE Debug (kdbg) appears to be crap.
  • I need a new office chair for my desk because my back is bothering me from using what used to be one of Gran's kitchen chair's.