Proxeno.Kiln
0.1.2
See the version list below for details.
dotnet add package Proxeno.Kiln --version 0.1.2
NuGet\Install-Package Proxeno.Kiln -Version 0.1.2
<PackageReference Include="Proxeno.Kiln" Version="0.1.2" />
<PackageVersion Include="Proxeno.Kiln" Version="0.1.2" />
<PackageReference Include="Proxeno.Kiln" />
paket add Proxeno.Kiln --version 0.1.2
#r "nuget: Proxeno.Kiln, 0.1.2"
#:package Proxeno.Kiln@0.1.2
#addin nuget:?package=Proxeno.Kiln&version=0.1.2
#tool nuget:?package=Proxeno.Kiln&version=0.1.2

Kiln
A from-scratch H.264 encoder for .NET. Pure managed, SIMD-accelerated C#, zero native dependencies, Apache-2.0. Feed it raw frames and it hands back a standards-compliant H.264 baseline bitstream — the whole codec (bitstream, transforms, intra/inter prediction, motion search, entropy coding, deblocking) is implemented here, in this repository, against the ITU-T H.264 specification. No native codec to cross-compile, ship, or keep patched.
Status: pre-release (0.x). APIs will change. Every capability listed here is backed by a test in this repository — including smoke tests that decode every produced stream with an independent reference decoder as an oracle — and the What Kiln is not section says plainly what isn't here.
What you can build
Kiln is the encode step: one .NET process turns rendered or captured frames into an H.264 stream you can send anywhere, with no native runtime on the box. It's built for low-latency, real-time video, such as:
- Game & cloud-gaming streaming — render and encode on a server, play in a browser or thin client with well-under-a-second glass-to-glass latency.
- Screen capture & remote desktop — a headless host encoding its own output frame by frame.
- Camera & robotics video — live feeds from cameras, drones, or robots to an operator's screen.
- A source for a WebRTC / RTP pipeline — Kiln emits Annex B access units that drop straight into a stack like Keryx or any RTP packetizer.
- Anywhere you need low-latency managed H.264 inside a .NET process without bundling a native codec or taking on GPL/LGPL linkage.
Goals
- Pure managed. 100% C# on .NET 10 with hardware intrinsics — NEON/AdvSimd on arm64, AVX2 and SSSE3 on x64, scalar fallback everywhere else. No native library to cross-compile, ship, or patch.
- Genuinely open. Apache-2.0, original work that links no copyleft code — embed it in commercial or proprietary products where GPL/LGPL codec linkage is a problem. That's exactly why it exists.
- Faithful to the spec. Written against ITU-T H.264 (ISO/IEC 14496-10); every numeric table that
originates in the spec carries its clause/table citation in the source (
Table 9-4,§8.5.9,§9.2.1, …). - Real-time first. Predictable per-frame latency over maximum compression: a steady stream of low-latency frames beats a slow exhaustive search.
- Honest about scope. A 0.x that tells you exactly what is proven and what isn't here yet.
Quick start
using Kiln;
var encoder = new H264BaselineEncoder(1280, 720, new H264BaselineEncoderOptions
{
QuantizationParameter = 28,
KeyframeIntervalFrames = 120,
SliceCount = 4, // parallel slice encoding
});
var annexB = new byte[1280 * 720 * 2];
// Planar I420 input; u/v are half-resolution planes.
var written = encoder.EncodeFrame(y, u, v, strideY: 1280, strideUv: 640, annexB);
var wasIdr = encoder.LastFrameWasIdr;
// annexB[0..written] is a complete Annex B access unit (SPS/PPS included on IDR).
What you get
A real encoder, not a toy — the parts a low-latency streaming server actually needs:
- Baseline bitstream that just plays. Constrained baseline profile, IDR + P-frames, CAVLC entropy coding, Annex B output (SPS/PPS carried on every IDR) that streams straight into a WebRTC or RTP packetizer and decodes on browsers and hardware decoders.
- Genuine coding tools. Intra 4×4 / 16×16 with RD mode selection, P-slice inter prediction with sub-pel SATD motion search, P_Skip, and multiple reference frames.
- Quality knobs. In-loop deblocking, optional greedy trellis quantization, variance-based spatial adaptive QP, and per-frame rate control.
- Parallelism built in. Multi-slice frames encode their slices in parallel and bound the region a lost packet can damage.
- SIMD with a safety net. NEON/AdvSimd, AVX2 and SSSE3 kernels selected at runtime, each covered by parity tests against a scalar reference; CI runs the full suite on Linux, Windows and macOS so both architectures stay green.
- Streaming companions.
Kiln.RateControl(a low-latency rate controller with network feedback) andKiln.Recovery(IDR budgeting / keyframe recovery policy) are public companion namespaces for server use. - Verified. 2,174 tests — spec-roundtrip decoding, SIMD/scalar parity, golden-frame regression, PSNR fidelity floors, adversarial neighbour-availability sweeps, and independent-decoder smoke tests over every produced stream.
Options reference
| Option | Default | What it does |
|---|---|---|
QuantizationParameter |
28 | Base QP, 0–51. |
KeyframeIntervalFrames |
60 | IDR every N coded frames (frame 0 is always IDR). EncodeFrame(forceKeyframe: true) overrides. |
SliceCount |
1 | Slices per frame; >1 encodes slices in parallel and bounds loss regions. |
MaxReferenceFrames |
2 | 1 = single-ref (WebRTC / hardware-decoder safe), 2 = multi-reference P. |
TargetBitsPerFrame |
0 (off) | Per-MB QP adaptation toward a per-frame bit budget. |
FastSearch |
true | Hex/diamond integer ME + qpel refinement; false = exhaustive integer search. |
UseMotionSatd |
true | SATD scoring for integer-pel ME candidates (SAD for fractional refinement). |
EnableIntraInPFallback |
true | Allows I16x16/I4x4 macroblocks inside P-frames when inter prediction fails. |
TrellisLevel |
0 | 1 = greedy per-coefficient trellis quantization (better RD, ~5% CPU). |
AdaptiveQuantStrength |
0.0 | Variance-based spatial AQ; 1.0 = standard, typical 0.5–1.5. |
PreferRealtimeLatencyTuning |
false | Speed-biased P-frame ME / chroma-DC handling. |
LightweightDeblocking |
false | Disables in-loop deblocking (bitstream-signalled) to cut CPU. |
PreferHardwareIntrinsics |
true | Runtime SIMD kernel selection; false forces scalar. |
SubPartitionRangeCap |
16 | Sub-partition ME radius cap (per-frame complexity budget applies). |
ProfileIdc / LevelIdc |
66 / 0x1F | Signalled profile (baseline) and level. |
ChromaDcRdLambda, Intra4x4SadLambda |
derived | Expert RD-lambda overrides; leave null. |
Performance
Measured on Apple M5 Max (arm64, NEON/AdvSimd), .NET 10, BenchmarkDotNet, quiet machine — the
committed perf-gate baseline numbers (perf/).
| Benchmark | Mean | Min |
|---|---|---|
SATD 4x4 kernel (Satd4x4_Once) |
11.2 ns | 11.1 ns |
SATD 4x4 x 9 intra modes (SatdMany4x4_9Modes) |
99.3 ns | 99.2 ns |
| SAD 8x8 dispatch | 3.5 ns | 3.4 ns |
| SAD 16x16 dispatch (stride 720) | 6.4 ns | 6.4 ns |
| Full-MB 16x16 ME search, range 8 | 76.4 us | 76.1 us |
| Steady P-frame encode, 1280x720, 1 slice | 2.24 ms | 2.20 ms |
A ~2.2 ms steady-state P-frame at 720p on one slice leaves comfortable headroom for 60 fps game
streaming; SliceCount > 1 parallelizes further. Perf discipline is part of the repo:
bench/Kiln.Benchmarks (BenchmarkDotNet) plus scripts/h264-simd-capture-baseline.sh and
scripts/h264-simd-perf-gate.sh gate changes against the committed baseline in perf/. See
docs/perf-gate.md.
What Kiln is not
Not an x264 competitor. No B-frames, no CABAC, no 8×8 transform, no interlace; 4:2:0 8-bit only; dimensions must be multiples of 16. If you need maximum compression at any CPU cost, use a full-profile encoder. If you need clean-licensed, dependency-free, low-latency H.264 inside a .NET process, you are in the right place.
The Adaptation (resolution/fps ladders) and Queue (latest-frame dropping) namespaces ship inside
the library, fully tested but not yet wired into the encoder — experimental, and their APIs may
change or move without notice. See docs/architecture.md.
Installing
Published on nuget.org as Proxeno.Kiln. The package
id is Proxeno.Kiln; the assembly and namespace stay Kiln, so code uses using Kiln;.
dotnet add package Proxeno.Kiln
Documentation
- docs/architecture.md — pipeline stages, SIMD kernel structure, subsystems
- docs/perf-gate.md — benchmark baseline + regression gate workflow
- CONTRIBUTING.md — build, test, and contribution rules
- SECURITY.md — reporting vulnerabilities
License
Apache-2.0 — see LICENSE. © Kiln contributors.
| 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. |
-
net10.0
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
First public release. Pure-managed H.264 baseline-profile encoder for .NET 10 with runtime SIMD kernel selection (NEON/AVX2/SSSE3), P-frames, rate control and keyframe recovery.