OnvifLib 1.3.1
dotnet add package OnvifLib --version 1.3.1
NuGet\Install-Package OnvifLib -Version 1.3.1
<PackageReference Include="OnvifLib" Version="1.3.1" />
<PackageVersion Include="OnvifLib" Version="1.3.1" />
<PackageReference Include="OnvifLib" />
paket add OnvifLib --version 1.3.1
#r "nuget: OnvifLib, 1.3.1"
#:package OnvifLib@1.3.1
#addin nuget:?package=OnvifLib&version=1.3.1
#tool nuget:?package=OnvifLib&version=1.3.1
OnvifLib
<p align="center"> <img src="docs/images/onviflib-banner.jpg" alt="OnvifLib — ONVIF Device Manager alternative" width="100%"> </p>
<p align="center"> <a href="https://www.nuget.org/packages/OnvifLib"><img src="https://img.shields.io/nuget/v/OnvifLib.svg?style=flat-square&label=NuGet" alt="NuGet"></a> <a href="https://www.nuget.org/packages/OnvifLib"><img src="https://img.shields.io/nuget/dt/OnvifLib.svg?style=flat-square" alt="Downloads"></a> <a href="LICENSE"><img src="https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square" alt="MIT"></a> <a href="https://github.com/treealarm/OnvifLib/releases"><img src="https://img.shields.io/github/v/release/treealarm/OnvifLib?filter=gui-*&style=flat-square&label=GUI%20release" alt="GUI release"></a> <a href="https://github.com/sponsors/treealarm"><img src="https://img.shields.io/badge/sponsor-%E2%99%A5-ea4aaa?style=flat-square&logo=githubsponsors&logoColor=white" alt="Sponsor"></a> </p>
OnvifLib is a modern .NET 10 library for ONVIF IP cameras — discovery, PTZ, media URIs, events, analytics, Profile G, and Device I/O.
OnvifLib.Gui is the desktop companion: a cross-platform ONVIF Device Manager alternative for Windows and Linux, with live H.264 / HEVC playback (bundled ffmpeg), multi-camera tabs, and a full service test bench.
<p align="center"> <a href="https://github.com/treealarm/OnvifLib/releases"><b>Download GUI</b></a> · <a href="samples/OnvifLib.Gui"><b>GUI docs</b></a> · <a href="https://www.nuget.org/packages/OnvifLib"><b>NuGet</b></a> </p>
Why OnvifLib.Gui
Classic ONVIF Device Manager is Windows-only and often stalls on modern codecs. This stack is different:
| ODM | OnvifLib.Gui | |
|---|---|---|
| Platforms | Windows | Windows + Linux |
| Live video | Limited (HEVC often missing) | H.264 / HEVC via ffmpeg |
| Install | Aging installer | WiX MSI, Snap, portable zip |
| Profiles | Weak G/M on many builds | Profile G archive + Profile M / analytics |
| Stack | Legacy player era | .NET 10 + Avalonia |
Windows: prefer the MSI from Releases (Program Files, no Mark-of-the-Web). Linux: sudo snap install onviflib-gui (Snap Store); the zip on Releases is the portable variant. "Remember password" in the snap needs sudo snap connect onviflib-gui:password-manager-service until auto-connect is approved. After winget merges: winget install treealarm.OnvifLib.Gui.
Library features
- Device discovery (WS-Discovery) and device information; GetCapabilities fallback for ONVIF 1.x/2.0 cameras
- Device administration: users, date/time mode and time zone, network interfaces, DNS, NTP, hostname, protocols, gateway, discovery scopes
- Media profiles, RTSP / snapshot URIs, video source configurations and OSD
- PTZ continuous, relative, absolute, presets, home position, nodes and auxiliary commands
- Imaging: picture, day/night (IR cut), exposure, white balance, WDR, BLC, focus configuration and focus moves
- Events (PullPoint): topic list, topic filters, synchronization point
- Analytics (ver20) and metadata configuration (Profile M)
- Profile G: search (recordings and events), replay, recordings, tracks and recording jobs
- Geolocation: where the camera says it is, with each optional coordinate kept absent rather than zero
- Device I/O: relays and digital inputs, and their live state from
Device/Triggerproperty events - WS-Security UsernameToken
- Target: .NET 10
Install (library)
dotnet add package OnvifLib
Quick start
using OnvifLib;
// Create returns immediately and discovers the camera's services in the background.
var camera = Camera.Create("192.168.1.64", 80, "admin", "secret");
await camera.InitTask;
// A null service list means unreachable or unauthorized — Create itself never throws.
if (await camera.GetServicesAsync() is null)
throw new InvalidOperationException("could not reach the camera");
var info = await camera.GetDeviceInformationAsync();
Console.WriteLine($"{info.Manufacturer} {info.Model}, firmware {info.FirmwareVersion}");
// Every Get*Service() returns null when the camera does not offer that service.
if (await camera.GetMediaService() is { } media)
{
foreach (var profile in media.GetProfiles())
{
var uri = await media.GetStreamUri(profile.Token);
Console.WriteLine($"{profile.Name} {profile.Width}x{profile.Height} {profile.Encoding} → {uri}");
}
// Snapshot bytes, or null (the failure is logged rather than thrown).
if (await media.GetImage() is { } image)
await File.WriteAllBytesAsync("snapshot.jpg", image.Data);
}
if (await camera.GetPtzService() is { } ptz)
{
var profile = (await camera.GetProfiles())!.First();
await ptz.ContinuousMoveAsync(profile.Token, panTiltX: 0.5f, panTiltY: 0f);
await Task.Delay(500);
await ptz.StopAsync(profile.Token);
}
Stream URIs come back exactly as the camera reported them, which is usually without
credentials — a player needs user:password spliced in, percent-encoded.
To find cameras rather than address one directly:
var result = await WsDiscovery.ProbeAsync(TimeSpan.FromSeconds(4), CancellationToken.None);
// ScanOk distinguishes "scanned, found nothing" from "could not scan at all".
if (!result.ScanOk)
Console.WriteLine("no interface could join the multicast group — check the firewall");
foreach (var device in result.Devices)
Console.WriteLine($"{device.Name} at {device.Ip}:{device.Port}");
Geolocation
GetGeoLocationAsync reports where the camera says it is on the Earth. The ONVIF schema makes each
coordinate optional, and the library keeps that: a value the camera did not send is null, not 0.
foreach (var place in await camera.GetGeoLocationAsync())
Console.WriteLine($"{place.Entity} {place.Token}: " +
$"{place.Location?.Latitude}, {place.Location?.Longitude} at {place.Location?.ElevationMeters} m");
// Move a fixed camera. A vehicle-mounted one refuses (ActionNotSupported) — its place is the
// vehicle's, and GetGeoLocationAsync reports it.
await camera.SetGeoLocationAsync(new OnvifLocationEntity(
"Device", "cam1", new OnvifGeoLocation(38.9923, -76.9378, 12.5)));
Live relay and input state
ONVIF has no getter for the live state of a relay output or a digital input: it travels as
Device/Trigger property events. DeviceIoStateWatcher opens a topic-filtered pull point, keeps a
snapshot, and raises StateChanged. Subscribing replays the current state as Initialized, so the
snapshot is filled without waiting for anything to move.
if (await camera.GetEventService() is { } events)
{
// The watcher takes the event service's subscription over — give it one nothing else uses.
await using var io = await DeviceIoStateWatcher.CreateAsync(events);
await Task.Delay(1000); // the Initialized snapshot arrives with the first pull
if (io.TryGetState(DeviceIoKind.Relay, "relay1", out var relay))
Console.WriteLine($"relay1 energised: {relay.LogicalState}, contact closed: {relay.ContactClosed}");
if (io.TryGetState(DeviceIoKind.DigitalInput, "input1", out var input))
Console.WriteLine($"input1: {input.LogicalState}");
}
Samples
| OnvifLib.Probe | Console harness over the public API — OK/FAIL/SKIP, exit code, optional --allow-writes. |
| OnvifLib.Gui | Desktop ODM alternative: discovery, live video, PTZ, imaging, events, analytics, Profile G, Device I/O, SOAP log. Releases · WiX setup. |
dotnet run --project samples/OnvifLib.Probe -- --discovery
dotnet run --project samples/OnvifLib.Gui
In VS Code, press F5 and pick a configuration. In Visual Studio, set either sample as startup.
Note: do not enable trimming or NativeAOT in a consuming application.
System.ServiceModel.*builds channels, serializers and proxies by reflection with no trim annotations — a trimmed build launches and then fails on the first SOAP call.
Releasing the library
A push to main only builds. To publish to nuget.org, bump <Version> in
OnvifLib.csproj, commit, and push a tag naming it:
git tag v1.2.2 && git push origin v1.2.2
The release fails if the tag and <Version> disagree, or if that version is already on
nuget.org. The GUI is released separately, by gui-* tags.
| 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.14)
- System.Security.Cryptography.Xml (>= 10.0.13)
- System.ServiceModel.Duplex (>= 6.0.0)
- System.ServiceModel.Federation (>= 10.1.0)
- System.ServiceModel.Http (>= 10.1.0)
- System.ServiceModel.NetTcp (>= 10.1.0)
- System.ServiceModel.Primitives (>= 10.1.0)
- System.ServiceModel.Security (>= 6.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.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.3.1 | 0 | 11/9/2026 |
| 1.3.0 | 62 | 11/5/2026 |
| 1.2.2 | 147 | 10/25/2026 |
| 1.2.1 | 188 | 10/19/2026 |
| 1.2.0 | 132 | 10/12/2026 |
| 1.1.1 | 147 | 8/11/2026 |
| 1.0.10 | 118 | 8/11/2026 |
| 1.0.9 | 125 | 8/11/2026 |
| 1.0.7 | 144 | 6/22/2026 |
| 1.0.6 | 125 | 6/5/2026 |
| 1.0.5 | 121 | 6/5/2026 |
| 1.0.4 | 314 | 10/1/2025 |
| 1.0.3 | 229 | 9/8/2025 |
| 1.0.2 | 246 | 7/3/2025 |
| 1.0.1 | 382 | 6/11/2025 |
1.3.1: Pull points are released, not abandoned. EventService1 gains DisposeAsync (Dispose does the same for synchronous callers): it stops the receive loop, waits for it, unsubscribes over the still-open subscription manager with a bounded deadline, and only then closes the clients. The old order closed the clients under the loop, so its Unsubscribe was lost and the camera kept the pull point — a camera with a small MaxPullPoints ran out after a series of restarts and then refused every new subscription. Re-subscribing now releases the old pull point first on both paths, including after a fault, so a camera at its cap frees a slot instead of losing the subscription for good. StopReceivingAsync now stops deterministically, and a refused CreatePullPointSubscription logs the camera's advertised MaxPullPoints. 1.3.0: Geolocation on Camera — GetGeoLocationAsync and SetGeoLocationAsync, with the ONVIF *Specified flags honoured so a coordinate the camera did not report is absent rather than zero. Device I/O live state: DeviceIoStateWatcher opens a topic-filtered pull point on Device/Trigger/Relay and Device/Trigger/DigitalInput, where the Initialized snapshot gives each relay's and input's current state and Changed gives every update, and keeps it as a TryGetState snapshot with a change event. DeviceIoState carries a relay's logical state and contact. The probe gains geolocation steps and shows live relay and input state. New unit tests project (not packaged).