MFormats SDK: displaying closed captions on the preview

MCCDisplay is a special plugin that makes it possible to use the Closed Captions lib together with MFormats SDK. The plugin receives ANC data from the incoming frame and creates a new frame with closed captions. This way the user can access both the original frame and the frame with CC overlay. The frame created by the plugin can be used to preview the captions.


To use MCCDisplay with MFormats SDK:


  • Add a link (reference) to the library containing the plugin into your project:




  • Create the plugin object:


m_objCCDisplay = new MCCDisplayClass();

 

  • Process the incoming frame with the ProcessFrame method:


// Original frame received from the source. It contains CC data that is not visible on a preview.
MFFrame pFrame;
int nFramesRes;

// New frame that will contain the CC overlaid data.
MFFrame pFrameOut = null;

// Process the original frame with CC Display object.
((MFORMATSLib.IMFProcess)m_objCCDisplay).ProcessFrame(pFrame, out pFrameOut, out nFramesRes, "");

// Don't forget to release the original frame from the memory if you don't need it anymore.
if (pFrameOut != null)
{
	Marshal.ReleaseComObject(pFrame);
}

// Use the result frame (pFrameOut) as you need: send to the Preview, output to capture card, write to file, etc.


You can check the plugin using the File Playback sample: