MCCDisplay is a plugin that draws captions and subtitles over the video. Use it to preview what a viewer would see, to check captions on a monitoring output, or to burn captions into the picture. It is available in both MFormats and MPlatform and can draw:
- CEA-608 captions (channels CC1–CC4);
- CEA-708 captions (services 1–63);
- SRT and ASS subtitles decoded by the reader, with full Unicode (for example, Cyrillic);
- OP-47 Teletext pages (see OP-47 Teletext subtitles in ANC);
- XDS information: program name and V-Chip rating (see XDS: program name and V-Chip rating).
MCCDisplay requires a license with the Closed Captions option.
MPlatform
Add MCCDisplay as a plugin to the source object. The source sends its frames through the plugin:
using MPLATFORMLib;
var ccDisplay = new MCCDisplayClass();
ccDisplay.PropsSet("cc_type", "608");
m_objFile.PluginsAdd(ccDisplay, 0); // or m_objPlaylist, m_objLive
The drawn captions are part of the video from this object onward: the preview, renderers and writers connected to it
all receive the video with captions. Keep a reference to the plugin while it is attached. When finished, remove it
with PluginsRemove(ccDisplay) and release it.
MFormats
Pass each frame through ProcessFrame and send the returned frame on:
using MFORMATSLib;
var ccDisplay = new MCCDisplayClass();
ccDisplay.PropsSet("cc_type", "608");
MFFrame sourceFrame = null;
MFFrame outputFrame = null;
try
{
reader.SourceFrameGet(-1, out sourceFrame, "");
ccDisplay.ProcessFrame(sourceFrame, out outputFrame, out int framesRest, "");
preview.ReceiverFramePut(outputFrame, -1, "");
}
finally
{
if (outputFrame != null)
Marshal.ReleaseComObject(outputFrame);
if (sourceFrame != null)
Marshal.ReleaseComObject(sourceFrame);
}
Send outputFrame, not the source frame: only the returned frame has the captions drawn. Create the plugin once
and use it for all frames of a source, because captions are built up over many frames.
Choosing what to draw
MCCDisplay decides on every frame what to draw:
- With
cc_type=teletext: the OP-47 Teletext page selected on the reader or capture device. - Otherwise, with
subtitle_text=true(default) and SRT/ASS text on the frame: that text. - Otherwise: CEA-608 or CEA-708 captions, as set in
cc_type.
SRT and ASS subtitles
Select the subtitle track on the reader: subtitle_track on MFReader, file::subtitle_track on MFile.
The value is a zero-based track index (0 is the first subtitle track), and -1 (default) turns subtitle decoding
off. The number of tracks is in info::subtitle_tracks (file::info::subtitle_tracks).
// MFormats
reader.ReaderOpen(path, "subtitle_track=0");
// MPlatform
m_objFile.PropsSet("file::subtitle_track", "0");
The text keeps its Unicode characters; ASS styling is not applied, use the appearance properties of MCCDisplay instead.
Between subtitles the screen stays clear. The SDK also converts the same text to CEA-608 in C608, but that
conversion supports basic Latin characters only.
To show the CEA-608/708 captions of a file that also has a selected text subtitle track, set subtitle_text to false.
Properties
Set the properties on the MCCDisplay object with PropsSet, without prefixes. They can be changed while
frames are processed. Initial values can also be stored in the registry under
HKEY_CURRENT_USER\SOFTWARE\Medialooks\MCCDisplay; values set with PropsSet take precedence.
Selection
| Property | Default | Meaning |
|---|---|---|
show_subtitles |
true | Draws captions, subtitles and XDS. false hides the overlay; captions are still decoded and XDS is still reported. |
cc_type |
608 |
608, 708 or teletext. |
subtitle_text |
true | Prefers SRT/ASS text over CEA-608/708. |
channel |
1 | CEA-608 channel, 1–4. |
cc_service |
1 | CEA-708 service, 1–63. 0 draws all services (legacy mode). |
cc_track |
empty | CEA-708 input: ATSC for GA94 data, CDP for C708. Empty: whatever is available. |
cc_codepage |
0 | Character encoding of CEA-708 P16 characters, see below. |
xds_duration |
-1 | How long XDS information is kept, in seconds. -1: without limit, 0: XDS off. |
reset |
— | Set to true to clear all caption, XDS and Teletext state on the next frame. Useful after a seek or a source change. |
Appearance
| Property | Default | Meaning |
|---|---|---|
face |
Consolas | Font. Choose an installed font that contains the characters you need. |
color |
white | Text color: a name or a hexadecimal ARGB value. |
bg-color |
empty | Background color behind the text. |
outline, outline-color
|
not set | Text outline width (in 1/240 of the text area height) and color. |
cc_style |
empty | Extra text formatting parameters for captions and subtitles, for example align='center' vert-align='top'. |
xds_style |
empty | Text formatting parameters for XDS information. |
SRT/ASS text is centered at the bottom, inside a safe area of 7% from each edge. To move it to the top:
ccDisplay.PropsSet("cc_style", "align='center' vert-align='top'"). CEA-608/708 captions use the positions
given in the caption data.
Character encoding of CEA-708
CEA-708 can carry 16-bit characters (P16 code). Their encoding is not stored in the caption data itself, so MCCDisplay
needs cc_codepage:
-
0(default): UTF-16BE. For a Korean service, the encoding is taken from the CDP service information: withkorean_code=0it is code page 949 (KS X 1001), withkorean_code=1UTF-16BE. - Any other value: a Windows code page used for all P16 characters, for example
932(Japanese Shift-JIS),936(Simplified Chinese),949(Korean),950(Traditional Chinese Big5).
The code page must convert two bytes into one character. Single-byte code pages such as 1251 do not work for P16.
cc_codepage does not affect CEA-608 or SRT/ASS text.
ccDisplay.PropsSet("subtitle_text", "false");
ccDisplay.PropsSet("cc_type", "708");
ccDisplay.PropsSet("cc_service", "1");
ccDisplay.PropsSet("cc_codepage", "949");
Still have questions?
Tell us what didn’t work or what you’d like clarified.