Shirei v0.10
Cross-platform video playback
2026.11.24
Shirei is a Go-based cross-platform GUI framework. Version v0.10.0 was released on 2026-11-24.
The main addition in this release is go.hasen.dev/shirei/media: cross-platform video playback across macOS, Windows, Linux, iOS, and Android. Video frames are presented as ordinary Shirei images through the GPU compositor, so translucent controls, labels, tooltips, and popups hover cleanly above playing video without native child-window z-order workarounds.
If you have Go installed, you can try the included video player example directly:
go run go.hasen.dev/shirei/examples/video_player@v0.10.0
Two constraints shaped the design of shirei/media:
- No LGPL/GPL dependencies in default builds. Applications should not have to bundle or ship FFmpeg to play common formats.
- No cgo required on desktop. macOS, Windows, and Linux all build with
CGO_ENABLED=0by default. CGO is only needed on mobile (where the platform app backends already require it) and for the opt-in-tags libavbackend on Linux and Windows.
Meeting both constraints across five operating systems turns out to be mostly a story about format and codec compatibility—what each OS gives you for free, where it falls short, and how to fill the gaps cleanly.
Format and OS compatibility matrix
Each cell below shows which decoding layer provides support on that platform:
Containers
| Container | macOS | Windows | Linux | iOS | Android |
|---|---|---|---|---|---|
| MP4 / MOV | OS BSD | OS BSD | GSt BSD | OS BSD | OS |
| WebM | BSD | BSD | GSt BSD | BSD | OS |
| MKV | BSDAV1 / VPx | BSDAV1 / VPx | GSt BSD | BSDAV1 / VPx | PartialOS dependent |
| HLS (.m3u8) | OS | No | No | OS | OS |
Video codecs
| Video Codec | macOS | Windows | Linux | iOS | Android |
|---|---|---|---|---|---|
| H.264 (AVC) | OS | OS | GStDistro plugins / OpenH264 | OS | OS |
| AV1 | BSD+ OS on M3+ | BSD+ Store ext | GSt BSD | BSD+ OS on A17 Pro+ | OSAndroid 10+ |
| VP9 | BSD | BSD+ Store ext | GSt BSD | BSD | OS |
| VP8 | BSD | BSD | GSt BSD | BSD | OS |
| HEVC (H.265) | OS | PartialPaid Store ext | PartialDistro plugins | OS | OSAPI 21+ |
Audio codecs
| Audio Codec | macOS | Windows | Linux | iOS | Android |
|---|---|---|---|---|---|
| AAC | OS | OS | GStDistro plugins | OS | OS |
| Opus | BSD | BSD | GSt BSD | BSD+ OS in MP4 | OS |
| Vorbis | BSD | BSD | GSt BSD | BSD | OS |
| MP3 | OS | OS | GSt | OS | OS |
| FLAC | OSin MP4 / MOV | OS | GSt | OSin MP4 | OS |
Two format combinations work safely across all five native platforms:
- MP4 (H.264 + AAC) — handled by the OS decoder on macOS, Windows, iOS, and Android, and by system GStreamer/OpenH264/FFmpeg on Linux.
- WebM or MP4 (VP9 or AV1 + Opus) — royalty-free and independent of patented distro codecs, handled by the BSD codec layer on macOS, Windows, iOS, and Linux, and natively by the OS on Android.
On Web (Wasm), media.Open currently returns media.ErrUnsupported.
Why two layers: OS decoders + permissive BSD codecs
Relying on OS decoders alone leaves big holes in the matrix:
- Apple's AVFoundation (macOS and iOS) handles H.264, HEVC, and AAC with hardware acceleration, but rejects WebM, MKV, VP8, VP9, and Vorbis, and only supports AV1 in hardware on M3 / A17 Pro and newer chips.
- Windows Media Foundation ships with H.264, AAC, MP3, and FLAC, but leaves WebM, VP8, VP9, AV1, and Opus dependent on optional Microsoft Store extensions (and HEVC behind a paid Store extension).
- Linux has no single universal media API, and distributions like Fedora or openSUSE exclude patented codecs from default installs.
On the other hand, dropping OS decoders in favor of a single bundled software stack would either pull in LGPL/GPL FFmpeg or give up hardware-accelerated H.264 and HEVC on desktop and mobile.
Shirei combines both:
- The OS media framework handles patented and hardware-accelerated formats (H.264, HEVC, AAC, MP3, FLAC, HLS) wherever the OS provides them.
- A permissive fallback pipeline fills in the open web formats (WebM, MKV, and MP4 carrying AV1, VP9, VP8, Opus, or Vorbis). It is built from pure-Go MP4 and WebM/MKV demuxers paired with four BSD-2/3 codec libraries:
libdav1d(AV1),libvpx(VP8/VP9),libopus(Opus), andlibvorbis(Vorbis).
When media.Open is given a local file, Shirei sniffs the container header and track codecs before opening a decoder. If the file uses a container or codec that the platform's OS decoder cannot reliably play (such as WebM, VP8/VP9, AV1, Opus, or Vorbis), Shirei routes it directly to the permissive BSD pipeline instead of letting the OS decoder fail.
On desktop (macOS, Windows, Linux), those four BSD libraries are loaded dynamically at runtime via purego—so desktop builds stay CGO_ENABLED=0 and keep working even if a library is absent (they simply skip unavailable codecs). The loader checks SHIREI_CODEC_DIR, the executable's directory, macOS ../Frameworks, Homebrew, and standard system library paths.
How each platform works
macOS (CGO_ENABLED=0)
- What the OS gives us:
AVFoundation(AVPlayer+AVPlayerItemVideoOutput), called directly throughpurego's Objective-C runtime bridge with zero cgo. It gives hardware-accelerated MP4, MOV, HLS, H.264, HEVC, AAC, MP3, and FLAC (plus hardware AV1 on M3+). DecodedCVPixelBufferframes are backed by anIOSurface, which Shirei wraps as a MetalMTLTexturewith zero CPU pixel copy (falling back to CPU RGBA whenSHIREI_GPU=0). - What we compensate for: WebM, MKV, VP8, VP9, Vorbis, Opus, and AV1 on older Apple Silicon / Intel Macs (as well as AV1+Opus combinations in MP4). Header sniffing routes those tracks to the pure-Go demuxers and
libdav1d/libvpx/libopus/libvorbisviapurego, uploading decoded frames through Shirei's GPU image path and outputting audio through Shirei's audio backend.
iOS (CGO_ENABLED=1)
- What the OS gives us:
AVFoundationvia an Objective-C/cgo bridge (iOS apps already build with cgo for the UIKit host). It covers MP4, MOV, HLS, H.264, HEVC, AAC, MP3, FLAC-in-MP4, and Opus-in-MP4 (plus hardware AV1 on A17 Pro+), handingIOSurfaceframes straight into Metal with zero CPU copy. It also wires into iOS lifecycle events—pausing automatically on backgrounding, audio session interruptions, and headphone unplug. - What we compensate for: The same WebM, MKV, VP8, VP9, AV1, Opus, and Vorbis gaps as macOS. Because iOS apps cannot load arbitrary system dynamic libraries, Shirei provides a one-time cross-compile script (
shirei/media/scripts/build_ios_codecs.sh) that builds static.aarchives for the BSD codecs (~2.4 MB total). When those archives are present in the cache (orSHIREI_IOS_CODECS_DIR),shirei_mobilerunautomatically links them with no Go build tags required.
Windows (CGO_ENABLED=0)
- What the OS gives us: Windows Media Foundation (
IMFMediaEnginein D3D11 frame-server mode), called via COM vtables throughpuregowith zero cgo. Out of the box, Media Foundation decodes MP4/MOV, H.264, AAC, MP3, and FLAC, transferring each frame to a DXGI shared D3D11 texture that Shirei's D3D11 compositor samples directly on the GPU. - What we compensate for: On stock Windows installations without Microsoft Store codec packs, WebM, MKV, AV1, VP9, VP8, Opus, and Vorbis fail in Media Foundation. Shirei sniffs those files and routes them to the pure-Go demuxers + BSD codec DLLs via
purego, uploading NV12 Y/UV planes directly to a D3D11 shader so color conversion stays on the GPU. For applications that want full FFmpeg coverage on Windows, an opt-in-tags libav(CGO_ENABLED=1) backend is also available.
Android (CGO_ENABLED=1)
- What the OS gives us:
android.media.MediaPlayerconnected to aSurfaceTextureover JNI/cgo, sampled directly in Shirei's GLES compositor viaGL_TEXTURE_EXTERNAL_OESwith zero CPU copy. Playback also integrates withAudioManagerfocus and pauses cleanly onAPP_CMD_PAUSEandAPP_CMD_STOP. - What we compensate for: Nothing—Android is the one platform where the OS media stack already covers almost the entire matrix natively: MP4, WebM, HLS, H.264, HEVC (API 21+), VP8, VP9, AV1 (Android 10+), AAC, Opus, Vorbis, MP3, and FLAC. Only MKV remains partial, depending on the device's OS build.
Linux (CGO_ENABLED=0 by default)
Linux is the trickiest desktop target because there is no single guaranteed media stack, and distributions differ sharply on patented codecs (Fedora and openSUSE ship without patented H.264/HEVC/AAC decoders by default unless the user enables extra repositories or Fedora's Cisco OpenH264).
Shirei handles Linux with an automatic layered fallback chain, where every default layer builds with CGO_ENABLED=0:
- System GStreamer 1.0 (
purego): Loaded dynamically at runtime for in-process decoding and seeking. It automatically picks up whatever the user's distribution provides—including VA-API hardware acceleration, OpenH264, and installed codec plugins. - Permissive BSD codecs (
purego): Pure-Go WebM/MKV/MP4 demuxers +libdav1d/libvpx/libopus/libvorbis. Even on a minimal or patent-stripped distro without GStreamer plugins, WebM and MP4 with AV1/VP9/VP8 + Opus/Vorbis still play in-process. ffmpeg/ffprobeCLI subprocess fallback: Last-resort fallback if neither GStreamer nor the BSD codecs can open the file, using theffmpegbinary onPATHif present.- Opt-in
-tags libav(CGO_ENABLED=1): For builds that explicitly opt into LGPL/cgolibavformat/libavcodec, Shirei also includes an in-processlibav*backend with zero-copy VA-APIdmabufimport into Wayland EGL/GLES.
In all Linux stream paths, decoded NV12 frames upload as two-plane Y/UV textures converted in the GLES fragment shader rather than converting YUV to RGBA on the CPU.
Other highlights in v0.10
While video playback is the centerpiece, building it pushed several general-purpose improvements into the core framework:
- Public external GPU textures (
UseExternalImage): Applications producing their own GPU textures—camera feeds, custom decoders, offscreen renderers—can now registerExternalIOSurfaceBGRA,ExternalD3D11Texture,ExternalNV12,ExternalDMABuf, orExternalAndroidSurfaceTexturedirectly with Shirei's compositor. - Thread-safe image registry &
Post(fn):UseImage,UseExternalImage,ReleaseImage, andLookupImageare now safe to call from any goroutine without holding the frame lock, andPost(fn)queues UI-thread state updates cleanly from background goroutines with automatic wake and redraw. - Upgraded
widgets.FileBrowser&FileBrowserModal: Clickable path breadcrumbs, quick-jump places, direct path entry, Name/Date/Size sorting, Hidden and All-files toggles, symlink traversal, mobile-adapted sizing, and modal wrappers. - New examples: Alongside
examples/video_player, this release addsexamples/go_board(tabbed Go games with a window-fitted board) and reload/history navigation in Markdown Viewer.
The agent-oriented manual has been updated for v0.10.0 (including the new video playback guide), and the full release notes are in the v0.10.0 changelog.

GitHub