038 MPV configuration

本文最后更新于:2023-08-12

See you later.

2021/04/06 update


还没配置完,先记下参考资料,待更新

Ref:

双声道播放多声道音轨时,背景音过大,台词音量小

播放HDR视频亮度不稳定

应该是看的 HDR 视频吧,我也在看某些 HDR 视频时遇到过这个问题,可以调整色调映射(tone-mapping)用的算法,默认是 hable,我改的是 mobius ,这是之前的版本的默认算法。
配置文件里添加下面这行试试看,还是有问题也可以换其它的算法试一试,官方文档里写的很清楚。
tone-mapping=mobius


2021/04/06 update

佛系配置

鸽了一年的帖子(咕咕咕~~~

今天偶然发现自己乱配置的config file似乎有点过时了,命令行运行时提示几个选项找不到
瞅了一眼这篇帖子 VCB bbs - 分享一下自己的mpv配置,官方似乎更新了不少功能,可以更简洁的实现楼主写的配置

思来想去,还是不那么折腾了,佛系配置一下,能用就行,做最少的改动

lua scripts

先看了看scripts文件夹,官方更新的在/usr/share/mpv/scripts/下,似乎比我用的少一个,备份一下我之前用的lua脚本

1
cp /usr/share/mpv/scripts/* ~/.config/mpv/scripts/

config file

备份一下我的mpv.conf

1
cp /usr/share/doc/mpv/mpv.conf ~/.config/mpv/

然后打开看看,根据个人喜好改改
文件最后有一个include,可以包含其他配置文件,这样自定义的配置可以放在另一个文件里,方便一些
加了一个mpv.conf.custom

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

把我的自定义配置放到mpv.conf.custom里了

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
###################
# 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/

# 在mpv.conf所在目录下建一个 shaders_cache 空文件夹,以存放编译好的GPU shaders,加速启动。
# 注意!如果不放APPDATA下,确保该文件夹有用户写入权限。
gpu-shader-cache-dir="~/.config/mpv/shaders_cache"

上面配置第21、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
原本有个bug,自定义截屏路径会导致打开mpv时自动截两张图
但这次配置好之后似乎没这个bug了

bug: something something hello world

结果配置好之后,打开一个油管视频,画面上面有奇怪的水印

本来以为是在线视频的问题,但是换硬盘里的视频也有这些水印
上网查了查,没有找到同样的问题

排查了一下config file,没问题
又看了看lua scripts,发现是osd-test.lua的问题…禁用禁用

找到罪魁祸首的方法是grep hello ~/.config/mpv/scripts/*.lua

mpv播放油管视频/直播

用mpv看油管直播也不错,mpv https://.....命令行贴link,或者开一个mpv窗口,直接把地址扔上去

我摸索半天,改了一条自选分辨率、不飙命令行信息、后台bash的命令

1
mpv --ytdl-raw-options=format=48 https://www.youtube.com/watch?v=xxxxxxxxxx > /dev/null 2>&1 &
  • --ytdl-raw-options=format=48 1080p分辨率有点费梯子,还是降低一下画质(fucking GFW),48是分辨率的format id,可以运行youtube-dl -F https://www.youtube.com/watch?v=xxxxxxxxxx列出视频所有格式
  • > /dev/null 2>&1 把命令行输出的信息都扔掉
  • & 后台新开一个bash运行mpv,可以关掉当前bash

最后把这条长命令写一个alias,一键看直播

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


2021/12/08 update

网上有个好配置,我抄(


2023/08/12 update

Mpv-Playlistmanager

稍微折腾了一下 mpv,默认 F8 显示的播放列表字体太大了,一屏显示不了 5 条
上网找了找怎么缩小字体,但好像没有特别好的方法,似乎改字体大小会应用到所有控件上

没办法,只好换一个播放列表脚本,Github - Mpv-Playlistmanager,这个似乎不错
不需要特别配置,把 .lua.conf 放到对应的文件夹里面就行了

但刚开始用的时候有一点问题,只有当前视频,文件夹里其他视频没有加载出来
看了看 playlistmanager.conf 文件

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

loadfiles_on_start 改成 yes 就可以加载文件夹里所有视频了

这个脚本默认还会把图片文件也加载进来,在 loadfiles_filetypes 这个项目里,我不需要加载图片文件,删掉对应的后缀名就行了

mpv-osc-modern-f

看到一个不错的屏幕控件,比自带的好看多了,顺便换了一下,链接是这个 Github - mpv-osc-modern-f
也不用特别配置,按照项目的说明做,再自己按喜好调一下就 ok

Github - thumbfast,这个进度条缩略图脚本也不错,一块安装上了


还有好多有意思的脚本,有时间再折腾(咕咕咕
Github - Awesome mpv,一堆有用的 mpv 资源导航
Github - mpv-scriptsMpv-Playlistmanager 作者的脚本合集