Skip to content

Commit 9e642e5

Browse files
committed
Log mpv by default and remove logs for successful encodes
1 parent a0ad304 commit 9e642e5

File tree

2 files changed

+29
-14
lines changed

2 files changed

+29
-14
lines changed

src/options.lua

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@ local thumbnailer_options = {
2525
-- Use "" to disable
2626
mpv_profile = "",
2727
-- Output debug logs to <thumbnail_path>.log, ala <cache_directory>/<video_filename>/000000.bgra.log
28-
mpv_log = false,
28+
-- The logs are removed after successful encodes, unless you set mpv_keep_logs below
29+
mpv_logs = true,
30+
-- Keep all mpv logs, even the succesfull ones
31+
mpv_keep_logs = false,
2932

3033
-- Disable the built-in keybind ("T") to add your own
3134
disable_keybinds = false,

src/thumbnailer_server.lua

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ function create_thumbnail_mpv(file_path, timestamp, size, output_path)
2929
-- Insert --no-config, --profile=... and --log-file if enabled
3030
(thumbnailer_options.mpv_no_config and "--no-config" or nil),
3131
profile_arg,
32-
(thumbnailer_options.mpv_log and log_arg or nil),
32+
(thumbnailer_options.mpv_logs and log_arg or nil),
3333

3434
file_path,
3535

@@ -72,23 +72,35 @@ function create_thumbnail_ffmpeg(file_path, timestamp, size, output_path)
7272
end
7373

7474

75-
function check_output(ret, output_path)
75+
function check_output(ret, output_path, is_mpv)
76+
local log_path = output_path .. ".log"
77+
local success = true
78+
7679
if ret.killed_by_us then
7780
return nil
78-
end
79-
80-
local success = true
81+
else
82+
if ret.error or ret.status ~= 0 then
83+
msg.error("Thumbnailing command failed!")
84+
msg.error(ret.error)
85+
msg.error(ret.stdout)
86+
if is_mpv then
87+
msg.error("Debug log:", log_path)
88+
end
8189

82-
if ret.error or ret.status ~= 0 then
83-
msg.error("Thumbnailing command failed!")
84-
msg.error(ret.error or ret.stdout)
90+
success = false
91+
end
8592

86-
success = false
93+
if not file_exists(output_path) then
94+
msg.error("Output file missing!", output_path)
95+
success = false
96+
end
8797
end
8898

89-
if not file_exists(output_path) then
90-
msg.error("Output file missing!", output_path)
91-
success = false
99+
if is_mpv and not thumbnailer_options.mpv_keep_logs then
100+
-- Remove successful debug logs
101+
if success and file_exists(log_path) then
102+
os.remove(log_path)
103+
end
92104
end
93105

94106
return success
@@ -159,7 +171,7 @@ function do_worker_job(state_json_string, frames_json_string)
159171

160172
if need_thumbnail_generation then
161173
local ret = thumbnail_func(file_path, timestamp, thumb_state.thumbnail_size, thumbnail_path)
162-
local success = check_output(ret, thumbnail_path)
174+
local success = check_output(ret, thumbnail_path, thumbnail_func == create_thumbnail_mpv)
163175

164176
if success == nil then
165177
-- Killed by us, changing files, ignore

0 commit comments

Comments
 (0)