FFmpeg.Rx
0.1.2
dotnet add package FFmpeg.Rx --version 0.1.2
NuGet\Install-Package FFmpeg.Rx -Version 0.1.2
<PackageReference Include="FFmpeg.Rx" Version="0.1.2" />
<PackageVersion Include="FFmpeg.Rx" Version="0.1.2" />
<PackageReference Include="FFmpeg.Rx" />
paket add FFmpeg.Rx --version 0.1.2
#r "nuget: FFmpeg.Rx, 0.1.2"
#:package FFmpeg.Rx@0.1.2
#addin nuget:?package=FFmpeg.Rx&version=0.1.2
#tool nuget:?package=FFmpeg.Rx&version=0.1.2
FFmpeg.Rx
Reactive FFmpeg process wrapper using R3 Observables. Type-safe, composable, testable.
Why FFmpeg.Rx?
Most .NET FFmpeg wrappers pass encoding options as raw strings - codec names, bitrate values, filter expressions. Typos compile fine and fail at runtime. FFmpeg.Rx replaces string bags with typed records: every codec, bitrate, preset, pixel format, and container is a .NET type with static factories and a Custom() escape hatch. The pipeline is a record tree you can inspect, test, and serialize - builders are syntactic sugar on top.
Events (progress, log, lifecycle) come as R3 Observables, not callbacks. One session wraps one process. Build → Run → Done.
Features
- Typed pipeline model - codecs, bitrates, presets, formats as .NET types, not strings
- Disjoint codec specs -
StreamCopy | VideoEncode | AudioEncode | SubtitleEncodeat compile time - R3 Observables - progress, log, and lifecycle events as reactive streams
- ffprobe integration - strongly-typed
MediaInfowith AOT-compatible JSON - Convenience APIs - snapshots, concatenation, pipe I/O
- Escape hatches -
CustomArg()on every builder,Custom()on every value object - Mockable -
IFfmpegSessionfor consumer tests
Installation
dotnet add package FFmpeg.Rx
Requires ffmpeg on PATH (or provide a custom binary path via Ffmpeg.At(path)).
Requirements: .NET 10.0 or higher
Quick Start
using FFmpeg.Rx;
using FFmpeg.Rx.Codecs;
// Transcode with H264 + AAC
await using var session = Ffmpeg.Input("input.mp4")
.Output("output.mp4", o => o
.Stream(0, 0, StreamType.Video, s => s
.Encode(VideoCodec.H264, e => e
.Quality(Quality.Crf(23))
.Preset(Preset.Slow)))
.Stream(0, 0, StreamType.Audio, s => s
.Encode(AudioCodec.Aac, e => e
.Bitrate(Bitrate.Kbps(192)))));
var result = await session.RunAsync();
Stream Copy (Remux)
await using var session = Ffmpeg.Input("input.mp4")
.Output("output.mkv", o => o
.Stream(0, 0, StreamType.Video, s => s.Copy())
.Stream(0, 0, StreamType.Audio, s => s.Copy()));
await session.RunAsync();
Progress Events
await using var session = Ffmpeg.Input("input.mp4")
.WithProgressReporting()
.Output("output.mp4", o => o
.Stream(0, 0, StreamType.Video, s => s
.Encode(VideoCodec.H264, e => e.Quality(Quality.Crf(23)))));
session.Progress.Subscribe(p =>
Console.WriteLine($"Speed: {p.Speed:F1}x, Written: {p.BytesWritten} bytes"));
session.Log.Subscribe(log =>
Console.WriteLine($"[{log.Level}] {log.Line}"));
var result = await session.RunAsync();
Filters
await using var session = Ffmpeg.Input("input.mp4")
.Output("scaled.mp4", o => o
.Stream(0, 0, StreamType.Video, s => s
.Encode(VideoCodec.H264, e => e.Quality(Quality.Crf(23))))
.VideoFilter(f => f.Scale(1920, 1080)));
await session.RunAsync();
Probing
var info = await Ffmpeg.Probe("video.mp4");
Console.WriteLine($"Duration: {info.Duration}");
Console.WriteLine($"Video: {info.PrimaryVideo?.Codec} {info.PrimaryVideo?.Width}x{info.PrimaryVideo?.Height}");
Console.WriteLine($"Audio: {info.PrimaryAudio?.Codec} {info.PrimaryAudio?.SampleRate}Hz");
Snapshots and Concat
// Extract a single frame
await Ffmpeg.Snapshot("video.mp4", TimeSpan.FromSeconds(5), "thumb.jpg");
// Concatenate videos (same codec)
await Ffmpeg.Concat(["part1.mp4", "part2.mp4"], "full.mp4");
Custom Binary Path
await using var session = Ffmpeg.At("/usr/local/bin/ffmpeg")
.Input("input.mp4")
.Output("output.mp4", o => o
.Stream(0, 0, StreamType.Video, s => s.Copy())
.Stream(0, 0, StreamType.Audio, s => s.Copy()));
Architecture
Three-layer design - each layer is independently testable:
Layer 1: Pipeline records what the user wants PipelineConfig, OutputConfig, CodecConfig...
(immutable, inspectable, serializable)
|
Layer 2: Scoped builders how the user says it PipelineBuilder, OutputBuilder, StreamBuilder...
(fluent API sugar)
|
Layer 3: Serializer + CliWrap how it gets done ArgumentSerializer → CliWrap process execution
(pattern-match records → CLI args → run)
Core types:
| Type | Role |
|---|---|
PipelineConfig |
Root record: inputs + outputs + global options |
InputConfig |
Abstract: FileInput, UrlInput, PipeInput |
OutputConfig |
Destination, streams, container, filters, metadata |
CodecConfig |
StreamCopy | VideoEncode | AudioEncode | SubtitleEncode |
IFfmpegSession |
Consumer-facing interface (mockable) |
FfmpegSession |
CliWrap execution, R3 event bridging |
Building from Source
dotnet build src/FFmpeg.Rx.slnx
dotnet format src/FFmpeg.Rx.slnx --verify-no-changes
dotnet run --project src/FFmpeg.Rx.Tests/FFmpeg.Rx.Tests.csproj
dotnet run --project src/FFmpeg.Rx.IntegrationTests/FFmpeg.Rx.IntegrationTests.csproj
Contributing
Contributions are welcome. Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Write tests for your changes
- Ensure all tests pass and
dotnet formatis clean - Submit a Pull Request
License
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. 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. |
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.