Common Information
MFormats and MPlatform SDKs support SDI board-powered Internal and External keying functionality. For internal keying mode, our SDKs superimpose the graphics over an incoming signal. In external keying mode, our SDKs generate both fill and key signals and the keying is made by an external keyer.
By overlaying or splitting graphics using SDI card hardware, you can save a huge amount of computing resources on your system. This process itself is not complicated, but it's needed to know a couple of specific things.
The following articles contain the tables with the SDI cards that support keying:
- Magewell supported models
- Bluefish supported models
- Blackmagic Design supported models
- Stream Labs supported models
- Deltacast supported models
- AJA Video Systems supported models
In this article, we will take a closer look at how to work with keying using a Blackmagic DeckLink Duo 2 SDI card as an example.
Firstly, for both the keying modes is needed to create a string registry key which is named "keying.premultiply_fill" and set it as "true" → Computer\HKEY_CURRENT_USER\SOFTWARE\Medialooks\MFormats\MFRenderer\BMD → keying.premultiply_fill = "true".
Secondly, it's needed to map the Blackmagic DeckLink Duo 2 connectors in the following way:
When these preparations are done, connecting SDI inputs, outputs of the board and adding some code are left. We have in-built samples for MFormats ans MPlatform SDKs which can be used for quick check the keying functionality. They are located here:
- Sample Renderer for MFormats SDK → "C:\Program Files (x86)\Medialooks\MFormats SDK\Samples\C#\Sample Renderer\bin\x64\Debug\Sample Renderer.exe"
- Keying Sample for MPlatform SDK → "C:\Program Files (x86)\Medialooks\MPlatform SDK\Samples Basic\C#\Keying Sample\bin\x64\Debug\Keying Sample.exe"
To successfully overlay or split by channels a video or image with transparency using an SDI board, the video, or image itself must contain transparency and the pixel format MUST be set to ARGB32.
MFormats SDK:
M_AV_PROPS m_AV_PROPS = new M_AV_PROPS();
m_AV_PROPS.vidProps.eVideoFormat = eMVideoFormat.eMVF_Custom;
m_AV_PROPS.vidProps.fccType = eMFCC.eMFCC_ARGB32;
// ...
m_objReader.SourceFrameConvertedGet(ref m_AV_PROPS, 0, out MFFrame pFrame, "");
MPlatform SDK:
M_VID_PROPS m_VID_PROPS = new M_VID_PROPS();
m_VID_PROPS.eVideoFormat = eMVideoFormat.eMVF_Custom;
m_VID_PROPS.fccType = eMFCC.eMFCC_ARGB32;
m_objFile.FormatVideoSet(eMFormatType.eMFT_Convert, ref m_VID_PROPS);
Internal Keying
Internal keying allows you to superimpose the graphics over an incoming signal (to overlay video with an alpha channel on top of another video received by an SDI card). And as stated earlier, since graphics overlay performs at the hardware level by the SDI card, no additional computing resources of your system are consumed.
The following image demonstrates how internal keying works:
MFormats SDK:
// Create and initialize a new MFRendererClass instance:
MFRendererClass m_objRenderer = new MFRendererClass();
//Configure the new MFRendererClass instance and set it to the 1st available:
m_objRenderer.DeviceSet(eMFDeviceType.eMFDT_Video, 0, "");
// Get amount of keying options for the device:
m_objRenderer.PropsOptionGetCount("keying", out Int32 nCount);
for (Int32 i = 0; i < nCount; i++)
{
try
{
m_objRenderer.PropsOptionGetByIndex("keying", i, out String strNameKeying, out _);
if (strNameKeying == "internal")
{
m_objRenderer.PropsOptionSetByIndex("keying", i);
break;
}
}
catch {}
}
// Output the frame to the device:
m_objRenderer.ReceiverFramePut(frame, -1, "");
MPlatform SDK:
// Create and initialize a new MRendererClass instance:
MRendererClass m_objRenderer = new MRendererClass();
// Set required device name for rendering:
m_objRenderer.DeviceSet("renderer", "DeckLink Duo 2", "");
// Set internal keying feature:
m_objRendererer.DeviceSet("renderer::keying", "internal", "");
// Start output:
m_objRendererer.ObjectStart(m_objFile);
External Keying
External keying allows you to split a video with an alpha channel into fill (the video itself without alpha) and key (mask). Resulting fill and key signals can be used for further keying, made by an external keyer. And as stated earlier, since graphics overlay performs at the hardware level by the SDI card, no additional computing resources of your system are consumed.
The following image demonstrates how external keying works:
MFormats SDK:
// Create and initialize a new MFRendererClass instance:
MFRendererClass m_objRenderer = new MFRendererClass();
//Configure the new MFRendererClass instance and set it to the 1st available:
m_objRenderer.DeviceSet(eMFDeviceType.eMFDT_Video, 0, "");
// Get amount of keying options for the device:
m_objRenderer.PropsOptionGetCount("keying", out Int32 nCount);
for (Int32 i = 0; i < nCount; i++)
{
try
{
m_objRenderer.PropsOptionGetByIndex("keying", i, out String strNameKeying, out _);
if (strNameKeying == "external")
{
m_objRenderer.PropsOptionSetByIndex("keying", i);
break;
}
}
catch {}
}
// Output the frame to the device:
m_objRenderer.ReceiverFramePut(frame, -1, "");
MPlatform SDK:
// Create and initialize a new MRendererClass instance:
MRendererClass m_objRenderer = new MRendererClass();
// Set required device name for rendering:
m_objRenderer.DeviceSet("renderer", "DeckLink Duo 2", "");
// Set internal keying feature:
m_objRendererer.DeviceSet("renderer::keying", "external", "");
// Start output:
m_objRendererer.ObjectStart(m_objFile);