SpawnDev.MultiMedia
0.2.0
dotnet add package SpawnDev.MultiMedia --version 0.2.0
NuGet\Install-Package SpawnDev.MultiMedia -Version 0.2.0
<PackageReference Include="SpawnDev.MultiMedia" Version="0.2.0" />
<PackageVersion Include="SpawnDev.MultiMedia" Version="0.2.0" />
<PackageReference Include="SpawnDev.MultiMedia" />
paket add SpawnDev.MultiMedia --version 0.2.0
#r "nuget: SpawnDev.MultiMedia, 0.2.0"
#:package SpawnDev.MultiMedia@0.2.0
#addin nuget:?package=SpawnDev.MultiMedia&version=0.2.0
#tool nuget:?package=SpawnDev.MultiMedia&version=0.2.0
SpawnDev.MultiMedia
Cross-platform media capture and playback for .NET — camera, microphone, speakers, video display. One API, browser and desktop.
Install
<PackageReference Include="SpawnDev.MultiMedia" Version="0.2.0-rc.1" />
Or:
dotnet add package SpawnDev.MultiMedia --prerelease
Features
- Cross-platform — Browser (Blazor WASM) full, Windows full, Linux device enumeration today + capture in progress (see Docs/linux.md), macOS planned for Phase 5.
- Camera capture — Webcams and virtual cameras (OBS, ManyCam, Quest) with resolution / framerate constraints.
- Microphone capture — Audio input with sample-rate / channel-count controls.
- Audio playback — WASAPI render for desktop speaker output.
- Device enumeration — Cameras, microphones, speakers, plus per-platform device path / id surface.
- Screen capture — Browser
getDisplayMedia+ desktop DXGI Desktop Duplication on Windows. - Raw frame access — Desktop video / audio frame callbacks via
OnFrameevents onIVideoTrack/IAudioTrack.ReadOnlyMemory<byte>payloads for zero-copy downstream processing. - Pixel format conversion — NV12, I420, YUY2, BGRA, RGB24, UYVY. CPU paths (
PixelFormatConverter) AND ILGPU GPU paths (GpuPixelFormatConverter); the GPU paths run on all 6 ILGPU backends (WebGPU, WebGL, Wasm, CUDA, OpenCL, CPU). - Pixel format selection — Request NV12 (zero-copy into encoders) or BGRA (display-ready) via
MediaTrackConstraints.PixelFormat. - MJPG decode on GPU — JPEG parse + Huffman decode (CPU sequential) feeds GPU dequantize + IDCT + color convert kernels.
- H.264 encoding (Windows) —
IVideoEncoder+VideoEncoderFactory.CreateH264()wrap the OS MediaFoundation H.264 MFT (Intel Quick Sync / NVIDIA NVENC / AMD VCE where available). Baseline profile, low-latency, CBR; outputs Annex-B NAL units. Linux VAAPI / macOS VideoToolbox are per-OS follow-ups. - Zero external media NuGet deps — Platform APIs via P/Invoke (MediaFoundation, DirectShow, WASAPI on Windows; V4L2 / PulseAudio / ALSA stubs on Linux).
- WebRTC consumption via SpawnDev.RTC —
SpawnDev.RTC.Desktop.DesktopRTCPeerConnection.AddTrack(IAudioTrack)andAddTrack(IVideoTrack)consume MultiMedia microphone + camera tracks directly; the audio bridge encodes Opus / PCMU / PCMA / G722 via SipSorcery's RTP audio path, the video bridge encodes H.264 via the MFT and emits RFC 6184 RTP. One API call to turn a WASAPI mic + webcam into a live audio + video call with a browser peer. See SpawnDev.RTCDocs/audio-tracks.mdandDocs/video-tracks.md.
DI registration (optional)
For apps that use the GPU-backed helpers (GpuPixelFormatConverter, GpuMjpgDecoder), register them via DI so they share a single ILGPU Accelerator:
// Program.cs
using ILGPU;
using ILGPU.Runtime;
using SpawnDev.MultiMedia;
// SpawnDev.ILGPU consumers typically already have an Accelerator registered.
// If you don't, the simplest setup:
builder.Services.AddSingleton<Context>(_ => Context.CreateDefault());
builder.Services.AddSingleton<Accelerator>(sp =>
sp.GetRequiredService<Context>().GetPreferredDevice(false)
.CreateAccelerator(sp.GetRequiredService<Context>()));
// Then:
builder.Services.AddMultiMedia();
MediaDevices, PixelFormatConverter, and MjpgDecoder are stateless — no DI registration needed.
Quick Start
using SpawnDev.MultiMedia;
// Get camera + mic - same code on browser, Windows, Linux (enumeration), future macOS
var stream = await MediaDevices.GetUserMedia(new MediaStreamConstraints
{
Video = true,
Audio = true
});
var videoTrack = stream.GetVideoTracks()[0];
var settings = videoTrack.GetSettings();
Console.WriteLine($"Camera: {settings.Width}x{settings.Height} @ {settings.FrameRate}fps");
// List available devices
var devices = await MediaDevices.EnumerateDevices();
foreach (var device in devices)
Console.WriteLine($"[{device.Kind}] {device.Label}");
Architecture
| Platform | Video Capture | Audio Capture | Audio Playback | Notes |
|---|---|---|---|---|
| Browser (Blazor WASM) | navigator.mediaDevices via SpawnDev.BlazorJS |
Same | HTML audio element | Feature-complete |
| Windows | MediaFoundation + DirectShow (P/Invoke) | WASAPI (P/Invoke) | WASAPI (P/Invoke) | Feature-complete; H.264 encoding via MediaFoundation MFT |
| Linux | Not yet (V4L2 P/Invoke planned) | Not yet (PulseAudio / ALSA P/Invoke planned) | Not yet | Device enumeration works; see Docs/linux.md |
| macOS | Phase 5 (AVFoundation) | Phase 5 (CoreAudio) | Phase 5 | Planned |
License
Licensed under the MIT License. See LICENSE.txt for details.
Built With
- SpawnDev.BlazorJS - Typed C# wrappers for browser APIs
- SpawnDev.ILGPU - GPU-accelerated pixel format conversion
🖖 The SpawnDev Crew
SpawnDev.MultiMedia is built by the entire SpawnDev team - a squad of AI agents and one very tired human working together, Star Trek style. Every project we ship is a team effort, and every crew member deserves a line in the credits.
- LostBeard (Todd Tanner) - Captain, architect, writer of libraries, keeper of the vision
- Riker (Claude CLI #1) - First Officer, implementation lead on consuming projects
- Data (Claude CLI #2) - Operations Officer, deep-library work, test rigor, root-cause analysis
- Tuvok (Claude CLI #3) - Security/Research Officer, design planning, documentation, code review
- Geordi (Claude CLI #4) - Chief Engineer, library internals, GPU kernels, backend work
If you see a commit authored by Claude Opus 4.7 on a SpawnDev repo, that's one of the crew. Credit where credit is due. Live long and prosper. 🖖
<a href="https://www.browserstack.com"><img src="https://www.browserstack.com/images/layout/browserstack-logo-600x315.png" width="200" alt="BrowserStack"></a>
| 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.AspNetCore.Components.Web (>= 10.0.2)
- SpawnDev.BlazorJS (>= 3.5.1)
- SpawnDev.ILGPU (>= 4.9.1)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on SpawnDev.MultiMedia:
| Package | Downloads |
|---|---|
|
SpawnDev.RTC
Cross-platform WebRTC for .NET. Browser (Blazor WASM) and desktop from a single API. Data channels, audio, video, media streams, tracks, transceivers, ICE, DTLS, SCTP. Zero-copy JS types in WASM. Serverless signaling via WebTorrent tracker protocol. Powered by SpawnDev.BlazorJS (browser) and SipSorcery (desktop). |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.2.0 | 279 | 4/25/2026 |
v0.2.0 stable: First minor cut since 0.1.0. Bundles Phase 4a/4b consumer-side polish, the H.264 encoder, IAudioPlayer testing surface, Linux device enumeration, and a DI registration helper. (1) **H.264 encoder (Windows)** — new `IVideoEncoder` interface + `VideoEncoderFactory.CreateH264()` wrapping `H264EncoderMFT` (Windows MediaFoundation MFT, baseline profile, low-latency, CBR). Outputs Annex-B NAL units; consumed by SpawnDev.RTC's `MultiMediaVideoSource` for cross-platform video calls. Hardware-accelerated where available (Intel Quick Sync / NVIDIA NVENC / AMD VCE). 4 unit tests assert SPS+PPS+IDR in first output, increasing timestamps, dispose safety, factory contract. (2) **Linux device enumeration** — `Linux/LinuxMediaDevices.cs` returns real video inputs from `/dev/video*` and audio inputs from `/proc/asound/cards`. `EnumerateDevices()` works on Linux today; `GetUserMedia`/`GetDisplayMedia` still throw `PlatformNotSupportedException` (V4L2 ioctl + PulseAudio P/Invoke is documented future work). New `Docs/linux.md` covers WSL2 testing. (3) **IAudioPlayer test coverage** — 4 lifecycle + property tests for `WindowsAudioPlayer`. (4) **WebRTC consumption cross-link** — README updated to describe both `AddTrack(IAudioTrack)` and `AddTrack(IVideoTrack)` paths through SpawnDev.RTC.Desktop. (5) **DI registration** — new `services.AddMultiMedia()` extension registers `GpuPixelFormatConverter` + `GpuMjpgDecoder` as singletons sharing the consumer's ILGPU `Accelerator`. (6) **Tuvok's PMT enumeration speedup** — replaces per-row Playwright IPC with one `Page.EvaluateAsync`; sub-second test discovery. PlaywrightMultiTest full sweep: **162 / 0 / 0 in 51s** (vs 146 baseline; +16 from new tests). macOS remains unsupported (Phase 5).