ManagedCodecs.Playback
0.9.0
dotnet add package ManagedCodecs.Playback --version 0.9.0
NuGet\Install-Package ManagedCodecs.Playback -Version 0.9.0
<PackageReference Include="ManagedCodecs.Playback" Version="0.9.0" />
<PackageVersion Include="ManagedCodecs.Playback" Version="0.9.0" />
<PackageReference Include="ManagedCodecs.Playback" />
paket add ManagedCodecs.Playback --version 0.9.0
#r "nuget: ManagedCodecs.Playback, 0.9.0"
#:package ManagedCodecs.Playback@0.9.0
#addin nuget:?package=ManagedCodecs.Playback&version=0.9.0
#tool nuget:?package=ManagedCodecs.Playback&version=0.9.0
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:
TakeFramegives 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.MatrixandRangeoverride them. HDR is not tone mapped. - Shape:
frame.SampleAspectRatio(anamorphic video) andplayer.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.Loopplays 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 | 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
- ManagedCodecs.Aac (= 0.9.0)
- ManagedCodecs.Containers (= 0.9.0)
- ManagedCodecs.Core (= 0.9.0)
- ManagedCodecs.H264 (= 0.9.0)
- ManagedCodecs.Mjpeg (= 0.9.0)
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 |