Skip to content

Latest commit

 

History

98 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

#+TITLE:MPV config
#+STARTUP: nohideblocks

[[https://mpv.io/manual/master/][official manual]], [[https://wiki.archlinux.org/title/mpv][arch mpv page]] (which i deem to b a _must-read_)

*Dependencies*: libsixel, lua52, sndio, unzip, webtorrent-cli, xidel

This repository works via Emacs Org-mode tangling. Sections of this readme
are tangled to =mpv.conf=, =input.conf= and =sources= file which contains links to all
external scripts i use. Run 'tangle' command on this file once and those files
will be created. Then run =./mpvmanager= without an argument to get all scripts
downloaded to proper directories. Run =./mpvmanager sync= to download only missing
(or if you added new scripts to this readme). It won't delete scripts that you
removed from readme, cuz i deem such functionality as overly complex, remove
those by hand.

** Configuration
*** mpv.conf [[https://mpv.io/manual/stable/#options][#config-docs]]
:PROPERTIES:
:header-args: :tangle mpv.conf
:END:

External Sources of this config:
- https://wiki.archlinux.org/title/mpv    <-- READ WHOLE
- https://github.com/hl2guide/better-mpv-config
- https://raw.githubusercontent.com/classicjazz/mpv-config/master/mpv.conf

**** General
#+begin_src conf
# DO NOT ALTER! This config is tangled from README

pause=no                               # disables autoplay
border=no              # hides the window title bar
# Sets the profile restore method to "copy if equal"
profile-restore=copy-equal
no-input-builtin-bindings
save-position-on-quit=yes               # saves the seekbar position on exit
force-seekable=yes                      # forces videos to be seekable
#+end_src

**** Video
#+begin_src conf
vlang=en,eng                            # Sets the video language
# Uses GPU-accelerated video output by default.
# https://github.com/mpv-player/mpv/wiki/GPU-Next-vs-GPU
vo=gpu # gpu-next <- experimental video renderer based on libplacebo
# NOTE: need fast as my most frequent case is opening my vids via
# 'dired-do-open' from emacs which i do frequently and don't want to wait
profile=fast # gpu-hq # Can cause performance problems with some GPU drivers and GPUs.
hwdec=auto
# scale=ewa_lanczossharp
dscale=mitchell

# due to me being in places with shitty internet most of the time that makes
# much more sence
# (https://www.reddit.com/r/linuxquestions/comments/clyt9z/how_do_i_make_mpv_select_1080p_or_less_for_video/)
ytdl-format=bestvideo[height<=480]+bestaudio/best
#+end_src

**** Motion interpolation
#+begin_src conf
display-fps-override=60
video-sync=display-resample
interpolation=yes
tscale=oversample # smoothmotion
#+end_src

**** Subtitles
#+begin_src conf
blend-subtitles=yes
sub-auto=fuzzy # Enable fuzzy searching:
#+end_src
**** Images
#+begin_src conf
image-display-duration=inf
#+end_src

*** input.conf
:PROPERTIES:
:header-args: :tangle input.conf
:END:

[[file:/usr/share/doc/mpv/input.conf][default keybindings]]

Use SHARP to assign the ~#~ key.

- List of commands and further details: DOCS/man/input.rst
- List of special keys: --input-keylist
- Keybindings testing mode: mpv --input-test --force-window --idle

Use 'ignore' to unbind a key fully (e.g. 'ctrl+a ignore').

Strings need to be quoted and escaped:
  KEY show-text "This is a single backslash: \\ and a quote: \" !"

#+begin_src conf
# THIS FILE IS BEING TANGLED FROM README

# If this is enabled, treat all the following bindings as default:
default-bindings start
#+end_src

*Note:* All key bindings below that are bound to ~_~ are defined as leader ones in
my leader script.

**** Playback
#+begin_src conf
# always exact seeks (non-keyframe-limited).
# Don't show them on the OSD (no-osd).
l no-osd seek 10 exact
h no-osd seek -10 exact
RIGHT no-osd seek 5 exact
LEFT no-osd seek -5 exact

[ multiply speed 1/1.1 # decrease the playback speed
] multiply speed 1.1   # increase the playback speed
> multiply speed 2.0   # double the playback speed
< multiply speed 0.5   # halve the playback speed
0 set speed 1.0        # reset the speed to normal

SPACE cycle pause       # toggle pause/playback mode
PLAY cycle pause        # toggle pause/playback mode
PAUSE cycle pause       # toggle pause/playback mode
PLAYPAUSE cycle pause   # toggle pause/playback mode
PLAYONLY set pause no   # unpause
PAUSEONLY set pause yes # pause
#+end_src

**** Audio
#+begin_src conf
j add volume -5
k add volume 5
m cycle mute                           # toggle mute
#+end_src

**** Misc
#+begin_src conf
# Quitting
# q quit
Q quit-watch-later # exit and remember the playback position
# q {encode} quit 4
ESC set fullscreen no                  # leave fullscreen
ESC {encode} quit 4

# toggle displaying information and statistics (https://mpv.io/manual/master/#stats)
i script-binding stats/display-stats-toggle 
` script-binding console/enable        # open the console
Ctrl+F cycle fullscreen                     # toggle fullscreen

Alt+v cycle video                          # switch video track
# cycle the video aspect ratio ("-1" is the container aspect)
Alt+Ctrl+v cycle-values video-aspect-override "16:9" "4:3" "2.35:1" "-1"

# take a screenshot of the video in its original resolution without subtitles
Ctrl+S screenshot video

H  no-osd sub-seek -1   # seek to the previous subtitle
L  no-osd sub-seek  1   # seek to the next subtitle

# to open terminal with process:
# Ctrl+d run foot sh -c "yt-dlp -o '~/Downloads/%(title)s.%(ext)s' '${path}'; read -p 'done ' x"
Ctrl+d run foot sh -c "ytdcur '${path}'"
# Ctrl+d run /bin/sh -c "ytdcur '${path}'"
#+end_src

** [[https://github.com/stax76/awesome-mpv][User scripts]]
FYI: to get those debug messages displayed run add
~--msg-level={script_name}={verbosity_level}~ to mpv command where
'verbosity_level' is 'debug'.

*** my [[https://github.com/Seme4eg/mpv-scripts][own]] scripts
#+begin_src bash :tangle sources
get M-x-rofi script https://raw.githubusercontent.com/Seme4eg/mpv-scripts/master/M-x-rofi.lua
get M-x-rofi options https://raw.githubusercontent.com/Seme4eg/mpv-scripts/master/script-opts/M_x_rofi.conf

get leader script https://raw.githubusercontent.com/Seme4eg/mpv-scripts/master/leader.lua
get leader module https://raw.githubusercontent.com/Seme4eg/mpv-scripts/master/script-modules/leader.lua
get leader options https://raw.githubusercontent.com/Seme4eg/mpv-scripts/master/script-opts/leader.conf

get shaders-rofi script https://raw.githubusercontent.com/Seme4eg/mpv-scripts/master/shaders-rofi.lua
#+end_src

*** [[https://gist.github.com/Artefact2/0a9c87d6d0f0ef6a565e44d830943fff][dbvol]] - volume control using decibels
#+begin_src bash :tangle sources
get dbvol script https://gist.githubusercontent.com/Artefact2/0a9c87d6d0f0ef6a565e44d830943fff/raw/c841063304a98f99371ce28e0b14ade609e8185c/dbvol.lua
#+end_src

#+begin_src conf :tangle input.conf :comments noweb
j script-binding dbvol/decrease-db
k script-binding dbvol/increase-db
#+end_src

*** [[https://github.com/occivink/mpv-scripts#blur-edgeslua][blur-edges]]
Fills the black bars on the side of a video with a blurred copy of its edges.

*NOTE* slows everything down *a lot* + triggers only on fullscreen toggle

#+begin_src bash :tangle sources
get blur_edges script https://raw.githubusercontent.com/occivink/mpv-scripts/master/scripts/blur-edges.lua
get blur_edges options https://raw.githubusercontent.com/occivink/mpv-scripts/master/script-opts/blur_edges.conf
#+end_src

#+begin_src conf :tangle input.conf :comments link
Alt+b script-binding blur-edges/toggle-blur
#+end_src

*** [[https://github.com/4e6/mpv-reload][reload]]
~ctrl+r~ to reload if anything is wrong / stuck

#+begin_src bash :tangle sources
get reload script https://raw.githubusercontent.com/sibwaf/mpv-scripts/master/reload.lua
#+end_src

#+begin_src conf :tangle input.conf :comments link
Ctrl+r script-binding reload/reload
#+end_src

*** [[https://github.com/Eisa01/mpv-scripts#undoredo][undoredo]]
#+begin_src bash :tangle sources
get undoredo script https://raw.githubusercontent.com/Eisa01/mpv-scripts/master/scripts/UndoRedo.lua
#+end_src

#+begin_src conf :tangle input.conf :comments link
u script-binding UndoRedo/undo
r script-binding UndoRedo/redo
U script-binding UndoRedo/undoLoop
#+end_src

*** [[https://github.com/AN3223/dotfiles/blob/master/.config/mpv/scripts/lilskippa.lua][lilskippa]] fast forward to scene/black/silence
Alternatives: [[https://github.com/ferreum/mpv-skipsilence][mpv-skipsilence]] and [[https://github.com/detuur/mpv-scripts/blob/master/skiptosilence.lua][skiptosilence]]

-- This script defines the following keybinds:
--
-- % skip2scene   -- skip2scene fast forwards to the next scene change
-- ^ skip2black   -- skip2black fast forwards to the next black video segment
-- & skip2silence -- skip2silence fast forwards to the next silent audio segment

#+begin_src bash :tangle sources
get lilskippa script https://raw.githubusercontent.com/AN3223/dotfiles/master/.config/mpv/scripts/lilskippa.lua
#+end_src

#+begin_src conf :tangle input.conf :comments link

#+end_src

*** [[https://github.com/l-jared/thumbfast][thumbfast]] High-performance on-the-fly thumbnailer for mpv.
#+begin_src bash :tangle sources
get thumbfast script https://raw.githubusercontent.com/l-jared/thumbfast/master/thumbfast.lua
get thumbfast options https://raw.githubusercontent.com/l-jared/thumbfast/master/thumbfast.conf
#+end_src

*** [[https://github.com/tomasklaen/uosc][uosc]] Feature-rich minimalist proximity-based UI for MPV player.
#+begin_src bash :tangle sources
get_uosc() {
    config_dir="${XDG_CONFIG_HOME:-~/.config}"
    mkdir -pv "$config_dir"/mpv/script-opts/
    rm -rf "$config_dir"/mpv/scripts/uosc_shared
    wget -P /tmp/ https://github.com/tomasklaen/uosc/releases/latest/download/uosc.zip
    unzip -od "$config_dir"/mpv/ /tmp/uosc.zip
    rm -fv /tmp/uosc.zip
    get uosc options https://github.com/tomasklaen/uosc/releases/latest/download/uosc.conf
}

if [ $command = sync ]; then
    [ ! -d ./scripts/uosc ] && get_uosc
else
    get_uosc
fi
#+end_src

Config:
#+begin_src conf :tangle mpv.conf
# required so that the 2 UIs don't fight each other
osc=no
# uosc provides its own seeking/volume indicators, so you also don't need this
osd-bar=no
# uosc will draw its own window controls if you disable window border
border=no

# uosc respects this setting
# osd-font='Iosevka'

# And these doesn't
# osd-font-size=45
# osd-scale=0.5
#+end_src

*** [[https://github.com/Eisa01/mpv-scripts#smartcopypaste][copy-paste]]
#+begin_src bash :tangle sources
get SmartCopyPaste script https://github.com/Eisa01/mpv-scripts/raw/master/scripts/SmartCopyPaste.lua
#+end_src

*** [[https://github.com/noctuid/mpv-webtorrent-hook][mpv-webtorrent-hook]]
#+begin_src bash :tangle sources
get mpv-webtorrent-hook scripts/webtorrent-hook https://raw.githubusercontent.com/noctuid/mpv-webtorrent-hook/refs/heads/master/main.lua
get mpv-webtorrent-hook scripts/webtorrent-hook https://raw.githubusercontent.com/noctuid/mpv-webtorrent-hook/refs/heads/master/webtorrent-speed-printer.sh
get mpv-webtorrent-hook scripts/webtorrent-hook https://raw.githubusercontent.com/noctuid/mpv-webtorrent-hook/refs/heads/master/webtorrent-wrap.sh

config_dir="${XDG_CONFIG_HOME:-~/.config}"
mkdir -pv "$config_dir"/mpv/script-opts/
chmod +x "$config_dir"/mpv/scripts/webtorrent-hook/webtorrent-speed-printer.sh
chmod +x "$config_dir"/mpv/scripts/webtorrent-hook/webtorrent-wrap.sh
#+end_src

** [[https://github.com/stax76/awesome-mpv#shaders][Shaders]]
- [[https://gist.github.com/igv][SSimDownscaler, SSimSuperRes, Krig, Adaptive Sharpen, etc.]] -
  - SSimDownscaler: Perceptually based downscaler.
  - SSimSuperRes: make corrections to the image upscaled by mpv built-in scaler.
  - Krig: Chroma scaler that uses luma information for high quality upscaling.
- [[https://gist.github.com/agyild/bbb4e58298b2f86aa24da3032a0d2ee6][FidelityFX CAS]] - AMD FidelityFX Contrast Adaptive Sharpening (CAS) - sharpen
  and optionally scale an image.
- [[https://gist.github.com/agyild/82219c545228d70c5604f865ce0b0ce5][FidelityFX FSR]] - AMD FidelityFX Super Resolution is a spatial upscaler.
- [[https://gist.github.com/agyild/7e8951915b2bf24526a9343d951db214][NVIDIA Image Scaling]] - spatial scaling and sharpening algorithm.
- [[https://github.com/bloc97/Anime4K/blob/master/GLSL_Instructions.md][Anime4K]]

#+begin_src bash :tangle sources
get NVScaler shader https://gist.github.com/agyild/7e8951915b2bf24526a9343d951db214/raw/05f00864228871ffd157daa9beb2db8fa7412cfa/NVScaler.glsl
get NVScaler shader https://gist.github.com/agyild/7e8951915b2bf24526a9343d951db214/raw/05f00864228871ffd157daa9beb2db8fa7412cfa/NVSharpen.glsl
get FSR shader https://gist.github.com/agyild/82219c545228d70c5604f865ce0b0ce5/raw/2623d743b9c23f500ba086f05b385dcb1557e15d/FSR.glsl
get SSimDownscaler shader https://gist.github.com/igv/36508af3ffc84410fe39761d6969be10/raw/575d13567bbe3caa778310bd3b2a4c516c445039/SSimDownscaler.glsl
#+end_src

#+begin_src conf :tangle mpv.conf
glsl-shader="~~/shaders/NVScaler.glsl"
#+end_src

** mpv.conf custom profiles ( must be tangled last )
:PROPERTIES:
:header-args: :tangle mpv.conf
:END:

#+begin_src conf
[fastforward]
profile-restore=copy-equal
scale=bilinear
dscale=bilinear
cscale=bilinear
vd-lavc-skiploopfilter=all
vd-lavc-skipframe=all
#+end_src

*** File Type Profiles
#+begin_src conf
# GIF Files
[extension.gif]
profile-restore=copy-equal # Sets the profile restore method to "copy if equal"
profile-desc=gif
cache=no
no-pause
loop-file=yes

# WebM Files
[extension.webm]
profile-restore=copy-equal # Sets the profile restore method to "copy if equal"
profile-desc=webm
no-pause
loop-file=yes
#+end_src
*** Protocol Specific Configuration
#+begin_src conf
[protocol.http]
profile-restore=copy-equal # Sets the profile restore method to "copy if equal"
profile-desc=http
hls-bitrate=max # use max quality for HLS streams
cache=yes
no-cache-pause # don't pause when the cache runs low

[protocol.https]
profile-restore=copy-equal # Sets the profile restore method to "copy if equal"
profile-desc=https
profile=protocol.http

[protocol.ytdl]
profile-restore=copy-equal # Sets the profile restore method to "copy if equal"
profile-desc=ytdl
profile=protocol.http
#+end_src

** To do list
*** IDEA recents
take any script that SIMPLY logs history and pipe it to rofi

[[https://gist.github.com/garoto/e0eb539b210ee077c980e01fb2daef4a][script 1]], [[https://github.com/hacel/recent][script 2]]

Example of line format in history.log file (see how it forms [[https://github.com/Eisa01/mpv-scripts#simplehistory][here]]):
: [Wednesday/September 06/09/2023 19:17:52] "output.lq.mp4" | https://dl4.vibio.tv/f064277c672d45c35a49426dca2020f7/2839/2839278/output.lq.mp4 | length=5367.4472335601 | time=5367.4100453432

*** IDEA subtitles
- Check [[https://github.com/hl2guide/better-mpv-config/blob/master/mpv_v3/configs/mpv_subtitles.conf][these]] config settings for subtitles.
- check [[https://github.com/stax76/awesome-mpv#subtitle][this]] user-script list

either [[https://github.com/directorscut82/find_subtitles][this]] or [[https://github.com/davidde/mpv-autosub][this]]. Former - press to download, latter - automatic
also search on scripts page for 'sub-', there are lots of utility scripts for
working with subtitles

and yet another [[https://github.com/wiiaboo/mpv-scripts/blob/master/subit.lua][script]] for subtitles

Bind those if ya'll ever need 'em:
- Shift+g add sub-scale +0.1             # increase the subtitle font size
- Shift+f add sub-scale -0.1             # decrease the subtitle font size
- Ctrl+Shift+LEFT sub-step -1            # change subtitle timing such that the previous subtitle is displayed
- Ctrl+Shift+RIGHT sub-step 1            # change subtitle timing such that the next subtitle is displayed

**** IDEA when learning jap
[[https://github.com/linguisticmind/mpv-scripts/tree/master/copy-subtitle][copy-subtitle]]
and [[https://github.com/liberlanco/mpv-lang-learner][lang-learner]] as a must
and [[https://github.com/Ben-Kerman/immersive][immersive]] also for learning
[[https://github.com/fxmarty/rikai-mpv][rikay-mpv]] - special for jap
[[https://github.com/laelnasan/yomichampv][yomichampv]]

About

No description, website, or topics provided.

Resources

Stars

4 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages