Skip to content

feat(player): switch libmpv to a custom build with Vulkan and HDR support - #258

Merged
MakD merged 3 commits into
masterfrom
mpv-hdr-support
Oct 14, 2026
Merged

MakD merged 3 commits into
masterfrom
mpv-hdr-support

Conversation

@MakD

@MakD MakD commented Oct 14, 2026

Copy link
Copy Markdown
Owner

Summary

Replaces jarnedemeulemeester's dev.jdtech.mpv:libmpv:1.0.0 with a custom build of the same library, published as io.github.makd:libmpv:1.1.0, which is compiled with Vulkan and HDR support. The dev.jdtech.mpv.MPVLib API is unchanged, so this is close to a drop-in swap. With Vulkan available, the mpv GPU and HDR settings that were hidden in Player Options are turned back on.

Changes

libmpv / rendering

  • Swapped the libmpv dependency to io.github.makd:libmpv:1.1.0
  • GPU context is chosen from the GPU API setting:
    • Vulkan → gpu-context=androidvk
    • OpenGL → gpu-context=android + opengl-es=yes
  • With Vulkan, hwdec=mediacodec is promoted to mediacodec-copy
  • Added stop-playback-on-init-failure=yes so output init failures show up as errors instead of silently stalling

Settings

Re-enabled the mpv options in Player Options:

  • GPU API: OpenGL (default) / Vulkan (experimental)
  • HDR output: Auto (passthrough) / Always tone-map to SDR
  • Tone mapping: Auto, BT.2446a, Spline, Hable, Mobius, Clip
  • HDR peak detection

Error diagnostics

  • mpv end-file errors are now tracked; VO/AO init failures raise distinct error codes with steps the user can try (for example, "Try GPU API: OpenGL")
  • On stream load failures the player checks whether the server is reachable, so it can tell apart: server offline, local playback error, live channel unavailable, and server transcode failure
  • For admin sessions, the matching FFmpeg error is pulled from the server's recent transcode logs (redacted) and added to the error message

Player

  • PlayerActivity handles onNewIntent, so a new playback request replaces the current one
  • Speed controls, long-press speed-up and the < / > shortcuts are disabled on live channels, and speed resets to 1.0x when live playback starts
  • Shows a loading state while switching between items

Housekeeping

  • Moved coroutine delay / withTimeoutOrNull / debounce calls to kotlin.time.Duration across the codebase
  • Bumped Kotlin 2.4.20 → 2.4.21, AboutLibraries 15.2.0 → 15.3.0, commonmark 0.30.0 → 0.30.1

MakD added 3 commits October 14, 2026 14:31
This commit migrates the player backend from `dev.jdtech.mpv` to `io.github.marlboro-advance:mpv-android`, introducing a dedicated `MpvHandle` wrapper for lifecycle management and Vulkan GPU context support. Additionally, it improves `PlayerActivity` intent handling and disables playback speed adjustments during live stream playback.

Key changes:
* Library Migration: Switched `libmpv` dependency to `io.github.marlboro-advance:mpv-android` and updated ProGuard rules to retain `is.xyz.mpv.**` JNI classes.
* `MpvHandle` Lifecycle Wrapper: Created `MpvHandle` to manage libmpv creation, observer registration/cleanup, and lifecycle state to prevent concurrent native state corruption.
* Vulkan Support & Config: Configured GPU context dynamically (`androidvk` for Vulkan, `android` with OpenGL ES otherwise) and adjusted hardware decoding to `mediacodec-copy` when using Vulkan.
* Re-enabled MPV Settings: Restored advanced MPV settings in `PlayerOptionsScreen`, including GPU API, Tone Mapping, and HDR Peak Detection options.
* New Intent Handling in Player: Added `PlaybackRequest` data model and implemented `onNewIntent` in `PlayerActivity` to seamlessly update active playback when receiving a new playback intent.
* Live Playback Restrictions: Disabled speed modification controls, long-press speed-up, and keyboard shortcuts (`<` / `>`) when playing live channels, and automatically reset playback speed to 1.0x upon starting live playback.
* Stale Item Indicator: Updated `PlayerScreenWrapper` to display a loading state while transitioning between different media item IDs.
…uts, and debounces

This commit migrates raw numeric millisecond arguments passed to coroutine and flow time-based functions (`delay`, `withTimeoutOrNull`, and `debounce`) to type-safe Kotlin `Duration` extensions (`milliseconds`, `seconds`, `minutes`) across the codebase, improving code readability and consistency.

Key changes:
* Type-Safe Durations: Replaced raw numeric millisecond and second parameters with `Duration` equivalents across repositories, ViewModels, UI components, background workers, and playback managers.
* Coroutine Scope Clarification: Added explicit labeled scoping (`this@mediaChanges.launch`) in `AppDataRepository` to clarify nested coroutine launching during media change events.
* Minor Range Cleanup: Simplified sleep timer prompt threshold check in `PlayerViewModel` using Kotlin range containment (`in 1L..SLEEP_TIMER_PROMPT_THRESHOLD_MS`).
This commit migrates the player from the previous MPV wrapper to an updated `libmpv` library, while significantly enhancing error reporting and diagnostics across playback failures, including server-side transcode error inspection for admins.

Key changes:
* Updated `libmpv` Dependency: Upgraded to `io.github.makd:libmpv:1.1.0` using `dev.jdtech.mpv.MPVLib`, removing the legacy `MpvHandle` wrapper and outdated ProGuard rules.
* Output Failure Handling in MPV: Added handling for `endFile` error codes, surfacing distinct error codes for audio (`AO_INIT_FAILED`) and video (`VO_INIT_FAILED`) output initialization failures with tailored troubleshooting messages.
* Server Transcode Log Inspection: Added `getTranscodeFailureReason` in `ServerAdminRepository` to fetch and parse recent FFmpeg logs matching the failed media source, extracting and redacting error lines.
* Enhanced Player Error Reporting: Updated `PlayerViewModel` to verify server reachability on stream load failures, differentiating between offline server, local playback errors, live channel drops, and server transcoding failures.
* Admin Error Insights: For administrative sessions, playback error messages now asynchronously retrieve and append the server's transcode failure reason to the on-screen error prompt.
* New String Resources: Added user-facing strings for video output errors, audio output errors, unavailable live channels, failed streams, and formatted server failure reasons.
@MakD
MakD marked this pull request as ready for review October 14, 2026 22:41
@MakD
MakD merged commit 5757b92 into master Oct 14, 2026
0 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant