Terminal interface to find, download, and stream movies, TV shows, and live TV using local media players.
fix(player): tune mpv and iina cache buffering to prevent stutter loops
Samir Hossainsb5fb7a6ae9f1
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 247964e..bb13041 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -9,7 +9,7 @@- Preserved stable card slot positions during search pagination in `src/tui/app/requests.rs` by appending subsequent page items to the list rather than re-sorting the entire array out from under the cursor.- **Media Playback & Buffering Engine**:- Prioritized native desktop media players (`mpv`, `VLC`) over Android intent openers in `src/player.rs` when an active X11/Wayland display server (`$DISPLAY`, `$WAYLAND_DISPLAY`) is detected, preventing Ubuntu Xfce (udroid/PRoot) and Termux:X11 desktop sessions from dispatching playback to external Android app choosers.- - Reduced `mpv` and `IINA` cache-pause wait penalty from 8 seconds to 2 seconds (`--cache-pause-wait=2`) and disabled startup cache pause (`--cache-pause-initial=no`) in `src/player.rs`, preventing multi-second playback stalls on minor network dips.+ - Configured `mpv` and `IINA` with initial cache buffering (`--cache-pause-initial=yes`) and resilient re-buffer cushion (`--cache-pause-wait=10`) in `src/player.rs`, preventing repeated 2-second stutter loops on bandwidth-constrained CDN streams.- Replaced aggressive VLC buffering flags (`--network-caching=10000`, `--adaptive-logic=nearoptimal`) with `--network-caching=3000` and `--adaptive-logic=predictive` in `src/player.rs` to stop demuxer stream restarts and 10-second stall loops.- Enabled HTTP/1.1 persistent connections (`Keep-Alive`) across DASH segment streaming in `src/proxy.rs`, eliminating recurring TCP handshake overhead.- Enforced `max_height` resolution limits in the loopback stream proxy manifest rewriter (`src/proxy.rs`, `src/main.rs`, `src/tui/app/playback.rs`), pruning representations exceeding the chosen ceiling so Android players and VLC respect 480p and 720p selections.diff --git a/src/player.rs b/src/player.rsindex 5098915..cfd5bb3 100644--- a/src/player.rs+++ b/src/player.rs@@ -430,8 +430,8 @@ fn mpv_command(command.arg(format!("{prefix}geometry=50%:50%"));command.arg(format!("{prefix}cache=yes"));command.arg(format!("{prefix}cache-pause=yes"));- command.arg(format!("{prefix}cache-pause-wait=2"));- command.arg(format!("{prefix}cache-pause-initial=no"));+ command.arg(format!("{prefix}cache-pause-wait=10"));+ command.arg(format!("{prefix}cache-pause-initial=yes"));let (max_bytes, back_bytes) =if cfg!(target_os = "android") || crate::updater::artifact::is_termux_environment() {("128M", "50M")@@ -1896,8 +1896,8 @@ mod tests {assert!(args.contains(&"--autofit=1920x1080".to_string()));assert!(args.contains(&"--cache=yes".to_string()));assert!(args.contains(&"--cache-pause=yes".to_string()));- assert!(args.contains(&"--cache-pause-wait=2".to_string()));- assert!(args.contains(&"--cache-pause-initial=no".to_string()));+ assert!(args.contains(&"--cache-pause-wait=10".to_string()));+ assert!(args.contains(&"--cache-pause-initial=yes".to_string()));assert!(args.contains(&"--demuxer-max-bytes=256M".to_string()));assert!(args.contains(&"--demuxer-readahead-secs=120".to_string()));assert!(args.contains(&"--demuxer-lavf-buffersize=1048576".to_string()));