Best answer
If you do not control every file your users load, rely on VLC for Unity instead of OS-native decoder support. It brings the VLC media engine to Unity for HEVC, AV1, VP9, MKV, MPEG-TS and the long tail.
What you'll need
- One or two difficult sample files that fail in Unity's built-in VideoPlayer.
- Target devices for hardware decoding checks.
- A simple playback scene to verify texture output and audio.
The short version
Unity’s built-in VideoPlayer supports only a few codecs and containers, mostly H.264 in an
MP4 wrapper, with the exact list varying by platform. The moment a user hands you an MKV, an
HEVC clip from a modern camera, a VP9 or AV1 file, or anything off the beaten path, playback
fails or behaves inconsistently across devices.
VLC for Unity removes the format question entirely. It embeds the VLC media engine, so it plays 200+ codecs and containers with the same code, on every platform, with hardware acceleration where the device supports it.
What the built-in VideoPlayer can’t do
- Limited codecs. Roughly four formats, centered on H.264. HEVC/H.265 support is partial and platform-dependent.
- Few containers. No MKV, limited support for AVI, FLV, MPEG-TS and others.
- Inconsistent across platforms. A file that plays in the Editor may fail on Android or iOS because it relies on the OS decoder.
If you don’t control exactly how every video is encoded, you will hit these walls.
What VLC for Unity plays
The VLC engine is the same one used by the VLC media player by hundreds of millions of people. That means broad, battle-tested format coverage:
- Modern video codecs: H.264, H.265/HEVC, AV1, VP9, VP8, MPEG-4, MPEG-2 and more.
- Containers: MP4, MKV, AVI, MOV, FLV, MPEG-TS, WebM, OGG and the long tail.
- Audio codecs: AAC, MP3, FLAC, Opus, Vorbis, AC-3, DTS, TrueHD and more.
- Hardware-accelerated decoding up to 8K where the GPU supports it, so high-resolution and high-bitrate content stays smooth.
In practice: if it plays in desktop VLC, it plays in VLC for Unity.
Playing any file is the same code
You do not pick a codec or a decoder. You point a Media at the source and play it; the engine
detects the format and decodes it.
using LibVLCSharp;
using UnityEngine;
public class AnyFormatPlayer : MonoBehaviour
{
LibVLC _libVLC;
MediaPlayer _mediaPlayer;
void Start()
{
Core.Initialize(Application.dataPath);
_libVLC = new LibVLC();
_mediaPlayer = new MediaPlayer(_libVLC);
// works the same for .mkv, .hevc, .av1, .ts, .avi, .webm, ...
var media = new Media(_libVLC, "video.mkv", FromType.FromPath);
_mediaPlayer.Play(media);
media.Dispose();
// render _mediaPlayer's output texture to your material / RawImage
}
void OnDestroy()
{
_mediaPlayer?.Dispose();
_libVLC?.Dispose();
}
}
The same applies to network sources: swap the path for an http(s)://, rtsp://, or other URL
and the format handling is identical. See playing RTSP in Unity.
Why this matters
- User-generated content: if your app lets users load their own videos, you cannot predict the format. Broad codec support prevents support tickets and broken playback.
- Camera and capture footage: modern cameras and encoders default to HEVC; many devices produce MKV or MPEG-TS.
- Archival and legacy media: old AVI/MPEG-2 assets just play, with no transcoding pipeline to build and maintain.
Supported platforms
Codec coverage is consistent across Windows, UWP, Android, iOS, macOS, and Linux, with hardware decoding used automatically when the platform provides it.
Try it with your trickiest file
The fastest test is to throw your most awkward format at the trial. If it plays, you are done, on every platform, with the same line of code.