SRTVideoEncoding.InProcess 1.0.0

dotnet add package SRTVideoEncoding.InProcess --version 1.0.0
                    
NuGet\Install-Package SRTVideoEncoding.InProcess -Version 1.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="SRTVideoEncoding.InProcess" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="SRTVideoEncoding.InProcess" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="SRTVideoEncoding.InProcess" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add SRTVideoEncoding.InProcess --version 1.0.0
                    
#r "nuget: SRTVideoEncoding.InProcess, 1.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package SRTVideoEncoding.InProcess@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=SRTVideoEncoding.InProcess&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=SRTVideoEncoding.InProcess&version=1.0.0
                    
Install as a Cake Tool

SRTVideoEncoding - FFmpeg In-Process Video Encoder for .NET

Description

SRTVideoEncoding is a high-performance .NET library that wraps FFmpeg.AutoGen to provide in-memory (In-Process) video encoding without the need to launch external processes (ffmpeg.exe) or use standard input/output pipes (stdin/stdout).

Designed specifically for ultra-low latency video streaming applications, such as custom SRT (Secure Reliable Transport) or UDP implementations. It transforms raw memory buffers (for example, originating from OpenCV BGR matrices) into network-compatible MPEG-TS containers, compressed using libx264 or libx265.

Features

  • 100% In-Process: Executes entirely in RAM. Avoids bottlenecks caused by disk I/O operations or IPC pipes.

  • Native MPEG-TS: Direct output in multiplexed Transport Stream format, ready to be dispatched to network sockets.

  • Zero External Configuration: Internally configured for maximum speed (preset=ultrafast, tune=zerolatency).

  • Direct Integration: Ideal for consuming the Data / Stride output of an OpenCvSharp Mat object or a standard .NET Bitmap.

Environment Requirements

  1. Unsafe Compilation: This library operates directly with the memory pointers of the FFmpeg C API. Your project consuming this code must enable the use of unsafe blocks.

    • In Visual Studio: Right-click the project → Properties → Build → Allow unsafe code.
  2. FFmpeg Shared Binaries: The host machine (or container) must have the shared FFmpeg binaries available (avcodec-.dll, avutil-.dll, avformat-.dll, swscale-.dll on Windows, or .so on Linux). You can set the path dynamically in your code before initialization: ffmpeg.RootPath = "path/to/your/ffmpeg/binaries";

Usage Examples

Example in VB.NET

Imports SRTVideoEncoding
Imports OpenCvSharp

' 1. Instantiate and initialize (1920x1080 at 60 FPS, 5000 kbps, H.264)
Dim encoder As IVideoEncoder = New FFmpegInProcessEncoder()
encoder.Initialize(1920, 1080, 60, 5000, "libx264")

' 2. Inside your rendering / capture loop:
Dim frameMat As Mat = CaptureFrame() ' Assumes a 3-channel BGR Mat

' Pass the raw Data pointer and the Stride to the C# library
Dim mpegTsBytes As Byte() = encoder.EncodeFrame(frameMat.Data, CInt(frameMat.Step()))

' 3. Transmit directly to the network
If mpegTsBytes IsNot Nothing AndAlso mpegTsBytes.Length > 0 Then
    ' Assuming mySrtSocket is your active SRT connection
    mySrtSocket.Send(mpegTsBytes, 0, mpegTsBytes.Length)
End If

' 4. Final cleanup when streaming stops
encoder.Dispose()

Example in C#

using SRTVideoEncoding;
using OpenCvSharp;

// 1. Instantiate and initialize (1920x1080 at 60 FPS, 5000 kbps, H.264)
IVideoEncoder encoder = new FFmpegInProcessEncoder();
encoder.Initialize(1920, 1080, 60, 5000, "libx264");

// 2. Inside your rendering / capture loop:
Mat frameMat = CaptureFrame(); // Assumes a 3-channel BGR Mat

// Pass the raw Data pointer and the Stride to the library
byte[] mpegTsBytes = encoder.EncodeFrame(frameMat.Data, (int)frameMat.Step());

// 3. Transmit directly to the network
if (mpegTsBytes != null && mpegTsBytes.Length > 0) 
{
    // Assuming mySrtSocket is your active SRT connection
    mySrtSocket.Send(mpegTsBytes, 0, mpegTsBytes.Length);
}

// 4. Final cleanup when streaming stops
encoder.Dispose();

Maintenance and Extensibility

This library uses avio_alloc_context with a native delegate redirected to a .NET MemoryStream, meaning the multiplexer packages the data without touching a hard drive. If you need to modify complex encoder parameters (such as main or high profiles, chroma subsampling, or GOP_Size), you should adapt the Initialize() method inside FFmpegInProcessEncoder.cs.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0 116 2/26/2026