Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add mpv settings to enable high quality #652

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,20 @@ constructor(
options = R.array.mpv_aos,
optionValues = R.array.mpv_aos,
),
PreferenceSwitch(
nameStringResource = R.string.pref_player_mpv_hq,
descriptionStringRes = R.string.pref_player_mpv_hq_summary,
dependencies = listOf(Constants.PREF_PLAYER_MPV),
backendName = Constants.PREF_PLAYER_MPV_HQ,
backendDefaultValue = true,
),
PreferenceSwitch(
nameStringResource = R.string.pref_player_mpv_deband,
descriptionStringRes = R.string.pref_player_mpv_deband_summary,
dependencies = listOf(Constants.PREF_PLAYER_MPV_HQ),
backendName = Constants.PREF_PLAYER_MPV_DEBAND,
backendDefaultValue = false,
),
),
),
PreferenceCategory(
Expand Down
4 changes: 4 additions & 0 deletions core/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -192,4 +192,8 @@
<string name="unmark_as_played">Unmark as played</string>
<string name="add_to_favorites">Add to favorites</string>
<string name="remove_from_favorites">Remove from favorites</string>
<string name="pref_player_mpv_hq">High quality</string>
<string name="pref_player_mpv_hq_summary">Enable high quality playback. Might cause performance issues on older devices.</string>
<string name="pref_player_mpv_deband_summary">Removes banding artifacts at the cost of some fine detail</string>
<string name="pref_player_mpv_deband">Deband</string>
</resources>
12 changes: 12 additions & 0 deletions core/src/main/res/xml/fragment_settings_player.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,18 @@
app:key="pref_player_mpv_ao"
app:title="@string/pref_player_mpv_ao"
app:useSimpleSummaryProvider="true" />
<SwitchPreferenceCompat
app:defaultValue="true"
app:dependency="pref_player_mpv"
app:key="pref_player_mpv_hq"
app:summary="@string/pref_player_mpv_hq_summary"
app:title="@string/pref_player_mpv_hq" />
<SwitchPreferenceCompat
app:defaultValue="false"
app:dependency="pref_player_mpv_hq"
app:key="pref_player_mpv_deband"
app:summary="@string/pref_player_mpv_deband_summary"
app:title="@string/pref_player_mpv_deband" />
</PreferenceCategory>

<PreferenceCategory app:title="@string/gestures">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ class MPVPlayer(
videoOutput: String = "gpu-next",
audioOutput: String = "audiotrack",
hwDec: String = "mediacodec",
highQuality: Boolean,
deband: Boolean,
) : BasePlayer(), MPVLib.EventObserver, AudioManager.OnAudioFocusChangeListener {

private val audioManager: AudioManager by lazy { context.getSystemService()!! }
Expand All @@ -77,12 +79,17 @@ class MPVPlayer(
// General
MPVLib.setOptionString("config", "yes")
MPVLib.setOptionString("config-dir", mpvDir.path)
MPVLib.setOptionString("profile", "fast")
MPVLib.setOptionString("profile", if (highQuality) "high-quality" else "fast")
MPVLib.setOptionString("vo", videoOutput)
MPVLib.setOptionString("ao", audioOutput)
MPVLib.setOptionString("gpu-context", "android")
MPVLib.setOptionString("opengl-es", "yes")

if (deband && highQuality)
MPVLib.setOptionString("deband", "yes")
else
MPVLib.setOptionString("deband", "no")

// Hardware video decoding
MPVLib.setOptionString("hwdec", hwDec)
MPVLib.setOptionString("hwdec-codecs", "h264,hevc,mpeg4,mpeg2video,vp8,vp9,av1")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ constructor(
videoOutput = appPreferences.playerMpvVo,
audioOutput = appPreferences.playerMpvAo,
hwDec = appPreferences.playerMpvHwdec,
highQuality = appPreferences.playerMpvHq,
deband = appPreferences.playerMpvDeband,
)
} else {
val renderersFactory =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ constructor(
val playerMpvHwdec get() = sharedPreferences.getString(Constants.PREF_PLAYER_MPV_HWDEC, "mediacodec")!!
val playerMpvVo get() = sharedPreferences.getString(Constants.PREF_PLAYER_MPV_VO, "gpu-next")!!
val playerMpvAo get() = sharedPreferences.getString(Constants.PREF_PLAYER_MPV_AO, "audiotrack")!!
val playerMpvHq get() = sharedPreferences.getBoolean(Constants.PREF_PLAYER_MPV_HQ, true)
val playerMpvDeband get() = sharedPreferences.getBoolean(Constants.PREF_PLAYER_MPV_DEBAND, false)
val playerIntroSkipper get() = sharedPreferences.getBoolean(Constants.PREF_PLAYER_INTRO_SKIPPER, true)
val playerTrickplay get() = sharedPreferences.getBoolean(Constants.PREF_PLAYER_TRICKPLAY, true)
val showChapterMarkers get() = sharedPreferences.getBoolean(Constants.PREF_PLAYER_CHAPTER_MARKERS, true)
Expand Down
2 changes: 2 additions & 0 deletions preferences/src/main/java/dev/jdtech/jellyfin/Constants.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ object Constants {
const val PREF_PLAYER_MPV_HWDEC = "pref_player_mpv_hwdec"
const val PREF_PLAYER_MPV_VO = "pref_player_mpv_vo"
const val PREF_PLAYER_MPV_AO = "pref_player_mpv_ao"
const val PREF_PLAYER_MPV_HQ = "pref_player_mpv_hq"
const val PREF_PLAYER_MPV_DEBAND = "pref_player_mpv_deband"
const val PREF_PLAYER_INTRO_SKIPPER = "pref_player_intro_skipper"
const val PREF_PLAYER_TRICKPLAY = "pref_player_trickplay"
const val PREF_PLAYER_CHAPTER_MARKERS = "pref_player_chapter_markers"
Expand Down
Loading