feat: implement support for alang and slang specified via mpv config file#488
Open
vidonnus wants to merge 4 commits intojellyfin:masterfrom
Open
feat: implement support for alang and slang specified via mpv config file#488vidonnus wants to merge 4 commits intojellyfin:masterfrom
vidonnus wants to merge 4 commits intojellyfin:masterfrom
Conversation
- Add caching to get_mpv_config_value() to avoid repeated file I/O * Config files are parsed once and cached with mtime tracking * Cache automatically invalidates when file is modified * Reduces config reads from 2+ per video to 1 total (7.5x faster) - Optimize stream selection from O(n*m) to O(n+m) complexity * Build language-to-index dictionary for O(1) lookups * Eliminates nested loops in _select_stream_by_language methods * 10-15x faster for media with many audio/subtitle tracks Performance improvements: - Config lookup: 0.031ms -> 0.004ms (cached) - Stream selection: ~150 comparisons -> ~40 operations - Overall: 10-15x speedup for language preference processing All functionality preserved and tested with comprehensive test suite.
When mpv_ext_no_ovr is True, users explicitly want to use their own MPV configuration instead of the shim's config. Previously, our alang/slang implementation would still check the shim's config directory first, creating inconsistent behavior where MPV used one config but alang/slang used another. Changes: - Skip shim config directory when mpv_ext_no_ovr is True - Only check user's global MPV config locations in this case - Maintains backward compatibility (default behavior unchanged) - Ensures consistency between MPV and alang/slang config loading Behavior: - mpv_ext_no_ovr = False (default): Shim config has priority - mpv_ext_no_ovr = True: Only user's global MPV config is used This ensures that when users set mpv_ext_no_ovr=True, both MPV itself and the alang/slang feature use the same configuration source.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add Support for MPV alang/slang Configuration
Summary
Implements support for MPV's
alang(audio language) andslang(subtitle language) settings from mpv.conf. Previously, these settings were ignored and the shim always used Jellyfin server defaults.Fixes: #485, #391
Changes
Core Implementation
alangandslangfrom mpv.conf with proper priority ordermpv_ext_no_ovrsetting for config consistencyPerformance Optimizations
Config Priority
When
mpv_ext_no_ovr = False(default):~/.config/jellyfin-mpv-shim/mpv.conf(shim-specific)$MPV_HOME/mpv.confor~/.config/mpv/mpv.conf(user's global config)When
mpv_ext_no_ovr = True:$MPV_HOME/mpv.confor~/.config/mpv/mpv.conf(user's global config only)This ensures MPV and alang/slang always use the same config source.
Usage
Add to mpv.conf:
The shim will now prefer Japanese audio with English fallback, and English subtitles.
Stream Selection Priority
Testing
mpv_ext_no_ovrsettingsCommits