FFmpegVideoPlayer.Avalonia
2.5.7
See the version list below for details.
dotnet add package FFmpegVideoPlayer.Avalonia --version 2.5.7
NuGet\Install-Package FFmpegVideoPlayer.Avalonia -Version 2.5.7
<PackageReference Include="FFmpegVideoPlayer.Avalonia" Version="2.5.7" />
<PackageVersion Include="FFmpegVideoPlayer.Avalonia" Version="2.5.7" />
<PackageReference Include="FFmpegVideoPlayer.Avalonia" />
paket add FFmpegVideoPlayer.Avalonia --version 2.5.7
#r "nuget: FFmpegVideoPlayer.Avalonia, 2.5.7"
#:package FFmpegVideoPlayer.Avalonia@2.5.7
#addin nuget:?package=FFmpegVideoPlayer.Avalonia&version=2.5.7
#tool nuget:?package=FFmpegVideoPlayer.Avalonia&version=2.5.7
FFmpegVideoPlayer.Avalonia
Self-contained FFmpeg video player for Avalonia UI.

Installation
Basic Installation (Video Only)
dotnet add package FFmpegVideoPlayer.Avalonia
The core package works without any additional dependencies. Audio playback is optional.
FFmpeg Binaries
By default, the NuGet package includes FFmpeg binaries for Windows x64 and macOS ARM64. However, you can:
Use your own FFmpeg binaries (recommended to avoid conflicts):
// In Program.cs or before creating VideoPlayerControl FFmpegInitializer.Initialize(customPath: @"C:\ffmpeg\bin", useBundledBinaries: false);Disable bundled binaries to reduce package size:
FFmpegInitializer.Initialize(useBundledBinaries: false); // Will search system PATH and common installation locationsUse bundled binaries (default behavior):
FFmpegInitializer.Initialize(); // Uses bundled binaries if available
Priority order when initializing:
- Custom path (if provided) - highest priority
- Bundled binaries (if
useBundledBinaries=trueand present) - System discovery (PATH, common installation locations)
With Audio Support (Optional)
To enable audio playback, also install the OpenTK audio package:
dotnet add package FFmpegVideoPlayer.Audio.OpenTK
Then set the AudioPlayerFactory property on VideoPlayerControl:
using FFmpegVideoPlayer.Audio.OpenTK;
using FFmpegVideoPlayer.Core;
// In your window/control initialization
VideoPlayer.AudioPlayerFactory = (sampleRate, channels) =>
AudioPlayerFactory.Create(sampleRate, channels);
If AudioPlayerFactory is not set (or set to null), the player will work in video-only mode without crashing.
Troubleshooting Audio Issues
If audio is not working, check the following:
OpenAL Native Libraries (Windows): OpenTK 4.x does not bundle OpenAL native libraries on Windows. You need to install OpenAL Soft separately:
- Download the Windows installer from OpenAL Soft Downloads
- Install it system-wide (places
openal32.dllin System32) - OR copy
openal32.dllto your application's output directory - The
AudioPlayerFactory.Create()method will returnnullif OpenAL is not available, allowing the player to continue in video-only mode
Error Handling: The
AudioPlayerFactory.Create()method returnsnullif initialization fails, allowing the player to continue in video-only mode. Check debug output for detailed error messages.Sample Rate/Format: Ensure your media file has a supported audio format. The player will automatically resample to stereo S16 format.
Alternative Solutions:
- If you cannot install OpenAL system-wide, you can download
openal32.dllfrom OpenAL Soft and place it in your application's output directory (next to your .exe) - For distribution, include
openal32.dllwith your application
- If you cannot install OpenAL system-wide, you can download
Try the Example
git clone https://github.com/jojomondag/FFmpegVideoPlayer.Avalonia.git
cd FFmpegVideoPlayer.Avalonia/examples/FFmpegVideoPlayerExample
dotnet run
FFmpegMediaPlayer API
Properties
| Property | Type | Default | Description |
|---|---|---|---|
Source |
string? |
null |
Video file path or URL |
AutoPlay |
bool |
false |
Auto-play when media is loaded |
Volume |
int |
100 |
Volume level (0-100) |
ShowBuiltInControls |
bool |
true |
Show/hide control bar |
ShowOpenButton |
bool |
true |
Show/hide file picker button |
ControlPanelBackground |
IBrush? |
White |
Control bar background brush |
VideoBackground |
IBrush? |
Black |
Video area background (set to Transparent for overlays) |
VideoStretch |
Stretch |
Uniform |
Video stretch mode (None, Fill, Uniform, UniformToFill) |
EnableKeyboardShortcuts |
bool |
true |
Enable keyboard controls (Space, Arrow keys, M) |
AudioPlayerFactory |
Func<int, int, IAudioPlayer?>? |
null |
Optional factory for audio playback. Set to enable audio, leave null for video-only mode. |
IconProvider |
IIconProvider? |
null |
Optional custom icon provider. If null, default Avalonia shapes are used. |
CurrentMediaPath |
string? |
null |
Full path of currently loaded media (read-only) |
HasMediaLoaded |
bool |
false |
Whether media is currently loaded (read-only) |
IsPlaying |
bool |
false |
Whether playback is active (read-only) |
Position |
long |
0 |
Current playback position in milliseconds (read-only) |
Duration |
long |
0 |
Total media duration in milliseconds (read-only) |
Methods
| Method | Parameters | Description |
|---|---|---|
Open(string path) |
path: File path or URL |
Opens and loads a media file |
OpenUri(Uri uri) |
uri: Media URI |
Opens media from a URI |
Play() |
- | Starts or resumes playback |
Pause() |
- | Pauses playback |
Stop() |
- | Stops playback and resets position |
TogglePlayPause() |
- | Toggles between play and pause |
Seek(float positionPercent) |
positionPercent: 0.0 to 1.0 |
Seeks to specific position |
ToggleMute() |
- | Toggles mute state |
Events
| Event | EventArgs | Description |
|---|---|---|
PlaybackStarted |
EventArgs |
Raised when playback starts |
PlaybackPaused |
EventArgs |
Raised when playback is paused |
PlaybackStopped |
EventArgs |
Raised when playback is stopped |
MediaOpened |
MediaOpenedEventArgs |
Raised when media is successfully opened |
MediaEnded |
EventArgs |
Raised when media reaches the end |
Custom Icons
The player uses standard Avalonia shapes for icons by default (no Material.Icons dependency). To use custom icons, implement IIconProvider:
public class MyIconProvider : IIconProvider
{
public Geometry CreatePlayIcon() => /* your custom geometry */;
public Geometry CreatePauseIcon() => /* your custom geometry */;
// ... implement other methods
}
// Then set it on the control
VideoPlayer.IconProvider = new MyIconProvider();
Dependencies
Required
- Avalonia (11.3.6+) - UI framework
- FFmpegVideoPlayer.Core - Core player logic (included)
Optional
- FFmpegVideoPlayer.Audio.OpenTK - Audio playback support (optional, video-only mode works without it)
- Material.Icons.Avalonia - Not required. Icons use standard Avalonia shapes by default.
Platform Support
| Platform | Bundled Binaries | Custom Binaries |
|---|---|---|
| Windows x64 | ✅ Optional | ✅ Supported |
| macOS ARM64 | ✅ Optional | ✅ Supported |
| macOS x64 | ⚠️ Not bundled | ✅ Supported (use custom path) |
| Linux | ⚠️ Not bundled | ✅ Supported (use custom path) |
Note: Bundled binaries are optional. You can use your own FFmpeg installation by providing a customPath to FFmpegInitializer.Initialize(). This avoids conflicts with other libraries and reduces package size.
License
MIT
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | 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 was computed. 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 was computed. 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. |
-
net8.0
- Avalonia (>= 11.3.6)
- FFmpegVideoPlayer.Core (>= 2.5.6)
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 |
|---|---|---|
| 2.6.1 | 55 | 3/25/2026 |
| 2.6.0 | 45 | 3/25/2026 |
| 2.5.8 | 46 | 3/25/2026 |
| 2.5.7 | 48 | 3/25/2026 |
| 2.5.6 | 46 | 3/25/2026 |
| 2.5.5 | 45 | 3/25/2026 |
| 2.5.4 | 48 | 3/25/2026 |
| 2.5.3 | 50 | 3/25/2026 |
| 2.5.2 | 51 | 3/25/2026 |
| 2.5.1 | 47 | 3/25/2026 |
| 2.5.0 | 47 | 3/25/2026 |
| 2.4.3 | 44 | 3/25/2026 |
| 2.4.2 | 50 | 3/25/2026 |
| 2.4.1 | 59 | 3/25/2026 |
| 2.4.0 | 59 | 3/25/2026 |
| 2.3.2 | 61 | 3/25/2026 |
| 2.3.1 | 54 | 3/25/2026 |
| 2.3.0 | 65 | 3/25/2026 |
| 2.2.3 | 56 | 3/25/2026 |
| 2.2.2 | 58 | 3/25/2026 |
v2.3.0: Customizable control panel styling via StyledProperties: IconSize, ControlFontSize, ButtonPadding, ControlPanelPadding, ButtonCornerRadius, ControlForeground, ButtonBackground. CpuVideoRenderer now reports correct desired size via MeasureOverride. v2.2.0: Added DecodeFirstFrame() for instant thumbnail preview. v2.1.8: Fixed audio/video sync. v2.1.7: Keyboard shortcuts.