r/iOSProgramming • u/tvrrp • 4d ago
Library SwiftExoPlayer – userspace media player for Apple platforms
https://github.com/tvrrp/SEPlayerI’ve been working on SEPlayer, a framework for building media players with almost all playback logic running entirely in userspace. Only decoding, video rendering, and audio playback are handled by the system.
One of the main goals is extensibility. Unlike AVPlayer, thanks to Dependency Injection SEPlayer allows you to change every part of the pipeline . And implement your own demuxer, use different renderers, or replace the ABR algorithm, much like ExoPlayer.
I’ve spent two years researching and experimenting with different playback pipelines. Initially, I followed ExoPlayer’s approach, but its high-frequency timer-based pipeline isn’t particularly power-efficient.
I think I’ve finally found a better solution: an event-driven pipeline that only does work when necessary.
The project is still in alpha, and there’s a lot left to implement.
Currently supported:
Progressive MP4, fMP4, and MPEG-TS playback
HLS
Planned:
MPEG-DASH
Additional containers and formats, including Matroska, AVI, MP3, and raw AAC streams
More stability improvements, error handling, and tests
There’s still a long way to go, but I wanted to share what I’ve been working on.
I’d be interested in hearing feedback, especially from anyone who’s worked on media playback pipelines or video players.
1
u/AlexCrypto222 4d ago
0
u/tvrrp 4d ago
I wanted to share a bit more about why I started SEPlayer.
My main motivation was the bugs and limitations I kept running into with AVPlayer.
At the time, we were trying to build a TikTok-style short-video feed with extremely fast startup times. The problem was that AVPlayer's default buffering behavior prioritizes avoiding stalls, which makes sense for long-form content, but isn't necessarily the right trade-off for short videos.
Meanwhile, our Android team was able to implement a custom buffering strategy to prioritize faster startup. Simply because ExoPlayer gave them that level of control. On iOS, we couldn't do the same.
Even collecting basic network metrics was a challenge. For example, time to first byte (TTFB) is an incredibly useful metric for understanding CDN performance, but back then, we couldn't reliably obtain it through AVPlayer.
Many major companies, including YouTube, Meta, and TikTok, have invested in their own playback infrastructure. But there were very few public examples showing how to build a native media playback pipeline on Apple platforms.
So I started with a simple question: Is it even possible?
What APIs would I need? Could I use the system's decoders and renderers while implementing everything else myself?
After a couple of months of experimenting, I realized I was already building a video player.
Of course, there are amazing projects like VLC and FFmpeg. But I wasn't looking for another ready-made player or a collection of media-processing libraries. I wanted a framework specifically designed for building custom media playback experiences.
That's what I want SEPlayer to become.
First, a public example of how to build a media playback pipeline using Apple's native APIs. Something other developers can learn from, experiment with, and build upon.
And eventually, something like ExoPlayer, but for Apple platforms.
I want developers to have the freedom to make their own trade-offs instead of being limited to the decisions made by AVPlayer.
For example:
- Prioritize startup time over buffering for short-form content.
- Collect detailed playback and network metrics to understand how their players actually perform.
- Support custom MP4 boxes, different containers, or formats that AVPlayer doesn't support.
- Experiment with alternative decoding pipelines, such as software AV1 decoding, to reduce bandwidth usage and CDN costs.
- Replace individual components of the pipeline without having to rewrite the entire player.
Ultimately, I don't think every company should have to build its own media player from scratch just to get more control over the playback experience.
There's still a huge amount of work ahead, but that's the direction I want to take this project.
And if nothing else, I hope SEPlayer can serve as a useful reference for anyone curious about how media playback actually works under the hood on Apple platforms.