FFmpegDotNet.Skia 9.3.0

dotnet add package FFmpegDotNet.Skia --version 9.3.0
                    
NuGet\Install-Package FFmpegDotNet.Skia -Version 9.3.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="FFmpegDotNet.Skia" Version="9.3.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="FFmpegDotNet.Skia" Version="9.3.0" />
                    
Directory.Packages.props
<PackageReference Include="FFmpegDotNet.Skia" />
                    
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 FFmpegDotNet.Skia --version 9.3.0
                    
#r "nuget: FFmpegDotNet.Skia, 9.3.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 FFmpegDotNet.Skia@9.3.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=FFmpegDotNet.Skia&version=9.3.0
                    
Install as a Cake Addin
#tool nuget:?package=FFmpegDotNet.Skia&version=9.3.0
                    
Install as a Cake Tool

FFmpeg.Skia

FFmpeg.Skia extends the FFmpeg .NET wrapper (FFmpegDotNet) with SkiaSharp integration. It converts decoded FFmpeg frames (AVFrame) into Skia objects (SKImage, SKBitmap) and back, and provides classes for decoding and playing videos and animated images with Skia.

📚 API Documentation


📖 Overview

FFmpeg.Skia combines FFmpeg's decoding with Skia's rendering, e.g. in MAUI, Avalonia, WPF or WinUI applications that use SkiaSharp.

  • Extension methods to convert between AVFrame and SKBitmap/SKImage (ToSKBitmap, AsSKImage, CopyTo, ToAVFrame, ...) and to draw frames (SKCanvas.DrawFrame)
  • FFCodec2Skia: decodes a video (or image) frame by frame into SKBitmaps, like SKCodec, with exact seeking
  • SKVideo: plays a video on a background thread and raises an event for each frame to render
  • SKAnimatedImage: animated images (GIF, APNG, WebP, ...) or videos, decoded manually or played automatically

Conversions apply the frame's crop and color properties (YUV matrix, range, HDR), and frames in a pixel format Skia supports are shared without copying.


🚀 Getting Started

Installation

dotnet add package FFmpegDotNet.Skia

FFmpeg.Skia is built for FFmpeg 8 and FFmpeg 9 from the same sources. The first number of the package version is the FFmpeg major version, like for FFmpegDotNet:

FFmpegDotNet.Skia FFmpegDotNet FFmpeg
9.x (e.g. 9.3.0.0) 9.x 9.0
8.x (e.g. 8.3.0.0) 8.x 8.1

Use the one that matches the FFmpegDotNet version and the FFmpeg binaries of your application; both behave the same. The FFmpeg binaries are not included: install FFmpeg, or use FFmpegDotNet.bin.winx64 of the same major version on Windows.

Loading FFmpeg

FFmpegLoader.Initialize();                       // searches the application directory and the PATH
FFmpegLoader.Initialize(@"C:\tools\ffmpeg\bin"); // or a specific directory

⚡ Quick Start

Frames ↔ Skia

using FFmpeg;
using FFmpeg.Images;
using FFmpeg.Skia;
using FFmpeg.Utils;
using SkiaSharp;

using MediaSource source = MediaSource.Open("video.mp4");
int videoStream = source.FindBestStream(MediaType.Video);
using AVFrame frame = AVFrame.Allocate();

AVResult32 result;
while (!(result = source.ReadAndDecodeAVFrame(frame)).IsError)
{
    if (result != videoStream)
        continue;

    using SKBitmap copy = frame.ToSKBitmap();   // an independent copy
    using SKImage shared = frame.AsSKImage();   // shares the frame's pixels if Skia supports its format
    canvas.DrawFrame(frame, new SKRect(0, 0, 640, 360), SKSamplingOptions.Default);
}

// and back, e.g. for encoding
using AVFrame yuv = bitmap.ToAVFrame(PixelFormat.YUV420P);

Decoding into bitmaps: FFCodec2Skia

using FFCodec2Skia codec = FFCodec2Skia.Create("video.mp4")!;
using SKBitmap bitmap = new(codec.Info);

codec.Seek(TimeSpan.FromSeconds(10));          // the next image is the one visible at 10 s
while (codec.NextImage(bitmap, out FFCodecFrameInfo info))
{
    // bitmap holds the frame shown at info.TimeStamp for info.Duration
}

Playing a video: SKVideo

using SKVideo video = new("video.mp4");
video.FrameReadyToRender += (_, e) =>
{
    // e.frame is reused by SKVideo: draw or copy it here, do not keep it
};
video.Ended += (_, _) => video.Seek(TimeSpan.Zero); // seeking in Ended loops the video
video.Start();

Animated images: SKAnimatedImage

using SKAnimatedImage animation = SKAnimatedImage.Create("animation.gif");
animation.ReadyToRender += (_, _) => view.InvalidateSurface();
animation.Start(looping: true);

// in the paint handler (Frame may be drawn from a render loop at any time)
canvas.DrawRotated(animation.Frame, destination, animation.Rotation, SKSamplingOptions.Default);

For manual decoding, call DecodeNextImage() (or DecodeNextImageAsync() with an FFmpegWorkQueue) instead of Start.

The examples show these classes in a WPF application.


📝 Notes

  • Alpha: FFmpeg stores straight (unpremultiplied) alpha. Skia objects created from frames use SKAlphaType.Unpremul (or Opaque for color types without alpha); premultiplied Skia images are converted when copied into frames.

  • Crop: the crop values of a frame are applied: only the visible region is converted.

  • Colors: frames are converted with FFmpeg's scaler using their color properties: the YUV matrix (AVFrame.ColorSpace: BT.601, BT.709, BT.2020, ...) and range (AVFrame.ColorRange). Untagged YUV is treated as BT.601 limited range, like everywhere in FFmpeg. Skia images are SDR with BT.709/sRGB primaries: HDR video (PQ, HLG) is tone mapped and wide gamuts (BT.2020, P3) are mapped to BT.709; when writing into a frame tagged as HDR or wide gamut, the Skia colors are mapped into it. YUV frames written from Skia without a matrix or range are tagged BT.601 / limited range.

  • Sharing: AsSKBitmap/AsSKImage (and DrawFrame) share the frame's buffer without copying when Skia supports its pixel format; treat such bitmaps as read-only.

  • Bitmaps allocated for frames use the frame's color type if Skia supports it, otherwise an 8 bit color type.

  • Pixel aspect ratio and rotation: videos with non-square pixels are decoded with square pixels by FFCodec2Skia, SKVideo and SKAnimatedImage (SampleAspectRatio). The display rotation (e.g. of phone videos) is not applied to the decoded images; it is available as Rotation and applied when drawing with DrawRotated:

    canvas.DrawRotated(bitmap, destination, video.Rotation, new SKSamplingOptions(SKCubicResampler.Mitchell));
    
  • Threads: FFCodec2Skia is not thread-safe. SKVideo and SKAnimatedImage raise their events on thread-pool threads; they may be disposed from any thread, including their event handlers.

  • Hardware decoding: frames decoded on the GPU are copied to memory by MediaSource.ReadAndDecodeAVFrame; GPU frames cannot be drawn directly.


🛠️ Development

Building

dotnet pack FFmpeg.Skia -c Release -p:FFmpegMajor=8
dotnet pack FFmpeg.Skia -c Release -p:FFmpegMajor=9   # default

Tests

FFmpeg.Skia.Tests (MSTest) uses the Windows x64 FFmpeg binaries (FFmpegDotNet.bin.winx64) that match FFmpegMajor:

dotnet test FFmpeg.Skia.Tests -p:FFmpegMajor=8
dotnet test FFmpeg.Skia.Tests -p:FFmpegMajor=9

The small media files in FFmpeg.Skia.Tests/Test-Files are created by make_test_files.py (PyAV).

GitHub Actions

Workflow Runs on Does
tests.yml push to master, pull requests builds the library and the examples and runs the tests for FFmpeg 8 and 9 (Windows)
Release.yml tag v<SkiaVersion>, e.g. v3.0.0 builds both packages (8.<SkiaVersion>, 9.<SkiaVersion>), publishes them to NuGet and creates a GitHub release
documentation.yml push to master, manually builds the API documentation with DocFX and publishes it to GitHub Pages

To release, set SkiaVersion in FFmpeg.Skia/FFmpeg.Skia.csproj and push the matching tag. Publishing uses NuGet trusted publishing (a policy for this repository and Release.yml on nuget.org); GitHub Pages must use "GitHub Actions" as source. Dependabot (.github/dependabot.yml) proposes updates for the actions and NuGet packages weekly.


📄 License

LGPL-3.0, see LICENSE.txt.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  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.  net11.0 is compatible. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
9.3.0 102 11/19/2026
8.3.0 94 11/19/2026
2.3.0 185 8/16/2026
2.2.0 150 8/14/2026
2.1.0 137 7/26/2026
2.0.0 151 7/26/2026
1.1.0 149 7/22/2026
1.0.2 265 10/28/2025
1.0.1 231 10/22/2025
1.0.0 235 10/20/2025

=== 3.0.0 ===
Builds for FFmpeg 8 (FFmpegDotNet 8.x, package 8.3.0.0) and FFmpeg 9 (FFmpegDotNet 9.x, package 9.3.0.0) from the same sources. Use the package matching your FFmpegDotNet version.

Breaking changes:
- FFCodec2Skia.NextImage throws on decoding errors; false only means the end of the video.
- FFCodec2Skia.Seek(TimeSpan) returns the frame visible at the requested time (was: the key frame before it); Seek(long) converts the frame number with the frame rate (FFmpeg's frame seeking is ignored by most formats).
- Videos with non-square pixels are decoded with square pixels by default (FFCodec2Skia, SKVideo, SKAnimatedImage), e.g. 720x480 with 32:27 as 853x480.
- AsSKBitmap, AsSKImage and FFCodec2Skia.Info use straight (Unpremul) alpha like FFmpeg; premultiplied Skia images are converted when copied into frames.
- Bitmaps allocated for frames (CopyTo into an empty bitmap, SKAnimatedImage) use 8 bit color types; 10 bit video got RgbaF16.
- YUV frames written from Skia without matrix or range are tagged BT.601 / limited range.
- SKAnimatedImage.Start throws until the task returned by Stop has completed (two loops could run at the same time).
- FFCodec2Skia.Create and SKAnimatedImage.Create throw for media without a video stream (ArgumentException / ArgumentOutOfRangeException) and dispose the media source.

Bug fixes:
- Copying frames with padded rows (most decoded frames) threw ArgumentOutOfRangeException (ToSKBitmap, ToSKImage, CopyTo, FFCodec2Skia, SKAnimatedImage).
- SKImage/SKBitmap.ToAVFrame and CopyTo ignored the row bytes of the image: skewed images, and a heap overflow for images with padded rows (e.g. from AsSKImage).
- FFCodec2Skia reused a scaler for bitmaps of another size: heap overflow.
- Cropped frames: AsSKBitmap/AsSKImage/Reference used a wrong row offset; CopyTo and FFCodec2Skia ignored the crop.
- SKBitmap.Reference wrote into the buffer of the previously referenced frame.
- The YUV matrix (BT.709, BT.2020) and full range of yuv420p frames were ignored with FFmpeg 8 (converted as BT.601 limited range), in both directions.
- HDR (PQ, HLG) was not tone mapped and wide gamuts were not mapped for Skia.
- Frames marked interlaced lost every other line.
- SKImage.ToAVFrame threw NullReferenceException for lazily decoded images; ToSKImage leaked an image.
- FFCodec2Skia leaked the media source when creation failed; Duration was wrong for streams without duration.
- SKVideo: Dispose after Stop threw; Dispose freed frames still used by the decoding thread or a handler; Restart while playing was not synchronized and lost the timing; seeking in Ended did not continue playback.
- SKAnimatedImage: frames were shown for the duration of the next frame; Dispose during an operation could be undone; the AVFrame (and in DisposeAsync a bitmap) leaked; looping a still image busy-looped.

New:
- Rotation (display matrix, e.g. phone videos), SampleAspectRatio and DisplaySize on FFCodec2Skia, SKVideo and SKAnimatedImage; AVStream/AVFrame.GetDisplayRotation, AVStream.GetSampleAspectRatio; SKCanvas.DrawRotated.
- SKVideo.Faulted event.
- Colors are converted with FFmpeg's dynamic scaler with both FFmpeg versions, honoring YUV matrix, range and HDR metadata.

Improvements:
- The extension methods reuse their conversion setup (converting HDR frames took seconds per call).
- SKAnimatedImage uses three buffers: Frame can be drawn from a render loop.
- SKVideo and SKAnimatedImage may be disposed from any thread, including their event handlers.
=== 2.3.0 ===
Added SKAnimatedImage - a class that allows for both automatic and manual decoding auf image/video data.
=== 2.2.0 ===
AVFrame.CopyTo(SKBitmap) allows now empty bitmaps.
SKBitmap.Reference(AVFrame). Same as AVFrame.AsSKBitmap(), just with an existing SKBitmap.
=== 2.1.0 ===
Added CopyTo-Extension that copies the content of SKBitmap/SKImage into an existing AVFrame
BugFix: Removed blocking scheduler from SKVideo
=== 2.0.0 ===
Some smaller BugFixes
Added xml docu into the package.
Some functions got renamed.