038 MPV configuration

Published on

Original language: Chinese . AI translations: English , Japanese .


See you later.

2021/04/06 update


Not finished yet. Recording references first; will update later.

Ref

When playing multi-channel audio tracks in stereo, background sounds become too loud and dialogues too quiet:

HDR playback brightness flickers:

Probably HDR videos. I also saw this issue on some HDR videos. You can change the tone-mapping algorithm. Default is hable. I changed it to mobius, which used to be the default algorithm.
Add the line below to the config and try. If still problematic, try other algorithms. It’s documented clearly in the manual.
tone-mapping=mobius


2021/04/06 update

Lazy config

A post I ghosted for a year (coo coo coo~~~

Today I noticed my random config file might be outdated; mpv CLI complained that some options can’t be found.
I skimmed this post VCB bbs - 分享一下自己的mpv配置. It seems mpv added/updated quite a few features and you can achieve similar configs more simply.

After thinking, I decided to stop over-tweaking. Lazy config: make minimal changes and keep it usable.

lua scripts

Checked the scripts folder. The official scripts are under /usr/share/mpv/scripts/. It seems there’s one fewer than what I used. Back up my previous lua scripts:

Terminal window
cp /usr/share/mpv/scripts/* ~/.config/mpv/scripts/

config file

Back up mpv.conf:

Terminal window
cp /usr/share/doc/mpv/mpv.conf ~/.config/mpv/

Open it and tweak to your preference.
At the end of the file there’s an include option, so you can include other config files. It’s handy to keep custom settings in a separate file.
I added mpv.conf.custom:

# You can also include other configuration files.
#include=/path/to/the/file/you/want/to/include
include=~/.config/mpv/mpv.conf.custom

I moved my custom settings into mpv.conf.custom:

###################
# Custom settings #
###################
# ref: http://bbs.vcb-s.com/thread-2730-1-1.html
save-position-on-quit
icc-profile-auto
icc-3dlut-size=256x256x256
sub-auto=fuzzy
sub-file-paths=subs
slang=chi,zh-CN,sc,chs
audio-file-auto=fuzzy
#audio-file-paths=audio
alang=jpn,ja,eng,en
screenshot-format=png
screenshot-template=mpv-shot-%F-%p-%n
# This option is not set by default, and thus will write screenshots to the directory from which mpv was started.
# https://mpv.io/manual/stable/#options-screenshot-directory
screenshot-tag-colorspace=yes
screenshot-high-bit-depth=yes
screenshot-png-compression=0
screenshot-png-filter=0
screenshot-directory=~/Pictures/mpv_cap/
# Create an empty shaders_cache folder next to mpv.conf to store compiled GPU shaders and speed up startup.
# Note: if not under APPDATA, make sure the folder is writable by the user.
gpu-shader-cache-dir="~/.config/mpv/shaders_cache"

In the config above, lines 21 and 22

# This option is not set by default, and thus will write screenshots to the directory from which mpv was started
# <https://mpv.io/manual/stable/#options-screenshot-directory>

There used to be a bug: customizing screenshot path would make mpv auto-take two screenshots at startup.
But after reconfiguring this time, it seems the bug is gone.

bug: something something hello world

After configuring, when opening a YouTube video, there was a strange watermark on the image:

At first I thought it’s an online-video thing, but local videos had the same watermark.
Searched online; couldn’t find the same issue.

Checked config file: fine.
Checked lua scripts and found it’s osd-test.lua… disable it.

The way to find the culprit was grep hello ~/.config/mpv/scripts/*.lua

Watching YouTube videos/live with mpv

Watching YouTube live with mpv is nice too: run mpv https://..... in terminal, or just drag the URL into an mpv window.

After some trial and error, I ended up with a command to choose a specific resolution, silence CLI logs, and run in background:

Terminal window
mpv --ytdl-raw-options=format=48 https://www.youtube.com/watch?v=xxxxxxxxxx > /dev/null 2>&1 &
  • --ytdl-raw-options=format=48 1080p is a bit expensive for my proxy, so I lowered quality (fucking GFW). 48 is the format id. Run youtube-dl -F https://www.youtube.com/watch?v=xxxxxxxxxx to list formats.
  • > /dev/null 2>&1 discard all CLI output
  • & run mpv in background in a new bash, so you can close current bash

Finally I turned this long command into an alias for one-key livestream watching.

Ref:
mpv manual
stackoverflow - How to select video quality from youtube-dl
stackoverflow - What is /dev/null 2>&1


2021/12/08 update

Found a nice config pack, I’m copying(


2023/08/12 update

Mpv-Playlistmanager

Tweaked mpv a bit: the playlist font shown with F8 is too large; you can’t even see 5 items in one screen.
I searched how to reduce font size, but there doesn’t seem to be a great solution; changing font size seems to affect all UI widgets.

So I switched to a playlist script: Github - Mpv-Playlistmanager. It seems good.
No special config needed; just put .lua and .conf into the right folders.

At first there was an issue: only the current video was in the playlist; other videos in the folder weren’t loaded.
I checked playlistmanager.conf:

#loadfiles at startup if 1 or more items in playlist
loadfiles_on_start=yes

Set loadfiles_on_start to yes and it will load all videos in the folder.

By default it also loads image files. In the loadfiles_filetypes setting, I don’t need images, so I removed the corresponding file extensions.

mpv-osc-modern-f

Found a nice on-screen controller that looks much better than the built-in one, so I switched too: Github - mpv-osc-modern-f
No special config; follow the project instructions, then tweak to your preference.

Github - thumbfast, a progressbar thumbnail script, is also good. Installed it as well.


There are many more interesting scripts. Will tweak more when I have time~~ (coo coo coo~~
Github - Awesome mpv, a navigation of useful mpv resources
Github - mpv-scripts, a collection by the Mpv-Playlistmanager author