mpv: setup profiles by which to tune youtube quality preferences and debanding
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
{ config, lib, pkgs, ... }:
|
||||
{ config, pkgs, ... }:
|
||||
{
|
||||
imports = [
|
||||
./fs.nix
|
||||
@@ -44,6 +44,8 @@
|
||||
brightness = false;
|
||||
};
|
||||
|
||||
sane.programs.mpv.config.default_profile = "high-quality";
|
||||
|
||||
sane.image.extraBootFiles = [ pkgs.bootpart-uefi-x86_64 ];
|
||||
|
||||
# needed to use libimobiledevice/ifuse, for iphone sync
|
||||
|
@@ -6,7 +6,7 @@
|
||||
# - Mobian wiki: <https://wiki.mobian-project.org/doku.php?id=start>
|
||||
# - recommended apps, chatrooms
|
||||
|
||||
{ config, pkgs, lib, ... }:
|
||||
{ config, ... }:
|
||||
{
|
||||
imports = [
|
||||
./fs.nix
|
||||
@@ -71,6 +71,8 @@
|
||||
max-quantum = 8192;
|
||||
};
|
||||
|
||||
sane.programs.mpv.config.default_profile = "fast";
|
||||
|
||||
# /boot space is at a premium. default was 20.
|
||||
# even 10 can be too much
|
||||
boot.loader.generic-extlinux-compatible.configurationLimit = 8;
|
||||
|
@@ -138,6 +138,22 @@ let
|
||||
in
|
||||
{
|
||||
sane.programs.mpv = {
|
||||
configOption = with lib; mkOption {
|
||||
default = {};
|
||||
type = types.submodule {
|
||||
options = {
|
||||
default_profile = mkOption {
|
||||
type = types.enum [ "high-quality" "mid-range" "fast" ];
|
||||
default = "mid-range";
|
||||
description = ''
|
||||
default mpv profile to use.
|
||||
this affects options such as the default youtube stream settings.
|
||||
see my `mpv.conf` for details
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
packageUnwrapped = pkgs.mpv-unwrapped.wrapper {
|
||||
mpv = pkgs.mpv-unwrapped.override rec {
|
||||
# N.B.: populating `self` to `luajit` is necessary for the resulting `lua.withPackages` function to preserve my override.
|
||||
@@ -154,35 +170,6 @@ in
|
||||
# visualizer #< XXX(2024-07-23): `visualizer` breaks auto-play-next-track (only when visualizations are disabled)
|
||||
# pkgs.mpv-uosc-latest
|
||||
];
|
||||
# extraMakeWrapperArgs = lib.optionals (cfg.config.vo != null) [
|
||||
# # 2023/08/29: fixes an error where mpv on moby launches with the message
|
||||
# # "DRM_IOCTL_MODE_CREATE_DUMB failed: Cannot allocate memory"
|
||||
# # audio still works, and controls, screenshotting, etc -- just not the actual rendering
|
||||
# #
|
||||
# # this is likely a regression for mpv 0.36.0.
|
||||
# # the actual error message *appears* to come from the mesa library, but it's tough to trace.
|
||||
# #
|
||||
# # 2024/03/02: no longer necessary, with mesa 23.3.1: <https://github.com/NixOS/nixpkgs/pull/265740>
|
||||
# #
|
||||
# # backend compatibility (2023/10/22):
|
||||
# # run with `--vo=help` to see a list of all output options.
|
||||
# # non-exhaustive (W=works, F=fails, A=audio-only, U=audio+ui only (no video))
|
||||
# # ? null Null video output
|
||||
# # A (default)
|
||||
# # A dmabuf-wayland Wayland dmabuf video output
|
||||
# # A libmpv render API for libmpv (mpv plays the audio, but doesn't even render a window)
|
||||
# # A vdpau VDPAU with X11
|
||||
# # F drm Direct Rendering Manager (software scaling)
|
||||
# # F gpu-next Video output based on libplacebo
|
||||
# # F vaapi VA API with X11
|
||||
# # F x11 X11 (software scaling)
|
||||
# # F xv X11/Xv
|
||||
# # U gpu Shader-based GPU Renderer
|
||||
# # W caca libcaca (terminal rendering)
|
||||
# # W sdl SDL 2.0 Renderer
|
||||
# # W wlshm Wayland SHM video output (software scaling)
|
||||
# "--add-flags" "--vo=${cfg.config.vo}"
|
||||
# ];
|
||||
};
|
||||
|
||||
suggestedPrograms = [
|
||||
@@ -223,7 +210,10 @@ in
|
||||
fs.".config/mpv/scripts/sane_sysvol/main.lua".symlink.target = ./sane_sysvol/main.lua;
|
||||
fs.".config/mpv/scripts/sane_sysvol/non_blocking_popen.lua".symlink.target = ./sane_sysvol/non_blocking_popen.lua;
|
||||
fs.".config/mpv/input.conf".symlink.target = ./input.conf;
|
||||
fs.".config/mpv/mpv.conf".symlink.target = ./mpv.conf;
|
||||
fs.".config/mpv/mpv.conf".symlink.target = pkgs.substituteAll {
|
||||
src = ./mpv.conf;
|
||||
inherit (cfg.config) default_profile;
|
||||
};
|
||||
fs.".config/mpv/script-opts/console.conf".symlink.target = ./console.conf;
|
||||
fs.".config/mpv/script-opts/osc.conf".symlink.target = ./osc.conf;
|
||||
fs.".config/mpv/script-opts/playlistmanager.conf".symlink.target = ./playlistmanager.conf;
|
||||
|
@@ -1,3 +1,11 @@
|
||||
# options, profiles, etc:
|
||||
# - example config: <https://thewiki.moe/tutorials/mpv/>
|
||||
# - example config: <https://iamscum.wordpress.com/guides/videoplayback-guide/mpv-conf/>
|
||||
# - default profiles: <https://github.com/mpv-player/mpv/blob/master/etc/builtin.conf>
|
||||
# or: `mpv --profile=help`
|
||||
# or: `mpv --show-profile=high-quality` (etc)
|
||||
# - available options and their defaults: `mpv --list-options`
|
||||
|
||||
# write ~/.local/state/mpv/watch_later on exit, to allow resume
|
||||
save-position-on-quit=yes
|
||||
# identify resumed files by filename only, since i use so many symlinks and doubt mpv does well with that.
|
||||
@@ -26,3 +34,87 @@ border=no
|
||||
# # with `ao-volume`, the max actually is 100.
|
||||
# # to go higher you'll have to use the system's native controls.
|
||||
# volume-max=100
|
||||
|
||||
# backend compatibility (2023/10/22):
|
||||
# run with `--vo=help` to see a list of all output options.
|
||||
# non-exhaustive (W=works, F=fails, A=audio-only, U=audio+ui only (no video))
|
||||
# ? null Null video output
|
||||
# A (default)
|
||||
# A dmabuf-wayland Wayland dmabuf video output
|
||||
# A libmpv render API for libmpv (mpv plays the audio, but doesn't even render a window)
|
||||
# A vdpau VDPAU with X11
|
||||
# F drm Direct Rendering Manager (software scaling)
|
||||
# F gpu-next Video output based on libplacebo
|
||||
# F vaapi VA API with X11
|
||||
# F x11 X11 (software scaling)
|
||||
# F xv X11/Xv
|
||||
# U gpu Shader-based GPU Renderer
|
||||
# W caca libcaca (terminal rendering)
|
||||
# W sdl SDL 2.0 Renderer
|
||||
# W wlshm Wayland SHM video output (software scaling)
|
||||
# vo=@vo@
|
||||
|
||||
# audio and subtitle language preferences
|
||||
alang=en,eng,ja,jp,jpn
|
||||
slang=en,eng
|
||||
# show subtitles more immediately when seeking through video
|
||||
demuxer-mkv-subtitle-preroll=yes
|
||||
# sub-auto=exact (default)|fuzzy|all
|
||||
# fuzzy means to load subs if their filename includes the filename of the video, even if it contains extras
|
||||
sub-auto=fuzzy
|
||||
|
||||
# to avoid frame drops or desync on low-power devices (lappy, moby, ...)
|
||||
# limit the max resolution, framerate, and avoid using codecs without HW acceleration
|
||||
# source: <https://git.sr.ht/~phate/mpv-config>
|
||||
# made compat with youtube 2023+: <https://github.com/yt-dlp/yt-dlp/issues/7846#issuecomment-1679306012>
|
||||
# see available formats: `yt-dlp -F https://youtube.com/<some_video>`
|
||||
# TODO: move this to `~/.config/yt-dlp/config`
|
||||
# and change this to a sort instead of a filter: <https://github.com/yt-dlp/yt-dlp/issues/7846#issuecomment-1821393561>
|
||||
ytdl-format=bestvideo[height<=1080][fps<=?60][vcodec!~='vp0?9'][vcodec!~='av0?1']+bestaudio/best
|
||||
|
||||
cache=yes
|
||||
# how many forward bytes into the video (stream or file) to cache
|
||||
demuxer-max-bytes=1024MiB
|
||||
# how many bytes backward into the video (stream or file) to keep in memory
|
||||
demuxer-max-back-bytes=2048MiB
|
||||
# demuxer-readahead-secs=20
|
||||
prefetch-playlist=yes
|
||||
|
||||
# debanding: good test case is 2001: A Space Oddyssey at 54:00
|
||||
deband=yes
|
||||
# iterations: 1-16 (default: 1). quality v.s. compute tradeoff. values > 4 are "practically useless".
|
||||
# - each iteration increases the range, but decreases the threshold
|
||||
# on lappy: i can notice a difference between 1 and 4 (4 is def better),
|
||||
# on lappy: the difference between 2 and 4 is there but very subtle.
|
||||
# on lappy: everything above 3 looks *basically* the same as 3. maybe relevant for HDR displays
|
||||
# on lappy, there is an observable perf difference between 1 and 3. it's irrelevant for 1080p h.264, but comes into play for 4K h.265.
|
||||
# so, default the iterations count to `1`, and selectively increase it on more capable devices/profiles.
|
||||
deband-iterations=1
|
||||
# threshold: 0-4096 (default: 48). higher value = higher strength, but lose details.
|
||||
deband-threshold=72
|
||||
# range: 1-64 (default: 16). a higher radius finds more gradients, but a lower radius smooths more aggressively. this is increased per iteration, so one should lower this here if using a high iteratio count.
|
||||
# OTOH, i find that a higher range lets me get away with a higher threshold without losing real detail.
|
||||
deband-range=20
|
||||
# grain: 0-4096 (default: 32): inject noise (post-deband; across the whole image) to mask remaining quantization artifacts. higher values needed for poor sources.
|
||||
# i'm disabling that, because it's not really the job of a deband filter to cover up block artifacts
|
||||
deband-grain=0
|
||||
|
||||
# set e.g. `profile=fast` to make that the default profile.
|
||||
# in fact, it's more like inheriting everything from that profile into the default profile.
|
||||
# toplevel `profile=fast` does not work, AND, [default]profile=default doesn't work,
|
||||
profile=@default_profile@
|
||||
|
||||
[high-quality]
|
||||
# this extends the builtin `high-quality` profile
|
||||
# - <https://github.com/mpv-player/mpv/blob/e8d14cd3142b117eabf23df026ee946cfded6424/etc/builtin.conf#L53>
|
||||
ytdl-format=bestvideo[height<=1440][fps<=?60]+bestaudio/best
|
||||
deband-iterations=3
|
||||
|
||||
[mid-range]
|
||||
# keep this here even if empty. `profile=default` is NOT supported by mpv, so we have to do `profile=mid-range` if we want to be general
|
||||
|
||||
[fast]
|
||||
# this extends the builtin `fast` profile
|
||||
# - <https://github.com/mpv-player/mpv/blob/e8d14cd3142b117eabf23df026ee946cfded6424/etc/builtin.conf#L43>
|
||||
deband=no
|
||||
ytdl-format=bestvideo[height<=360][fps<=?30][vcodec!=vp9][vcodec!~='av0?1']+bestaudio/best
|
||||
|
@@ -30,6 +30,7 @@ color=foreground=ff968b,background_text=ff968b
|
||||
# opacity values *must* be a multiple of 0.1
|
||||
opacity=timeline=0.8,position=1,chapters=0.8,slider=0.8,slider_gauge=0.8,controls=0,speed=0.8,menu=1,submenu=0.4,border=1,title=0.8,tooltip=1,thumbnail=1,curtain=0.8,idle_indicator=0.8,audio_indicator=0.5,buffering_indicator=0.3,playlist_position=0.8
|
||||
|
||||
# which resolution options to list in the stream menu dropdown.
|
||||
stream_quality_options=1440,1080,720,480,360,240,144
|
||||
|
||||
# default open-file menu directory
|
||||
|
Reference in New Issue
Block a user