warn if encoder is not available
This commit is contained in:
parent
8699be53aa
commit
94eba22ec9
15
encoder.lua
15
encoder.lua
|
@ -139,7 +139,7 @@ this.create_clip = function(clip_type, on_complete)
|
||||||
|
|
||||||
h.notify("Please wait...", "info", 9999)
|
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()
|
local clip_filename_noext = construct_output_filename_noext()
|
||||||
if clip_type == 'video' then
|
if clip_type == 'video' then
|
||||||
local output_path = this.mk_out_path_video(clip_filename_noext)
|
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()
|
this.timings:reset()
|
||||||
end
|
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.init = function(config, timings_mgr)
|
||||||
this.config = config
|
this.config = config
|
||||||
this.timings = timings_mgr
|
this.timings = timings_mgr
|
||||||
|
this.set_encoder_alive()
|
||||||
end
|
end
|
||||||
|
|
||||||
return this
|
return this
|
||||||
|
|
|
@ -26,7 +26,7 @@ function OSD:new()
|
||||||
end
|
end
|
||||||
|
|
||||||
function OSD:append(s)
|
function OSD:append(s)
|
||||||
table.insert(self.messages, s)
|
table.insert(self.messages, tostring(s))
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -42,6 +42,10 @@ function OSD:size(size)
|
||||||
return self:append('{\\fs'):append(size):append('}')
|
return self:append('{\\fs'):append(size):append('}')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function OSD:font(name)
|
||||||
|
return self:append('{\\fn'):append(name):append('}')
|
||||||
|
end
|
||||||
|
|
||||||
function OSD:align(number)
|
function OSD:align(number)
|
||||||
return self:append('{\\an'):append(number):append('}')
|
return self:append('{\\an'):append(number):append('}')
|
||||||
end
|
end
|
||||||
|
@ -62,6 +66,10 @@ function OSD:text(text)
|
||||||
return self:append(text)
|
return self:append(text)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function OSD:new_layer()
|
||||||
|
return self:append('\n')
|
||||||
|
end
|
||||||
|
|
||||||
function OSD:bold(s)
|
function OSD:bold(s)
|
||||||
return self:append('{\\b1}'):append(s):append('{\\b0}')
|
return self:append('{\\b1}'):append(s):append('{\\b0}')
|
||||||
end
|
end
|
||||||
|
@ -78,4 +86,12 @@ function OSD:item(text)
|
||||||
return self:color('fef6dd'):bold(text):color('ffffff')
|
return self:color('fef6dd'):bold(text):color('ffffff')
|
||||||
end
|
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
|
return OSD
|
||||||
|
|
|
@ -256,6 +256,9 @@ end
|
||||||
|
|
||||||
function main_menu:update()
|
function main_menu:update()
|
||||||
local osd = OSD:new():size(config.font_size):align(4)
|
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:submenu('Clip creator'):newline()
|
||||||
osd:tab():item('Start time: '):append(h.human_readable_time(self.timings['start'])):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()
|
osd:tab():item('End time: '):append(h.human_readable_time(self.timings['end'])):newline()
|
||||||
|
|
Loading…
Reference in a new issue