Skip to content

Linux Platform Blocks - VisioForge Media Blocks SDK .Net

Try it Download free trial dotnet add package VisioForge.DotNet.MediaBlocks Pricing →

Media Blocks SDK .Net

This section covers MediaBlocks specifically optimized for Linux platforms.

Available Blocks

VA-API Hardware Decoders

Linux provides hardware-accelerated video decoding through VA-API (Video Acceleration API):

  • VAAPIH264DecoderBlock: Hardware H.264/AVC decoding
  • VAAPIHEVCDecoderBlock: Hardware H.265/HEVC decoding
  • VAAPIJPEGDecoderBlock: Hardware JPEG decoding
  • VAAPIVC1DecoderBlock: Hardware VC-1 decoding

See Video Decoders Documentation

Platform Requirements

  • Linux: Any modern Linux distribution
  • VA-API: libva and appropriate driver for your GPU
  • Hardware: Intel, AMD, or other GPU with VA-API support

Features

  • Hardware Acceleration: GPU-based video decoding
  • Low CPU Usage: Offload decoding to dedicated hardware
  • Wide Compatibility: Works with Intel, AMD, and other GPUs
  • Power Efficiency: Reduced power consumption
  • Multi-Stream: Handle multiple HD/4K streams

Sample Code

Hardware H.264 Decoding

var pipeline = new MediaBlocksPipeline();

// The decoder takes the encoded stream: demux the MP4 and parse its H.264 instead of decoding it in a source block (another container needs its own demuxer)
var fileSource = new BasicFileSourceBlock("video.mp4");
var demux = new QTDemuxBlock(renderVideo: true, renderAudio: false);
var parse = new H264ParseBlock();
pipeline.Connect(fileSource.Output, demux.Input);
pipeline.Connect(demux.VideoOutput, parse.Input);

// VA-API hardware decoder
if (VAAPIH264DecoderBlock.IsAvailable())
{
    var vaapiDecoder = new VAAPIH264DecoderBlock();
    pipeline.Connect(parse.Output, vaapiDecoder.Input);

    var videoRenderer = new VideoRendererBlock(pipeline, VideoView1);
    pipeline.Connect(vaapiDecoder.Output, videoRenderer.Input);
}
else
{
    // Fallback to software decoder
    var decoder = new UniversalDecoderBlock(MediaBlockPadMediaType.Video);
    pipeline.Connect(parse.Output, decoder.Input);

    var videoRenderer = new VideoRendererBlock(pipeline, VideoView1);
    pipeline.Connect(decoder.VideoOutput, videoRenderer.Input);
}

await pipeline.StartAsync();

Multiple Hardware Decoders

var pipeline = new MediaBlocksPipeline();

// Decode H.264 stream
var h264Source = new BasicFileSourceBlock("h264.mp4");
var h264Demux = new QTDemuxBlock(renderVideo: true, renderAudio: false);
var h264Parse = new H264ParseBlock();
var h264Decoder = new VAAPIH264DecoderBlock();
pipeline.Connect(h264Source.Output, h264Demux.Input);
pipeline.Connect(h264Demux.VideoOutput, h264Parse.Input);
pipeline.Connect(h264Parse.Output, h264Decoder.Input);

// Decode H.265 stream
var h265Source = new BasicFileSourceBlock("h265.mp4");
var h265Demux = new QTDemuxBlock(renderVideo: true, renderAudio: false);
var h265Parse = new H265ParseBlock();
var h265Decoder = new VAAPIHEVCDecoderBlock();
pipeline.Connect(h265Source.Output, h265Demux.Input);
pipeline.Connect(h265Demux.VideoOutput, h265Parse.Input);
pipeline.Connect(h265Parse.Output, h265Decoder.Input);

// Mix both streams (example)
var mixer = new VideoMixerBlock(mixerSettings);
pipeline.Connect(h264Decoder.Output, mixer.Inputs[0]);
pipeline.Connect(h265Decoder.Output, mixer.Inputs[1]);

var videoRenderer = new VideoRendererBlock(pipeline, VideoView1);
pipeline.Connect(mixer.Output, videoRenderer.Input);

await pipeline.StartAsync();

Setup and Configuration

Installing VA-API

Ubuntu/Debian:

sudo apt-get install libva2 libva-drm2 vainfo

Fedora/RHEL:

sudo dnf install libva libva-utils

Checking VA-API Support

vainfo

This command displays available VA-API profiles and entrypoints.

Driver Installation

Intel GPUs:

# Ubuntu/Debian
sudo apt-get install intel-media-va-driver

# Fedora/RHEL
sudo dnf install intel-media-driver

AMD GPUs:

# Ubuntu/Debian
sudo apt-get install mesa-va-drivers

# Fedora/RHEL
sudo dnf install mesa-va-drivers

Checking Hardware Support in Code

// Check if VA-API H.264 decoder is available
if (VAAPIH264DecoderBlock.IsAvailable())
{
    Console.WriteLine("VA-API H.264 hardware decoding is available");
    var decoder = new VAAPIH264DecoderBlock();
}
else
{
    Console.WriteLine("VA-API not available, using software decoder");
    var decoder = new UniversalDecoderBlock(MediaBlockPadMediaType.Video);
}

Performance Tips

  • Ensure VA-API drivers are properly installed
  • Use hardware decoders when available for best performance
  • Check decoder availability before creating blocks
  • Monitor GPU memory usage when processing multiple streams
  • Use vainfo command to verify hardware support

Troubleshooting

VA-API not working: 1. Verify driver installation with vainfo 2. Check user permissions (may need to be in video or render group) 3. Ensure GStreamer VA-API plugins are installed: gstreamer1.0-vaapi

Permission issues:

# Add user to video group
sudo usermod -a -G video $USER
# Log out and back in for changes to take effect

Platforms

Linux (Ubuntu, Debian, Fedora, RHEL, Arch, and other distributions).

Requires VA-API support with appropriate drivers.

  • VideoDecoders - Hardware decoding blocks
  • Nvidia - Nvidia GPU acceleration (also works on Linux)