Commit: c13021688badcfb20d3378e9746bbd23755495c3
Parent: e46f486b6f863d04fbc18e0f113ca7bfff496a71
Author: 0x766F6964
Date: Mon, 4 May 2020 13:17:31 -0600
update mpv config
- update gallery thumbgen script
- don't render subs by default
- add a keybind to toggle screensaver (only useful on windows)
Diffstat:
4 files changed, 35 insertions(+), 34 deletions(-)
diff --git a/.config/mpv/input.conf b/.config/mpv/input.conf
@@ -9,3 +9,5 @@ Alt+LEFT add video-rotate -90
H cycle-values video-unscaled "yes" "no"
L cycle-values loop "inf" "no"
+
+F1 cycle stop-screensaver
diff --git a/.config/mpv/mpv.conf b/.config/mpv/mpv.conf
@@ -4,7 +4,7 @@ hwdec=auto
# Audio
audio-device=alsa/mpv
-volume=70
+volume=75
volume-max=200
# Output channels (stereo)
@@ -12,32 +12,23 @@ audio-channels=2
af=format=channels=2
# Default lang
-slang=jp,jpn,ja,eng,en,zh-Hant
+sid=no
+slang=jp,jpn,ja,zh-Hant
alang=jp,jpn,ja,eng,en
# UI
keep-open
#ontop
+osd-font="Kozuka Gothic Pro M"
+sub-font="Kozuka Gothic Pro M"
+osd-font-size=36
+sub-font-size=54
screenshot-format="png"
screenshot-template="[%tY.%tm.%td_%tH:%tM:%tS]_%F_%P"
screenshot-directory="~/media/pic/screengrabs/animu/"
screenshot-png-compression=9
-# OSD rice (for file info)
-sub-pos=95
-osd-font="Kozuka Gothic Pro M"
-sub-font="Kozuka Gothic Pro M"
-osd-font-size=40
-sub-font-size=54
-osd-color="#eeeeee"
-sub-color="#eeeeee"
-osd-border-size=2
-sub-border-size=2.5
-osd-border-color="#262626"
-sub-border-color="#262626"
-msg-level=osd/libass=warn
-
# Misc
script-opts=osc-minmousemove=3
hr-seek=yes
diff --git a/.config/mpv/scripts/gallery-thumbgen.lua b/.config/mpv/scripts/gallery-thumbgen.lua
@@ -3,6 +3,7 @@ local msg = require 'mp.msg'
local jobs_queue = {} -- queue of thumbnail jobs
local failed = {} -- list of failed output paths, to avoid redoing them
+local script_id = mp.get_script_name() .. utils.getpid()
local opts = {
ytdl_exclude = "",
@@ -23,14 +24,9 @@ function append_table(lhs, rhs)
return lhs
end
-function file_exists(path)
- local f = io.open(path, "r")
- if f ~= nil then
- io.close(f)
- return true
- else
- return false
- end
+local function file_exists(path)
+ local info = utils.file_info(path)
+ return info ~= nil and info.is_file
end
local video_extensions = { "mkv", "webm", "mp4", "avi", "wmv" }
@@ -123,7 +119,7 @@ function ytdl_thumbnail_url(input_path)
return json.thumbnail
end
-function thumbnail_command(input_path, width, height, take_thumbnail_at, output_path, with_mpv)
+function thumbnail_command(input_path, width, height, take_thumbnail_at, output_path, accurate, with_mpv)
local vf = string.format("%s,%s",
string.format("scale=iw*min(1\\,min(%d/iw\\,%d/ih)):-2", width, height),
string.format("pad=%d:%d:(%d-iw)/2:(%d-ih)/2:color=0x00000000", width, height, width, height)
@@ -132,11 +128,15 @@ function thumbnail_command(input_path, width, height, take_thumbnail_at, output_
local add = function(table) out = append_table(out, table) end
- if input_path:find("https?://") == 1 and not is_blacklisted(input_path) then
+ if input_path:find("^https?://") and not is_blacklisted(input_path) then
-- returns the original input_path on failure
input_path = ytdl_thumbnail_url(input_path)
end
+ if input_path:find("^archive://") or input_path:find("^edl://") then
+ with_mpv = true
+ end
+
if not with_mpv then
out = { "ffmpeg" }
@@ -153,13 +153,16 @@ function thumbnail_command(input_path, width, height, take_thumbnail_at, output_
if duration then
local percent = tonumber(string.sub(take_thumbnail_at, 1, -2))
local start = tostring(duration * percent / 100)
- add({ "-ss", start, "-noaccurate_seek" })
+ add({ "-ss", start })
end
end
else
- add({ "-ss", tonumber(take_thumbnail_at), "-noaccurate_seek" })
+ add({ "-ss", take_thumbnail_at })
end
end
+ if not accurate then
+ add({"-noaccurate_seek"})
+ end
add({
"-i", input_path,
"-vf", vf,
@@ -174,7 +177,10 @@ function thumbnail_command(input_path, width, height, take_thumbnail_at, output_
else
out = { "mpv", input_path }
if take_thumbnail_at ~= "0" and is_video(input_path) then
- add({ "--hr-seek=no", "--start", take_thumbnail_at })
+ if not accurate then
+ add({ "--hr-seek=no"})
+ end
+ add({ "--start", take_thumbnail_at })
end
add({
"--no-config", "--msg-level=all=no",
@@ -194,7 +200,7 @@ function generate_thumbnail(thumbnail_job)
if file_exists(thumbnail_job.output_path) then return true end
local dir, _ = utils.split_path(thumbnail_job.output_path)
- local tmp_output_path = utils.join_path(dir, mp.get_script_name())
+ local tmp_output_path = utils.join_path(dir, script_id)
local command = thumbnail_command(
thumbnail_job.input_path,
@@ -202,6 +208,7 @@ function generate_thumbnail(thumbnail_job)
thumbnail_job.height,
thumbnail_job.take_thumbnail_at,
tmp_output_path,
+ thumbnail_job.accurate,
thumbnail_job.with_mpv
)
@@ -209,7 +216,7 @@ function generate_thumbnail(thumbnail_job)
--"atomically" generate the output to avoid loading half-generated thumbnails (results in crashes)
if res.status == 0 then
local info = utils.file_info(tmp_output_path)
- if not info or info.size == 0 then
+ if not info or not info.is_file or info.size == 0 then
return false
end
if os.rename(tmp_output_path, thumbnail_job.output_path) then
@@ -233,7 +240,8 @@ function handle_events(wait)
height = tonumber(e.args[5]),
take_thumbnail_at = e.args[6],
output_path = e.args[7],
- with_mpv = (e.args[8] == "true"),
+ accurate = (e.args[8] == "true"),
+ with_mpv = (e.args[9] == "true"),
}
if e.args[1] == "push-thumbnail-front" then
jobs_queue[#jobs_queue + 1] = thumbnail_job
diff --git a/.config/mpv/scripts/gallery.lua b/.config/mpv/scripts/gallery.lua
@@ -7,7 +7,7 @@ local on_windows = (package.config:sub(1,1) ~= "/")
local opts = {
thumbs_dir = "/tmp/thumb",
auto_generate_thumbnails = true,
- generate_thumbnails_with_mpv = true,
+ generate_thumbnails_with_mpv = false,
thumbnail_width = 192,
thumbnail_height = 108,
@@ -60,7 +60,7 @@ local opts = {
ACCEPT = "ENTER",
CANCEL = "ESC",
REMOVE = "DEL",
- FLAG = "m",
+ FLAG = ",",
}
(require 'mp.options').read_options(opts)