ManagedCodecs.Playback 0.9.0

dotnet add package ManagedCodecs.Playback --version 0.9.0
                    
NuGet\Install-Package ManagedCodecs.Playback -Version 0.9.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.9.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ManagedCodecs.Playback" Version="0.9.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.9.0
                    
#r "nuget: ManagedCodecs.Playback, 0.9.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.9.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.9.0
                    
Install as a Cake Addin
#tool nuget:?package=ManagedCodecs.Playback&version=0.9.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 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.
  • Not a media player: no seeking. PlaybackOptions.Loop plays the file again from its start, the frames' times running on.

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 (1)

Showing the top 1 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 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.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.9.0 0 11/7/2026