53 lines
3.8 KiB
Nix
53 lines
3.8 KiB
Nix
{ lib, pkgs, flakes, ... }:
|
|
|
|
let
|
|
m = pkgs.mpvScripts;
|
|
mu = pkgs.unstable.mpvScripts;
|
|
a4k = lib.mkIf (m ? anime4k);
|
|
in
|
|
|
|
{
|
|
#home.packages = with pkgs; [ mpv ];
|
|
|
|
programs.mpv.enable = true;
|
|
programs.mpv.bindings."n" = "sub-seek 1";
|
|
programs.mpv.bindings."SHIFT+n" = "sub-seek -1";
|
|
programs.mpv.bindings."b" = ''cycle-values audio-channels 2 5 7 "auto"'';
|
|
|
|
# m.anime4k - from https://github.com/NixOS/nixpkgs/pull/273830
|
|
# TODO: add to home-manager?
|
|
programs.mpv.bindings."CTRL+0" = a4k ''no-osd change-list glsl-shaders clr ""; show-text "GLSL shaders cleared"'';
|
|
programs.mpv.bindings."CTRL+1" = a4k ''no-osd change-list glsl-shaders set "${m.anime4k}/Anime4K_Clamp_Highlights.glsl:${m.anime4k}/Anime4K_Restore_CNN_VL.glsl:${m.anime4k}/Anime4K_Upscale_CNN_x2_VL.glsl:${m.anime4k}/Anime4K_AutoDownscalePre_x2.glsl:${m.anime4k}/Anime4K_AutoDownscalePre_x4.glsl:${m.anime4k}/Anime4K_Upscale_CNN_x2_M.glsl"; show-text "Anime4K: Mode A (HQ)"'';
|
|
programs.mpv.bindings."CTRL+2" = a4k ''no-osd change-list glsl-shaders set "${m.anime4k}/Anime4K_Clamp_Highlights.glsl:${m.anime4k}/Anime4K_Restore_CNN_Soft_VL.glsl:${m.anime4k}/Anime4K_Upscale_CNN_x2_VL.glsl:${m.anime4k}/Anime4K_AutoDownscalePre_x2.glsl:${m.anime4k}/Anime4K_AutoDownscalePre_x4.glsl:${m.anime4k}/Anime4K_Upscale_CNN_x2_M.glsl"; show-text "Anime4K: Mode B (HQ)"'';
|
|
programs.mpv.bindings."CTRL+3" = a4k ''no-osd change-list glsl-shaders set "${m.anime4k}/Anime4K_Clamp_Highlights.glsl:${m.anime4k}/Anime4K_Upscale_Denoise_CNN_x2_VL.glsl:${m.anime4k}/Anime4K_AutoDownscalePre_x2.glsl:${m.anime4k}/Anime4K_AutoDownscalePre_x4.glsl:${m.anime4k}/Anime4K_Upscale_CNN_x2_M.glsl"; show-text "Anime4K: Mode C (HQ)"'';
|
|
programs.mpv.bindings."CTRL+4" = a4k ''no-osd change-list glsl-shaders set "${m.anime4k}/Anime4K_Clamp_Highlights.glsl:${m.anime4k}/Anime4K_Restore_CNN_VL.glsl:${m.anime4k}/Anime4K_Upscale_CNN_x2_VL.glsl:${m.anime4k}/Anime4K_Restore_CNN_M.glsl:${m.anime4k}/Anime4K_AutoDownscalePre_x2.glsl:${m.anime4k}/Anime4K_AutoDownscalePre_x4.glsl:${m.anime4k}/Anime4K_Upscale_CNN_x2_M.glsl"; show-text "Anime4K: Mode A+A (HQ)"'';
|
|
programs.mpv.bindings."CTRL+5" = a4k ''no-osd change-list glsl-shaders set "${m.anime4k}/Anime4K_Clamp_Highlights.glsl:${m.anime4k}/Anime4K_Restore_CNN_Soft_VL.glsl:${m.anime4k}/Anime4K_Upscale_CNN_x2_VL.glsl:${m.anime4k}/Anime4K_AutoDownscalePre_x2.glsl:${m.anime4k}/Anime4K_AutoDownscalePre_x4.glsl:${m.anime4k}/Anime4K_Restore_CNN_Soft_M.glsl:${m.anime4k}/Anime4K_Upscale_CNN_x2_M.glsl"; show-text "Anime4K: Mode B+B (HQ)"'';
|
|
programs.mpv.bindings."CTRL+6" = a4k ''no-osd change-list glsl-shaders set "${m.anime4k}/Anime4K_Clamp_Highlights.glsl:${m.anime4k}/Anime4K_Upscale_Denoise_CNN_x2_VL.glsl:${m.anime4k}/Anime4K_AutoDownscalePre_x2.glsl:${m.anime4k}/Anime4K_AutoDownscalePre_x4.glsl:${m.anime4k}/Anime4K_Restore_CNN_M.glsl:${m.anime4k}/Anime4K_Upscale_CNN_x2_M.glsl"; show-text "Anime4K: Mode C+A (HQ)"'';
|
|
/**/
|
|
|
|
programs.mpv.scripts = [
|
|
#m.thumbnail # TOO SLOW
|
|
m.thumbfast
|
|
m.mpris
|
|
(m.mpv-webm or mu.mpv-webm) # activate with SHIFT+W
|
|
# from https://github.com/mpv-player/mpv/issues/9767#issuecomment-1024831645
|
|
({ scriptName = "dynamic-subs.lua"; } // (pkgs.writeTextDir "share/mpv/scripts/dynamic-subs.lua" ''
|
|
mp.add_hook('on_load', 10, function()
|
|
sub_paths = {'Subs'}
|
|
sub_paths[#sub_paths+1]='Subs/' .. mp.get_property('filename/no-ext')
|
|
mp.set_property_native('sub-file-paths', sub_paths)
|
|
end)
|
|
''))
|
|
];
|
|
#programs.mpv.config.osc = "no"; # likely a 'thumbnail' requirement
|
|
|
|
# dynamic-subs.lua
|
|
programs.mpv.config.sub-auto = "all";
|
|
|
|
#https://nixos.wiki/wiki/Accelerated_Video_Playback
|
|
programs.mpv.config.hwdec = "auto-safe";
|
|
programs.mpv.config.vo = "gpu";
|
|
programs.mpv.config.profile = "gpu-hq";
|
|
programs.mpv.config.gpu-context = "wayland";
|
|
}
|