diff --git a/encoder.lua b/encoder.lua index ad58c15..aef5932 100644 --- a/encoder.lua +++ b/encoder.lua @@ -139,7 +139,7 @@ this.create_clip = function(clip_type, on_complete) h.notify("Please wait...", "info", 9999) - local output_file_path, args = (function() + local output_file_path, args = (function() local clip_filename_noext = construct_output_filename_noext() if clip_type == 'video' then local output_path = this.mk_out_path_video(clip_filename_noext) @@ -172,9 +172,22 @@ this.create_clip = function(clip_type, on_complete) this.timings:reset() end +this.set_encoder_alive = function() + local args = { 'mpv', '--version' } + local process_result = function(_, ret, _) + if ret.status ~= 0 or string.match(ret.stdout, "mpv") == nil then + this.alive = false + else + this.alive = true + end + end + h.subprocess_async(args, process_result) +end + this.init = function(config, timings_mgr) this.config = config this.timings = timings_mgr + this.set_encoder_alive() end return this diff --git a/osd_styler.lua b/osd_styler.lua index 5ba9c8a..3a865dc 100644 --- a/osd_styler.lua +++ b/osd_styler.lua @@ -26,7 +26,7 @@ function OSD:new() end function OSD:append(s) - table.insert(self.messages, s) + table.insert(self.messages, tostring(s)) return self end @@ -42,6 +42,10 @@ function OSD:size(size) return self:append('{\\fs'):append(size):append('}') end +function OSD:font(name) + return self:append('{\\fn'):append(name):append('}') +end + function OSD:align(number) return self:append('{\\an'):append(number):append('}') end @@ -62,6 +66,10 @@ function OSD:text(text) return self:append(text) end +function OSD:new_layer() + return self:append('\n') +end + function OSD:bold(s) return self:append('{\\b1}'):append(s):append('{\\b0}') end @@ -78,4 +86,12 @@ function OSD:item(text) return self:color('fef6dd'):bold(text):color('ffffff') end +function OSD:selected(text) + return self:color('48a868'):bold(text):color('ffffff') +end + +function OSD:red(text) + return self:color('ff0000'):bold(text):color('ffffff') +end + return OSD diff --git a/videoclip.lua b/videoclip.lua index 809ab2e..0089bbf 100644 --- a/videoclip.lua +++ b/videoclip.lua @@ -256,6 +256,9 @@ end function main_menu:update() local osd = OSD:new():size(config.font_size):align(4) + if encoder.alive == false then + osd:red("Error: "):append("mpv is not found in the PATH."):newline() + end osd:submenu('Clip creator'):newline() osd:tab():item('Start time: '):append(h.human_readable_time(self.timings['start'])):newline() osd:tab():item('End time: '):append(h.human_readable_time(self.timings['end'])):newline()