MXF files from playout and ingest servers often keep the SCTE-104 messages of the SDI signal in the SMPTE ST 436 ancillary data track. The SDK reads them with the other ANC data of the file and can write them back. For the track in general, see SMPTE ST 436 ancillary data in MXF files.
Reading
When MFReader or MFile reads an MXF file with an ST 436 track, each SCTE-104 packet (DID 0x41, SDID 0x07) is parsed and the
XML is put on its frame under SCTE-104. The format is the same as for SDI inputs, see
SCTE-104 on SDI: receiving and sending. The raw packet stays in ANC.Line.N.
MFormats
MFReaderClass reader = new MFReaderClass();
reader.ReaderOpen(@"C:\media\program.mxf", "");
while (true)
{
reader.SourceFrameGet(-1, out MFFrame frame, "");
if (frame == null)
break;
frame.MFStrGet("SCTE-104", out string message);
if (!string.IsNullOrEmpty(message))
{
frame.MFTimeGet(out M_TIME time);
double seconds = time.rtStartTime / 10000000.0;
Console.WriteLine($"{seconds:F3}: {message}");
}
Marshal.ReleaseComObject(frame);
}
reader.ReaderClose();
Marshal.ReleaseComObject(reader);
Read the file frame by frame from the beginning and check every frame. Messages can be anywhere in the file, and a frame without
a message returns null.
MPlatform
MFile raises the SCTE-104 event with the XML in the event parameter when a frame with a message is played:
m_objFile.PropsSet("object::on_event.sync", "true");
m_objFile.OnEvent += (string channelId, string eventName, string eventParam, object eventObject) =>
{
if (eventName == "SCTE-104")
HandleScte104(eventParam);
if (eventObject != null)
Marshal.ReleaseComObject(eventObject);
};
Things to know
-
SCTE-104holds one message per frame. If a frame has several, read all of them fromANC.Line.N. - Messages split over several packets are not parsed. Packets that cannot be parsed are skipped and a warning is logged; the raw packet is still in
ANC.Line.N. - For exact frame positions, read the file sequentially. After a seek, the first frames can carry the packets of earlier frames.
Playing the file to SDI
Frames from the file carry both the raw packet (ANC.Line.N) and the XML (SCTE-104). An SDI renderer that outputs
ANC.Line.N sends the original packet on its original line. The XML is not sent a second time, because it has no
SCTE104 root.
Writing to MXF
The MXF writer stores ANC.Line.N only (with mxf.anc_write='true'). SCTE-104 packets received from SDI or read from
another MXF file are already there. The SCTE-104 XML string is not converted into a packet: to add your own message, put the packet
bytes into ANC.Line.N with DID 0x41 and SDID 0x07. See the example in
SMPTE ST 436 ancillary data in MXF files.
Still have questions?
Tell us what didn’t work or what you’d like clarified.