MediaToolkitNet.MacOS
0.1.1
See the version list below for details.
dotnet add package MediaToolkitNet.MacOS --version 0.1.1
NuGet\Install-Package MediaToolkitNet.MacOS -Version 0.1.1
<PackageReference Include="MediaToolkitNet.MacOS" Version="0.1.1" />
<PackageVersion Include="MediaToolkitNet.MacOS" Version="0.1.1" />
<PackageReference Include="MediaToolkitNet.MacOS" />
paket add MediaToolkitNet.MacOS --version 0.1.1
#r "nuget: MediaToolkitNet.MacOS, 0.1.1"
#:package MediaToolkitNet.MacOS@0.1.1
#addin nuget:?package=MediaToolkitNet.MacOS&version=0.1.1
#tool nuget:?package=MediaToolkitNet.MacOS&version=0.1.1
MediaToolkit.NET
Low-level wrappers over the native media stacks for .NET 10, plus one cross-platform API on top of them: device enumeration, camera and microphone capture, audio playback, decoding and recording.
Interop goes through [LibraryImport] and unmanaged function pointers. COM on
Windows is called directly through vtable slots, without [ComImport] or the
built-in COM marshaller, so the assemblies stay AOT- and trim-safe.
Install
dotnet add package MediaToolkitNet.All
MediaToolkitNet.All pulls in every backend and selects one at runtime. Take a
single backend instead when you do not want the rest:
| Package | Contents |
|---|---|
MediaToolkitNet.All |
Facade: backend registry and per-platform selection |
MediaToolkitNet.Abstractions |
Abstractions only; no native code, no dependencies |
MediaToolkitNet.Interop |
Native loading, UTF-8 marshalling, COM vtable access |
MediaToolkitNet.FFmpeg |
FFmpeg 7.x: demux, decode, encode, mux |
MediaToolkitNet.Mpv |
libmpv client API |
MediaToolkitNet.Windows |
Media Foundation, WASAPI, DirectShow |
MediaToolkitNet.Linux |
V4L2, ALSA, PulseAudio |
MediaToolkitNet.MacOS |
AVFoundation, CoreAudio |
Quick start
using MediaToolkitNet;
using MediaToolkitNet.Abstractions.Capture;
using MediaToolkitNet.Abstractions.Frames;
// Whichever backend this machine actually has.
using var capture = MediaToolkitNetBackends.CreateVideoCapture(VideoCaptureSettings.Default);
capture.FrameCaptured += (in VideoFrame frame) =>
{
// The frame is borrowed: it is valid only inside this handler.
// Copy the data out if you need to keep it.
ReadOnlySpan<byte> luma = frame.GetPlane(0);
};
capture.Start();
List what a machine can do:
foreach (var backend in MediaToolkitNetBackends.Registered)
{
Console.WriteLine($"{backend.Name}: {backend.IsAvailable}, {backend.Capabilities}");
}
foreach (var device in MediaToolkitNetBackends.EnumerateDevices())
{
Console.WriteLine($"{device.Kind} {device.Name}");
}
What each backend provides
| Capability | Windows | Linux | macOS | FFmpeg | mpv |
|---|---|---|---|---|---|
| Device enumeration | MF + WASAPI + DShow | ALSA + V4L2 | CoreAudio + AVF | avdevice | — |
| Video capture | IMFSourceReader |
V4L2 mmap | AVCaptureSession |
— | — |
| Audio capture | WASAPI (+ loopback) | ALSA / PulseAudio | AudioQueue | — | — |
| Audio render | WASAPI | ALSA / PulseAudio | AudioQueue | — | — |
| Playback | — | — | AVPlayer |
decode to frames | full |
| Recording to file | IMFSinkWriter |
— | — | encode + mux | — |
A dash means the backend does not take that role: FFmpeg owns no audio output, mpv never hands frames back, and on Linux and macOS writing files is the FFmpeg backend's job.
Requirements
- .NET 10, and a 64-bit process: every mapped struct layout assumes a 64-bit pointer.
- No native binary ships in any package. The platform backends only call
libraries that are already part of the operating system, but:
MediaToolkitNet.FFmpegneeds FFmpeg 7.x at runtime (avutil 59 / avcodec 61 / avformat 61);MediaToolkitNet.Mpvneeds libmpv at runtime.
A backend whose libraries are missing reports IsAvailable == false instead of
throwing, so probing is always safe.
Status
This is an early release. On Windows, device enumeration, camera capture, WASAPI audio capture and audio recording to AAC/MP4 have been exercised against real hardware. The Linux, macOS, FFmpeg and mpv backends compile but have not been run yet, and the public API may still change. See the release notes for the full picture before depending on it.
Links
MIT licensed.
| 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
- MediaToolkitNet.Abstractions (>= 0.1.1)
- MediaToolkitNet.Interop (>= 0.1.1)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on MediaToolkitNet.MacOS:
| Package | Downloads |
|---|---|
|
MediaToolkitNet.All
MediaToolkit.NET: one API over the native media stacks. This package pulls in every backend and selects the right one for the current operating system. Install a single backend package instead if you only need one. |
GitHub repositories
This package is not used by any popular GitHub repositories.
MediaToolkit.NET 0.1.1 - first usable release.
There is no 0.1.0. Two packages of that version reached nuget.org before the rest
of the set was rejected: nuget.org refuses an id that matches an existing one
once dots are stripped, so MediaToolkitNet.Core collided with MediaToolkit.NetCore
and the facade collided with MediaToolkit.NET. Those two ids are now
MediaToolkitNet.Abstractions and MediaToolkitNet.All. MediaToolkitNet.Interop
0.1.0 and MediaToolkitNet.FFmpeg 0.1.0 depend on an id that never shipped, so
they are unlisted and must not be used.
The README on this page already covers what the library does, how to install it,
what each backend provides and what it needs at runtime. These notes cover only
what is specific to this release: how far it has actually been tested, and where
it does not work yet.
VERIFIED ON REAL HARDWARE (Windows 11)
- Device enumeration through Media Foundation, WASAPI and DirectShow, including
default-endpoint flags.
- Video capture from a USB camera: 640x480 NV12 at 30 fps, sustaining about
23 fps delivered to the frame handler.
- Audio capture through WASAPI at 48 kHz stereo float.
- Recording live audio to AAC/MP4 through IMFSinkWriter, producing a
structurally complete MP4 (ftyp / mdat / moov, brand mp42), which confirms the
writer was finalised rather than merely fed.
The Windows COM vtable slot tables were corrected twice during development by
running them, not by reading them: a wrong slot number compiles, raises no
exception, and silently calls the neighbouring method.
NOT EXERCISED YET - PLEASE READ BEFORE DEPENDING ON THIS
- The Linux and macOS backends have never been run. They compile and are guarded
at runtime, but the V4L2 struct sizes and the Objective-C runtime layout have
not been confirmed against real hardware.
- The FFmpeg and mpv backends have never been run, because those native
libraries were not installed on the development machine. The FFmpeg ABI
self-check refuses to proceed on a layout it cannot confirm, so a mismatch
should produce a clear error rather than memory corruption, but that path is
untested too.
- Media Foundation video recording is untested: the development machine has no
video encoder MFT registered at all. MediaFoundationRecorder detects that case
and reports it plainly. Audio recording on that path does work.
That is why this is 0.1.1. The public API may still change.
KNOWN LIMITATIONS
- Media Foundation video recording needs a video encoder MFT registered on the
machine; editions such as Windows N without the Media Feature Pack have none.
- MacOSBackend cannot write files, because AVAssetWriter is not wrapped. Use the
FFmpeg backend instead.
- FFmpegPlayer only decodes: no renderer and no audio output.
- Only the mpv client API is wrapped; the render API is not.
- DirectShow is wrapped for device enumeration only, with no filter graph.
Reports from Linux and macOS are especially welcome.
Full notes: https://github.com/yartat/MediaToolkit.NET/releases/tag/v0.1.1
Issues: https://github.com/yartat/MediaToolkit.NET/issues