ManagedCodecs.Playback 0.18.0

dotnet add package ManagedCodecs.Playback --version 0.18.0
                    
NuGet\Install-Package ManagedCodecs.Playback -Version 0.18.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="ManagedCodecs.Playback" Version="0.18.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ManagedCodecs.Playback" Version="0.18.0" />
                    
Directory.Packages.props
<PackageReference Include="ManagedCodecs.Playback" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add ManagedCodecs.Playback --version 0.18.0
                    
#r "nuget: ManagedCodecs.Playback, 0.18.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package ManagedCodecs.Playback@0.18.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=ManagedCodecs.Playback&version=0.18.0
                    
Install as a Cake Addin
#tool nuget:?package=ManagedCodecs.Playback&version=0.18.0
                    
Install as a Cake Tool

ManagedCodecs.Playback

Video in a game, in pure managed C#: an MP4, Matroska, WebM or AVI file (H.264 or MJPEG video, AAC or MP3 audio) decoded on a thread of its own into RGBA frames for a texture and float stereo for a streaming sound. No native binaries and no engine's API, so it plays the same in MonoGame, FNA, Godot .NET and Stride, on every platform .NET 10 runs on. For Unity, ManagedCodecs.Unity holds the same MediaPlayer.

using ManagedCodecs.Playback;

using var player = new MediaPlayer("intro.mp4");
player.Start(); // the decoding thread

// Each frame of the game, with the game's own clock (time played since the first frame was shown):
if (player.TakeFrame(clock.Elapsed) is { } frame)
{
    texture.SetData(frame.Pixels); // frame.Width x frame.Height, R, G, B, A from the top row
    player.Return(frame);          // its pixels back, for a later frame
}

while (player.TakeAudio() is { } audio)
{
    // audio.Samples: left, right, left, right... (-1 to 1) at audio.SampleRate, to the engine's streaming sound
}

if (player.IsFinished) { /* the video has ended; player.Error says why if it ended early */ }
  • Timing: TakeFrame gives the newest frame due by the clock you pass (the first frame is due at zero), and drops the ones that are already late, as a player does when it can't keep up. Pause by stopping your clock.
  • Bounded: the decoder runs up to 8 frames and about 32 audio chunks ahead, then waits. Take the audio, or drop it, even with no sound device.
  • Speed: H.264 with frame threading (by default one thread fewer than the processors, at most 4). On 4 vCPUs at 2.1 GHz, 1080p24 and 1080p30 keep up, conversion to RGBA included (about 2 ms a 1080p frame).
  • Colours: each frame by its own matrix and range, and where the stream says nothing as players assume (BT.709 from 720 lines, BT.601 below, limited range); PlaybackOptions.Matrix and Range override them. HDR is not tone mapped.
  • Shape: frame.SampleAspectRatio (anamorphic video) and player.Video.Rotation (phone video) are for you to apply when drawing.
  • Damaged files: play up to the damage, then end with the exception in Error, never thrown at the game loop.
  • Audio tracks: the one the demuxer reads unasked plays (the file's first today); PlaybackOptions.AudioTrack chooses another, counted from 0. An MXF file's mono track a channel plays in stereo: the track chosen left, the next one right.
  • Not a media player: no seeking. PlaybackOptions.Loop plays the file again from its start, the frames' times running on.

Live cameras

LivePlayer shows a camera serving MJPEG over HTTP (ESP32-CAM, mjpg-streamer, OctoPrint, most IP cameras' video.mjpg), or H.264 or JPEG over RTSP (new LivePlayer(new RtspSource(new Uri("rtsp://user:password@camera/stream1"))): Digest or Basic, RTP over the RTSP connection, or over UDP when the camera refuses that; rtsps:// over TLS, with CertificateHash for a camera's self-signed certificate). The UI takes the newest frame on its render tick, older ones are dropped and counted, and a dropped or stalled connection is made again.

using var player = new LivePlayer(new MjpegHttpSource(new Uri("http://camera.local/video.mjpg")));
player.Start();

// On each render tick:
if (player.TakeLatest() is { } frame)
{
    // frame.Pixels: frame.Width x frame.Height, R, G, B, A from the top row, into the UI's bitmap
    player.Return(frame);
}
// player.State (Connecting, Playing, Reconnecting, Failed) and player.Error for a status line.

Samples for MonoGame, Godot 4 .NET and Unity are in the repository's tools/ folder. The README has the rest.

Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (3)

Showing the top 3 NuGet packages that depend on ManagedCodecs.Playback:

Package Downloads
ManagedCodecs.MonoGame

Video for MonoGame games: VideoTexture plays an MP4, Matroska, WebM or AVI file (H.264 or MJPEG, AAC or MP3 audio) into a Texture2D and a DynamicSoundEffectInstance, decoded on a thread of its own by ManagedCodecs.Playback, in pure managed C#. Any MonoGame 3.8 platform.

ManagedCodecs.Avalonia

Live cameras in Avalonia: LiveView shows a LivePlayer's newest frame (MJPEG over HTTP, H.264 or JPEG over RTSP and RTSPS), decoded in pure managed C# by ManagedCodecs.Playback, no native libraries. Windows, macOS and Linux.

ManagedCodecs.Wpf

Live cameras in WPF: LiveView shows a LivePlayer's newest frame (MJPEG over HTTP, H.264 or JPEG over RTSP and RTSPS), decoded in pure managed C# by ManagedCodecs.Playback, no native libraries.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.18.0 417 11/16/2026
0.17.0 463 11/15/2026
0.16.0 98 11/15/2026
0.15.0 161 11/15/2026
0.14.0 182 11/14/2026
0.13.0 279 11/12/2026
0.12.0 310 11/10/2026
0.11.0 290 11/9/2026
0.10.0 201 11/8/2026
0.9.1 292 11/8/2026
0.9.0 235 11/7/2026