# Blackmagic Decklink Integration with Media Blocks SDK

Media Blocks SDK .Net

# Introduction to Decklink Integration

The VisioForge Media Blocks SDK for .NET provides robust support for Blackmagic Decklink devices, enabling developers to implement professional-grade audio and video functionality in their applications. This integration allows for seamless capture and rendering operations using Decklink's high-quality hardware.

Our SDK includes specialized blocks designed specifically for Decklink devices, giving you full access to their capabilities including SDI, HDMI, and other inputs/outputs. These blocks are optimized for performance and offer a straightforward API for implementing complex media workflows.

# Key Capabilities

  • Audio Capture and Rendering: Capture and output audio through Decklink devices
  • Video Capture and Rendering: Capture and output video in various formats and resolutions
  • Multiple Device Support: Work with multiple Decklink devices simultaneously
  • Professional I/O Options: Utilize SDI, HDMI, and other professional interfaces
  • High-Quality Processing: Maintain professional video/audio quality throughout the pipeline

# System Requirements

Before using the Decklink blocks, ensure your system meets these requirements:

  • Hardware: Compatible Blackmagic Decklink device
  • Software: Blackmagic Decklink SDK or drivers installed

# Decklink Block Types

The SDK provides four main block types for working with Decklink devices:

  1. Audio Sink Block: For audio output to Decklink devices
  2. Audio Source Block: For audio capture from Decklink devices
  3. Video Sink Block: For video output to Decklink devices
  4. Video Source Block: For video capture from Decklink devices

Each block type is designed to handle specific media operations while maintaining synchronization and quality.

# Working with Decklink Audio Sink Block

The Decklink Audio Sink block enables audio output to Blackmagic Decklink devices. This block handles the complexities of audio timing and device interfacing, allowing you to focus on your application logic.

# Device Enumeration

Before creating an audio sink block, you'll need to enumerate available devices:

var devices = await DecklinkAudioSinkBlock.GetDevicesAsync();
foreach (var item in devices)
{
    Console.WriteLine($"Found device: {item.Name}");
}

This code retrieves all available Decklink devices that support audio output functionality.

# Block Creation and Configuration

Once you've identified the target device, you can create and configure the audio sink block:

// Get the first available device
var device = (await DecklinkAudioSinkBlock.GetDevicesAsync()).FirstOrDefault();

// Create settings for the selected device
DecklinkAudioSinkSettings audioSinkSettings = null;
if (device != null)
{
    audioSinkSettings = new DecklinkAudioSinkSettings(device);
}

// Create the block with configured settings
var decklinkAudioSink = new DecklinkAudioSinkBlock(audioSinkSettings);

# Connecting to the Pipeline

The audio sink block includes an Input pad that accepts audio data from other blocks in your pipeline:

// Example: Connect an audio source to the Decklink audio sink
audioSource.Output.Connect(decklinkAudioSink.Input);

# Working with Decklink Audio Source Block

The Decklink Audio Source block enables capturing audio from Blackmagic Decklink devices. It supports various audio formats and configurations.

# Device Enumeration

Enumerate available audio source devices:

var devices = await DecklinkAudioSourceBlock.GetDevicesAsync();
foreach (var item in devices)
{
    Console.WriteLine($"Available audio source: {item.Name}");
}

# Block Creation and Configuration

Create and configure the audio source block:

// Get the first available device
var device = (await DecklinkAudioSourceBlock.GetDevicesAsync()).FirstOrDefault();

// Create settings for the selected device
DecklinkAudioSourceSettings audioSourceSettings = null;
if (device != null)
{
    // create settings object
    audioSourceSettings = new DecklinkAudioSourceSettings(device);
}

// Create the block with the configured settings
var audioSource = new DecklinkAudioSourceBlock(audioSourceSettings);

# Connecting to the Pipeline

The audio source block provides an Output pad that can connect to other blocks:

// Example: Connect the audio source to an audio encoder
audioSource.Output.Connect(audioEncoder.Input);

# Working with Decklink Video Sink Block

The Decklink Video Sink block enables video output to Blackmagic Decklink devices, supporting various video formats and resolutions.

# Device Enumeration

Find available video sink devices:

var devices = await DecklinkVideoSinkBlock.GetDevicesAsync();
foreach (var item in devices)
{
    Console.WriteLine($"Available video output device: {item.Name}");
}

# Block Creation and Configuration

Create and configure the video sink block:

// Get the first available device
var device = (await DecklinkVideoSinkBlock.GetDevicesAsync()).FirstOrDefault();

// Create settings for the selected device
DecklinkVideoSinkSettings videoSinkSettings = null;
if (device != null)
{
    videoSinkSettings = new DecklinkVideoSinkSettings(device);
    
    // Configure video output format
    videoSinkSettings.Mode = DecklinkMode.HD1080i60;
    
    // Optional: Additional configuration
    videoSinkSettings.PixelFormat = DecklinkPixelFormat.YUV10Bit;
}

// Create the block with the configured settings
var decklinkVideoSink = new DecklinkVideoSinkBlock(videoSinkSettings);

# Key Video Sink Settings

  • Mode: Specifies the video resolution and frame rate (e.g., HD1080i60, HD720p60)
  • PixelFormat: Defines the color format (YUV, RGB, etc.) and bit depth
  • KeyingMode: Controls keying/compositing options if supported by the device

# Working with Decklink Video Source Block

The Decklink Video Source block allows capturing video from Blackmagic Decklink devices, supporting various input formats and resolutions.

# Device Enumeration

Enumerate video capture devices:

var devices = await DecklinkVideoSourceBlock.GetDevicesAsync();
foreach (var item in devices)
{
    Console.WriteLine($"Available video capture device: {item.Name}");
}

# Block Creation and Configuration

Create and configure the video source block:

// Get the first available device
var device = (await DecklinkVideoSourceBlock.GetDevicesAsync()).FirstOrDefault();

// Create settings for the selected device
DecklinkVideoSourceSettings videoSourceSettings = null;
if (device != null)
{
    videoSourceSettings = new DecklinkVideoSourceSettings(device);
    
    // Configure video input format
    videoSourceSettings.Mode = DecklinkMode.HD1080i60;
}

// Create the block with configured settings
var videoSourceBlock = new DecklinkVideoSourceBlock(videoSourceSettings);

# Key Video Source Settings

  • Mode: Specifies the expected input resolution and frame rate
  • InputConnection: Defines which physical input to use (HDMI, SDI, Component, etc.)
  • InputFlags: Additional input processing options

# Advanced Usage Examples

# Synchronized Audio/Video Capture

// Create video and audio source blocks
var videoSource = new DecklinkVideoSourceBlock(videoSourceSettings);
var audioSource = new DecklinkAudioSourceBlock(audioSourceSettings);

// Create an MP4 encoder
var mp4Settings = new MP4SinkSettings("output.mp4");
var sink = new MP4SinkBlock(mp4Settings);

// Create video encoder
var videoEncoder = new H264EncoderBlock();

// Create audio encoder
var audioEncoder = new AACEncoderBlock();

// Connect video and audio sources
pipeline.Connect(videoSource.Output, videoEncoder.Input);
pipeline.Connect(audioSource.Output, audioEncoder.Input);

// Connect video encoder to sink
pipeline.Connect(videoEncoder.Output, sink.CreateNewInput(MediaBlockPadMediaType.Video));

// Connect audio encoder to sink
pipeline.Connect(audioEncoder.Output, sink.CreateNewInput(MediaBlockPadMediaType.Audio));

// Start the pipeline
await pipeline.StartAsync();

# Troubleshooting Tips

  • No Devices Found: Ensure Blackmagic drivers are installed and up-to-date
  • Format Mismatch: Verify the device supports your selected video/audio mode
  • Performance Issues: Check system resources and consider lowering resolution/framerate
  • Signal Detection: For input devices, check cable connections and signal presence

# Sample Applications

For complete working examples, refer to these sample applications:

# Conclusion

The Blackmagic Decklink blocks in the VisioForge Media Blocks SDK provide a powerful and flexible way to integrate professional video and audio hardware into your .NET applications. By following the patterns described in this document, you can quickly implement capture and playback functionality with minimal code.

For additional support or questions, please refer to our documentation or contact our support team.