Class MJPEGEncoderBlock
- Assembly
- VisioForge.Core.dll
Motion JPEG (MJPEG) encoder block for creating frame-by-frame compressed video streams. This block provides MJPEG encoding capabilities where each video frame is independently compressed as a JPEG image, offering frame-accurate editing, low latency streaming, and simplified decoding. Features optional callback mode for real-time frame capture and analysis without requiring downstream processing.
Key features:
- Independent frame compression (no inter-frame dependencies)
- Variable JPEG quality control (0-100)
- Frame-accurate editing capability
- Low latency encoding and decoding
- Optional callback mode for frame capture
- Hardware acceleration support
- Wide compatibility across platforms
Common use cases:
- IP camera streaming (security/surveillance)
- Video editing and post-production
- Medical imaging systems
- Machine vision applications
- Real-time frame analysis
- Network video recording (NVR)
- Digital signage systems
While MJPEG requires more bandwidth than inter-frame codecs, it excels in applications requiring frame independence, editing flexibility, and processing simplicity. Implements the VisioForge.Core.MediaBlocks.MediaBlock. Implements the VisioForge.Core.MediaBlocks.IMediaBlockInternals. Implements the IDisposable.
public class MJPEGEncoderBlock : MediaBlock, IMediaBlock, IDisposable, IMediaBlockInternalsInheritance
Implements
Inherited Members
Extension Methods
Constructors
MJPEGEncoderBlock(IMJPEGEncoderSettings)
Initializes a new instance of the VisioForge.Core.MediaBlocks.VideoEncoders.MJPEGEncoderBlock class. Creates an MJPEG encoder for standard stream output mode.
public MJPEGEncoderBlock(IMJPEGEncoderSettings settings)Parameters
settingsIMJPEGEncoderSettings-
The MJPEG encoder settings defining quality and compression parameters.
MJPEGEncoderBlock()
Initializes a new instance of the VisioForge.Core.MediaBlocks.VideoEncoders.MJPEGEncoderBlock class with default settings. Creates an MJPEG encoder with standard quality settings.
public MJPEGEncoderBlock()MJPEGEncoderBlock(IMJPEGEncoderSettings, bool, bool)
Initializes a new instance of the VisioForge.Core.MediaBlocks.VideoEncoders.MJPEGEncoderBlock class with callback support. Creates an MJPEG encoder that can operate in callback mode for real-time frame capture.
public MJPEGEncoderBlock(IMJPEGEncoderSettings settings, bool callbackMode, bool callbackIsSync)Parameters
settingsIMJPEGEncoderSettings-
The MJPEG encoder settings defining quality and compression parameters.
callbackModebool-
If true, enables callback mode for frame capture without output pad.
callbackIsSyncbool-
If true, frame callbacks are synchronous (blocking); otherwise asynchronous.
Properties
Input
Gets the primary input pad for receiving raw video frames.
public override MediaBlockPad Input { get; }Property Value
Inputs
Gets all input pads available on this block.
public override MediaBlockPad[] Inputs { get; }Property Value
Output
Gets the primary output pad for MJPEG-encoded video stream.
public override MediaBlockPad Output { get; }Property Value
Outputs
Gets all output pads available on this block.
public override MediaBlockPad[] Outputs { get; }Property Value
Settings
Gets or sets the MJPEG encoder settings controlling compression quality.
public IMJPEGEncoderSettings Settings { get; set; }Property Value
Type
Gets the block type identifier for the MJPEG encoder.
public override MediaBlockType Type { get; }Property Value
Methods
Build()
Builds and initializes the MJPEG encoder pipeline. Creates the encoder with specified quality settings and configures callback mode if enabled for real-time frame capture and analysis.
public override bool Build()Returns
- bool
-
trueif the encoder was successfully built;falseif initialization failed.
CleanUp()
Performs cleanup of all resources associated with the MJPEG encoder. Disposes the encoder element and callback components if present.
public void CleanUp()Dispose(bool)
Releases unmanaged and - optionally - managed resources.
protected override void Dispose(bool disposing)Parameters
disposingbool-
trueto release both managed and unmanaged resources;falseto release only unmanaged resources.
GetCore()
Gets the core GStreamer element wrapper for advanced configuration.
public BaseElement GetCore()Returns
- BaseElement
-
The BaseElement wrapper for the MJPEG encoder.
GetElement()
Gets the underlying GStreamer MJPEG encoder element.
public Element GetElement()Returns
- Element
-
The native GStreamer element performing MJPEG encoding.
IsAvailable(IMJPEGEncoderSettings)
Determines whether MJPEG encoding functionality is available on the current system. Checks for required encoder plugins and hardware acceleration support.
public static bool IsAvailable(IMJPEGEncoderSettings settings)Parameters
settingsIMJPEGEncoderSettings-
The MJPEG encoder settings to validate for availability.
Returns
- bool
-
trueif MJPEG encoding with specified settings is supported; otherwise,false.
IMediaBlockInternals.SetContext(MediaBlocksPipeline)
Sets the media pipeline context for this MJPEG encoder block.
void IMediaBlockInternals.SetContext(MediaBlocksPipeline pipeline)Parameters
pipelineMediaBlocksPipeline-
The parent media pipeline containing this block.
OnJPEGFrame
Occurs when a JPEG frame is encoded in callback mode. Provides access to individual JPEG images for real-time processing or analysis.
public event EventHandler<byte[]> OnJPEGFrameEvent Type
- EventHandler<byte[]>