SRTVideoEncoding.InProcess
1.0.0
dotnet add package SRTVideoEncoding.InProcess --version 1.0.0
NuGet\Install-Package SRTVideoEncoding.InProcess -Version 1.0.0
<PackageReference Include="SRTVideoEncoding.InProcess" Version="1.0.0" />
<PackageVersion Include="SRTVideoEncoding.InProcess" Version="1.0.0" />
<PackageReference Include="SRTVideoEncoding.InProcess" />
paket add SRTVideoEncoding.InProcess --version 1.0.0
#r "nuget: SRTVideoEncoding.InProcess, 1.0.0"
#:package SRTVideoEncoding.InProcess@1.0.0
#addin nuget:?package=SRTVideoEncoding.InProcess&version=1.0.0
#tool nuget:?package=SRTVideoEncoding.InProcess&version=1.0.0
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
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.
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 | Versions 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. |
-
.NETStandard 2.0
- FFmpeg.AutoGen (>= 6.1.0.1)
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 |