This will extract the captions from the recording that starts at 2:00 PM on May 30, 2009, recorded on channel 1020 (probably channel 20 of source 1). This script may not work with older versions of MythTV, prior to the introduction of storage groups. You may have to modify the MySQL username, password, or database name if you are not using default values, and you may have to modify the PATH variable if the mysql or ccextractor binaries are not in that set.

This will extract the captions from the recording that starts at 2:00 PM on May 30, 2009, recorded on channel 1020 (probably channel 20 of source 1). This script may not work with older versions of MythTV, prior to the introduction of storage groups. You may have to modify the MySQL username, password, or database name if you are not using default values, and you may have to modify the PATH variable if the mysql or ccextractor binaries are not in that set.

Viewing closed captions when present in a recording

You also need to configure the frontend to set whether you want Closed Captioning to turn on whenever you select a channel. Regardless of your choice for the frontend, you can toggle Closed Captioning on and off by using the keyboard. The default key is T.

If captions don't appear for you, it may be because the player (from your video profile) is not supporting playback for the kind of captions in the video. Try switching to a different video profile (one that uses VDPAU or ffmepg, for example) to improve the chances of captions working.

Extracting closed captions to a .srt file

If you have a recording that contains closed caption data, and a cutlist, you can extract the time-corrected .srt data. You will need CCExtractor. Install the following script:

This will extract the captions from the recording that starts at 2:00 PM on May 30, 2009, recorded on channel 1020 (probably channel 20 of source 1). This script may not work with older versions of MythTV, prior to the introduction of storage groups. You may have to modify the MySQL username, password, or database name if you are not using default values, and you may have to modify the PATH variable if the mysql or ccextractor binaries are not in that set.

Viewing transcoded recordings with captions in mplayer

The mplayer program automatically loads .srt files that match the media basename. That is, if you are watching Babylon5.mpg, it will automatically load captions from Babylon5.srt in the same directory. By using the script shown above after setting the cutlist, but before transcoding, you can produce a pair of files that will allow you to view the transcoded, commercial-cut recording with optional closed captions.

Creating DVDs with captions present

It should be possible to use the script above to insert captions into DVDs created with mytharchive. These captions will be in their own video stream, so can be turned on and off, they are not overlaid directly on the original video stream. The mytharchive script will have to be modified to call the caption-extracting script above, and put the .srt file into the appropriate directory. Then, after the .mpg file has been extracted and optionally requantized, it should create a file similar to this, call it 'b5.xml':

The width and height are for NTSC 4x3 video, they will have to be changed appropriately for other formats. Then, the .mpg file should be augmented with the captions using the command:

spumux -s0 b5.xml < origfile.mpg > with-captions.mpg

This will result in the creation of DVDs with a caption track associated with each .mpg that went into it, which can be toggled by the usual CC selection mechanism on the DVD playback system in use. I have tested the creation of .mpg files with the embedded captioning track, but have not yet tried to change the mytharchive python script to write these to a DVD filesystem.