This tutorial sends a playing file to an output device with MRenderer: an SDI card, an NDI output or another
supported renderer. It uses the file object from MPlatform 1: Playing a file; a live
source from MPlatform 2: Capturing from a device works the same way.
Choose the device, the output and the format
private readonly MRendererClass m_renderer = new MRendererClass();
private void FillRenderers()
{
m_renderer.DeviceGetCount(0, "renderer", out int count);
for (int i = 0; i < count; i++)
{
m_renderer.DeviceGetByIndex(0, "renderer", i, out string name, out string description);
rendererBox.Items.Add(name);
}
}
private void RendererBox_SelectedIndexChanged(object sender, EventArgs e)
{
m_renderer.DeviceSet("renderer", (string)rendererBox.SelectedItem, "");
// Output lines of the device, for example the SDI connectors of a card
outputBox.Items.Clear();
m_renderer.DeviceGetCount(0, "renderer::line-out", out int lines);
for (int i = 0; i < lines; i++)
{
m_renderer.DeviceGetByIndex(0, "renderer::line-out", i, out string line, out string description);
outputBox.Items.Add(line);
}
// Video formats of the output
formatBox.Items.Clear();
m_renderer.FormatVideoGetCount(eMFormatType.eMFT_Convert, out int formats);
for (int i = 0; i < formats; i++)
{
m_renderer.FormatVideoGetByIndex(eMFormatType.eMFT_Convert, i, out M_VID_PROPS props, out string formatName);
formatBox.Items.Add(formatName);
}
}
private void OutputBox_SelectedIndexChanged(object sender, EventArgs e)
{
m_renderer.DeviceSet("renderer::line-out", (string)outputBox.SelectedItem, "");
}
private void FormatBox_SelectedIndexChanged(object sender, EventArgs e)
{
m_renderer.FormatVideoGetByIndex(eMFormatType.eMFT_Convert, formatBox.SelectedIndex, out M_VID_PROPS props, out string formatName);
m_renderer.FormatVideoSet(eMFormatType.eMFT_Convert, ref props);
}
Start the output
Start the renderer on the source. From then on the renderer takes the frames of the source, converts them to its output format and sends them at the rate of the device.
private void StartOutput()
{
m_renderer.ObjectStart(m_file); // m_file is playing: FileNameSet + FilePlayStart
}
private void StopOutput()
{
m_renderer.ObjectClose(); // stops the output and frees the device
}
The preview of the file keeps working. Several renderers can be started on the same source. When the form closes, close the renderer before the file and release both objects.
Next steps
- Record the source to a file: MPlatform 4: Recording to a file.
- The SDK sample
Renderer Samplesends a source to several devices with their own formats.
Still have questions?
Tell us what didn’t work or what you’d like clarified.