Ancillary (ANC) data is data that travels in the SDI signal outside the visible picture: closed captions, Teletext, SCTE-104 ad triggers, AFD, timecode and any custom data. Each piece of data is an ANC packet (SMPTE ST 291-1) that sits on a particular line of the vertical blanking interval (VANC).
The SDK represents ANC packets as frame strings named ANC.Line.N, where N is the line
number. The same format is used everywhere:
- SDI capture devices put the received packets on the frame;
- SDI renderers send the packets they find on the frame;
- the MXF reader and writer use it for the SMPTE ST 436 data track (see SMPTE ST 436 ancillary data in MXF files).
So you can pass ANC data from input to output unchanged, record it, or create your own packets.
Captions and SCTE-104 have their own, easier interfaces (C608/C708 and
SCTE-104); use ANC.Line.N for everything else or when you need the exact packets.
Format
The key holds the line number, and the value holds one or more <packet> elements:
frame.MFStrSet("ANC.Line.10",
"<packet DID='0x52' SDID='0x01'>0102030405</packet>" +
"<packet DID='0x53' SDID='0x02'>A0B0C0</packet>");
| Part | Meaning |
|---|---|
ANC.Line.N |
Line number in the numbering of the video standard, for example 9–20 in 1080i/1080p, and 571–583 for the second field of 1080i. The line where a packet type usually travels is defined by its standard (for example, captions in HD usually use line 9, SCTE-104 line 12 or 13). |
DID |
Data Identifier: the type of packet. Decimal (65) or hexadecimal with the 0x prefix (0x41). |
SDID |
Secondary Data Identifier, for Type 2 packets (DID 0x01–0x7F). |
DBN |
Data Block Number, for Type 1 packets (DID 0x80–0xFF), instead of SDID. Optional. |
| Element text | User data words (the payload) as hexadecimal bytes, two digits per byte, without separators. Do not include the ancillary data flag, DID, SDID, data count or checksum: the SDK adds them. A Type 2 packet holds at most 255 bytes. |
Strings produced by the SDK wrap the packets in a root element with the name of the key and use decimal attribute values, for example:
<ANC.Line.9><packet DID="97" SDID="1">9669...</packet></ANC.Line.9>
Blackmagic, Bluefish444 and the MXF writer accept both forms, with or without the root element. DELTACAST
outputs only bare <packet> elements, so use the form without the root element when you
build packets yourself. If you add a packet to a line that
already has packets, read the existing value first and append your packet; MFStrSet replaces
the whole line.
Which DID and SDID to use
Some well-known packet types:
| Data | DID | SDID | Standard |
|---|---|---|---|
| AFD and bar data | 0x41 | 0x05 | SMPTE ST 2016-3 |
| SCTE-104 message | 0x41 | 0x07 | SMPTE ST 2010 |
| OP-47 Teletext (SDP) | 0x43 | 0x02 | RDD 8 (OP-47) |
| OP-47 Teletext (multipacket) | 0x43 | 0x03 | RDD 8 (OP-47) |
| Caption Distribution Packet (CEA-708) | 0x61 | 0x01 | SMPTE ST 334-1 |
| CEA-608 byte pair | 0x61 | 0x02 | SMPTE ST 334-1 |
| User-defined, Type 2 | 0x50–0x5F | any | SMPTE ST 291-1 |
| User-defined, Type 1 | 0xC0–0xCF | — (DBN) | SMPTE ST 291-1 |
For your own data, use the user-defined ranges, so that other equipment does not mistake your packets for a known type.
Large Type 1 payloads
A single ANC packet carries at most 255 bytes. On Blackmagic output, a Type 1 payload longer than 255
bytes is split into several packets with consecutive DBN values, starting from 1 or from the
DBN you specify. To continue a payload on another line, give the first packet of that line
the next DBN:
// Line 10: 1020 bytes, sent as 4 packets with DBN 1..4
frame.MFStrSet("ANC.Line.10", "<packet DID='0xC0'>" + first1020BytesHex + "</packet>");
// Line 11: the rest, numbering continues from DBN 5
frame.MFStrSet("ANC.Line.11", "<packet DID='0xC0' DBN='5'>" + restHex + "</packet>");
Sending packets to an SDI output
Set ANC.Line.N on each frame before you send it to the renderer. The packets are sent with
that frame only; to send a packet on every frame, set it on every frame.
MFormats
MFRendererClass renderer = new MFRendererClass();
renderer.PropsSet("output.anc_packets", "true"); // on by default for Blackmagic, off for Bluefish
renderer.DeviceSet(eMFDeviceType.eMFDT_Video, deviceIndex, "");
while (running)
{
reader.SourceFrameGet(-1, out MFFrame frame, "");
frame.MFStrSet("ANC.Line.10", "<packet DID='0x52' SDID='0x01'>0102030405</packet>");
renderer.ReceiverFramePut(frame, -1, "");
Marshal.ReleaseComObject(frame);
}
MPlatform
Add the packets in the synchronous OnFrameSafe event of the source object that feeds the
renderer (see Frame metadata: MFStrGet, MFStrSet, MFDataGet and MFDataSet). Renderer settings
go to the device with the device:: prefix after DeviceSet:
m_objRenderer.DeviceSet("renderer", deviceName, "");
m_objRenderer.PropsSet("device::output.anc_packets", "true");
m_objFile.PropsSet("object::on_frame.sync", "true");
m_objFile.PropsSet("object::on_frame.data", "true");
m_objFile.OnFrameSafe += (string channelId, object pFrame) =>
{
((IMFFrame)pFrame).MFStrSet("ANC.Line.10", "<packet DID='0x52' SDID='0x01'>0102030405</packet>");
Marshal.ReleaseComObject(pFrame);
};
Receiving packets from an SDI input
Enable ANC capture on the input device (it is off by default on Blackmagic and AJA), then read
ANC.Line.N from the captured frames. The device settings are described in
Configuring SDI devices for ANC, captions, AFD and SCTE-104.
MFLiveClass live = new MFLiveClass();
live.PropsSet("vanc.capture_anc", "true"); // Blackmagic; AJA uses capture_vanc
live.DeviceSet(eMFDeviceType.eMFDT_Video, deviceIndex, "");
live.SourceFrameGet(-1, out MFFrame frame, "");
frame.MFStrGet("ANC.Line.12", out string line12); // null if the line has no packets
Marshal.ReleaseComObject(frame);
You don't know in advance on which lines packets arrive. To find them, enumerate the frame strings and take
the names that start with ANC.Line.:
for (int i = 0; ; i++)
{
frame.MFStrGetByIndex(i, out string name, out string value);
if (name == null)
break; // no more strings
if (name.StartsWith("ANC.Line."))
Console.WriteLine($"{name}: {value}");
}
Pass-through
Frames from an SDI input keep their ANC.Line.N strings, so when you send such a frame to an SDI
output with output.anc_packets enabled, the packets are sent again on the same lines.
The SDK does not recalculate line numbers when the video format changes: if the output format differs
from the input, make sure the lines exist in the output format, or move the packets yourself.
Captions are output from C608/C708 on the caption line as well. If the same frame also
carries the caption packets as ANC.Line.N on the same line, the captions are sent twice.
When you pass through both, remove the caption packets from ANC.Line.N or disable one of the paths.
Limitations
- ANC packets go to SDI outputs and to MXF files (SMPTE ST 436). Other containers and IP outputs, including SMPTE ST 2110-40, are not supported.
- Not every device outputs custom
ANC.Line.Npackets; see the device table in Configuring SDI devices. - Lines of the active picture cannot carry ANC packets.
Still have questions?
Tell us what didn’t work or what you’d like clarified.