Skip to main content

MJPEG Video Encoders

The VisioForge library provides two MJPEG (Motion JPEG) encoder implementations for video encoding: a CPU-based encoder and a GPU-based Intel QuickSync encoder. This documentation covers their features, settings, and usage examples.

Overview

MJPEG encoders compress video by encoding each frame as a separate JPEG image. The library offers two encoder types:

  1. CPU-based MJPEG encoder (default)
  2. GPU-based Intel QuickSync MJPEG encoder

Both encoders implement the IMJPEGEncoderSettings interface, which defines the basic functionality for MJPEG encoding.

CPU-based MJPEG Encoder

The CPU-based encoder is the default implementation that processes video encoding using the CPU. It provides basic MJPEG encoding capabilities with configurable quality settings.

Features

  • Quality setting range: 10-100 (default: 85)
  • CPU-based processing
  • Standard MJPEG compression

Usage Example

// Create CPU-based MJPEG encoder settings
var encoderSettings = new MJPEGEncoderSettings
{
Quality = 85 // Set desired quality (10-100)
};

// Check if the encoder is available
if (MJPEGEncoderSettings.IsAvailable())
{
// Create encoder block
var encoderBlock = encoderSettings.CreateBlock();

// Use the encoder block in your video processing pipeline
}

Intel QuickSync MJPEG Encoder

The Intel QuickSync MJPEG encoder leverages Intel's QuickSync technology for hardware-accelerated video encoding, potentially offering better performance on compatible systems.

Features

  • Quality setting range: 10-100 (default: 85)
  • Hardware acceleration using Intel QuickSync
  • Preset quality profiles (Low, Normal, High, VeryHigh)
  • GPU-based processing

Usage Example

// Create QSV MJPEG encoder settings with default quality
var qsvEncoderSettings = new QSVMJPEGEncoderSettings
{
Quality = 85
};

// Or create with preset quality profile
var qsvEncoderWithPreset = new QSVMJPEGEncoderSettings(VideoQuality.High);

// Check if QSV encoder is available
if (QSVMJPEGEncoderSettings.IsAvailable())
{
// Create encoder block
var encoderBlock = qsvEncoderSettings.CreateBlock();

// Use the encoder block in your video processing pipeline
}

Quality Preset Values

The Intel QuickSync encoder provides preset quality profiles with the following values:

  • Low: 60
  • Normal: 75
  • High: 85
  • VeryHigh: 95

Best Practices

  1. Always check encoder availability using the IsAvailable() method before creating an encoder instance.
  2. Choose the appropriate encoder based on your system capabilities:
    • Use the CPU-based encoder for universal compatibility
    • Use the Intel QuickSync encoder when hardware acceleration is available and better performance is desired
  3. Select quality settings based on your requirements:
    • Higher values (85-100) for better visual quality
    • Lower values (10-60) for smaller file sizes and reduced quality
  4. Consider using preset quality profiles with the Intel QuickSync encoder for standardized quality levels

Compatibility

The availability of encoders can be checked at runtime using their respective IsAvailable() methods. The Intel QuickSync encoder requires compatible Intel hardware with QuickSync support.