[mpv]使用脚本保存url播放的视频(streamsave.lua)
前言
在使用Play-With-MPV这个脚本后,可以轻松将视频推流到mpv播放器中,但是mpv并没有提供直接将缓存转为储存的选项。
这个时候就streamsave.lua这个脚本就可以轻松将缓存转为储存,也就是将url播放的视频保存到本地文件夹。
github仓库:https://github.com/Sagnac/streamsave
国内可以直连
脚本特点
提供了5种工作方式(使用Alt+s在五种方式切换):
剪辑模式;A-Bloop,转存时需要已经使用mpv自带快捷键l设置A-Bloop循环才可以工作,否则报错。
完全/连续转储;Current position
从头写到现在的位置;Continuous
写当前章节;Chapter
单独写出所有章节以分隔文件;Segments
无需重新编码,转存速度极快,在1-3秒之间,能播就能存。
安装
(必选)下载此文件 streamsave.lua 到你的本地脚本文件夹内
(可选)下载 streamsave.conf 到你的本地脚本设置文件夹并修改内部参数适配
改变脚本保存到本地文件夹的位置,在streamsave.conf中找到save_directory参数输入目标位置
改变快捷键streamsave.conf未提供参数,其在streamsave.lua中已定义,需打开streamsave.lua在文件末尾找到
将Alt+s等改为你需要的快捷键(需要符合lua写法)。
本脚本只能保存已缓存的数据,如果缓存容量太小,将会出现只存了一小段的情况。
源仓库说明文档写道
It is advisable that you set --demuxer-max-bytes and --demuxer-max-back-bytes to larger values (e.g. at least 1GiB) in order to have a larger cache. If you want to use with local files set cache=yes in mpv.conf
需在mpv.conf加入以下代码改变缓存容量。
其中cache=yes是当你需要转存本地文件时才需要开启。
快捷键
Default keybinds:
Ctrl+z dumps cache to disk
Alt+z cycles dump mode
Alt+x aligns loop points to keyframes (pressing again will restore the initial loop points)
Ctrl+x stops continuous dumping
默认键绑定:
Ctrl+z将缓存转储到磁盘
Alt+z循环转储模式
Alt+x将循环点与关键帧对齐(再次按下将恢复初始循环点)
Ctrl+x停止连续倾倒
其他
脚本提供了自动化等设置参数,但是本人没用过,有兴趣的读者可自行阅读源仓库的说明文档。