What is HLS?
HTTP Live Streaming (HLS) is an adaptive streaming protocol developed by Apple. It breaks the stream into small segments and delivers them via HTTP, allowing for:- Better seeking - Jump to any point in the stream
- Adaptive bitrate - Automatically adjust quality based on connection
- Better buffering - More granular buffering control
- Wider compatibility - Works with more players and devices
How Aceplay uses HLS
When HLS mode is enabled, Aceplay requests a manifest file (.m3u8) from acestream-engine instead of a direct stream URL.
Direct mode (default)
HLS mode
Enabling HLS mode
You can enable HLS mode in three ways:1. Command-line flag
2. Configuration file
Edit~/.config/aceplay/config.yaml:
3. Environment variable
When to use HLS mode
Use HLS when
- You need seeking/scrubbing support
- Using a player with limited codec support
- Experiencing buffering issues
- Want adaptive bitrate streaming
- Using VLC (better HLS support than direct)
Use direct mode when
- You want lower latency
- Seeking is not required
- Using mpv (excellent direct stream support)
- Want simpler streaming setup
- Minimal overhead is important
Player compatibility
All supported players work with both modes, but have different strengths:| Player | Direct Mode | HLS Mode | Recommendation |
|---|---|---|---|
| mpv | Excellent | Good | Use direct mode for best performance |
| vlc | Good | Excellent | Use HLS mode for better seeking |
| ffplay | Good | Good | Either mode works well |
HLS implementation details
Aceplay’s HLS implementation is located ininternal/acestream/client.go:293-307. Here’s how it works:
The acestream-engine handles the actual HLS segmentation and manifest generation. Aceplay simply requests the appropriate endpoint based on the mode.
Example usage
Basic HLS playback
HLS with specific player
HLS with custom engine
Make HLS default
Set it in your config file for all streams:Performance considerations
Latency
- Direct mode: 2-5 seconds latency
- HLS mode: 5-15 seconds latency (due to segment buffering)
Bandwidth
- Direct mode: Continuous stream, minimal overhead
- HLS mode: Segmented stream, slight overhead from manifest requests
CPU usage
Both modes have similar CPU usage. The player does the decoding, not Aceplay.Seeking and scrubbing
One of the main advantages of HLS mode is better seeking support:Direct mode
- Seeking may not work or may be slow
- Some players cache the entire stream before seeking
- Limited by how acestream-engine handles direct stream seeks
HLS mode
- Fast seeking to any point in the stream
- Players can request specific segments
- More predictable seeking behavior
Troubleshooting
HLS mode not working
HLS mode not working
Symptoms: Error when trying to play with
--hls flagSolutions:-
Verify acestream-engine is running and supports HLS:
- Check engine version (older versions may not support HLS)
-
Try without HLS to verify the stream itself works:
Buffering issues with HLS
Buffering issues with HLS
Symptoms: Frequent buffering or stuttering in HLS modeSolutions:
-
Increase player cache:
-
For VLC, the cache is already set to 3000ms (see
internal/player/player.go:78-82) - Check network connection to acestream-engine
- Try direct mode if buffering persists
Seeking not working in HLS mode
Seeking not working in HLS mode
Symptoms: Can’t seek/scrub even with HLS enabledSolutions:
-
Ensure the player supports HLS seeking:
- VLC: Full support
- mpv: Full support
- ffplay: Limited support
- Wait for the stream to buffer some content before seeking
-
Try a different player:
High latency in HLS mode
High latency in HLS mode
Symptoms: 10-20 second delay behind liveSolutions:This is normal for HLS due to segment buffering.If you need lower latency:
-
Use direct mode instead:
- Or accept the trade-off for seeking capability
Configuration precedence
When HLS mode is set in multiple places, the priority is:- CLI flag
--hls(highest priority) - Environment variable
ACEPLAY_HLS=true - Config file
hls: true - Default
false(direct mode)
Reference
- HLS URL generation:
internal/acestream/client.go:293-307 - Default mode:
internal/config/config.go:20(DefaultHLS = false) - CLI flag:
cmd/main.go:128(—hls flag)