From 5ea390c07f166ad1186b409176dd4e27d93b6f92 Mon Sep 17 00:00:00 2001 From: Rostislav Pehlivanov Date: Fri, 4 Aug 2017 09:07:37 +0100 Subject: TOOLS/lua/status-line: improve and update Updates the line once per second rather than once per frame, saving quite a bit of CPU. Also completely stops the script while paused. That aside, fixes the swapped checks for video and audio-only files and adds bitrate printing. --- TOOLS/lua/status-line.lua | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/TOOLS/lua/status-line.lua b/TOOLS/lua/status-line.lua index 26ae8afb22..e40dce234f 100644 --- a/TOOLS/lua/status-line.lua +++ b/TOOLS/lua/status-line.lua @@ -18,10 +18,10 @@ function update_status_line() atsl("(Buffering) ") end - if mp.get_property("vid") ~= "no" then + if mp.get_property("aid") ~= "no" then atsl("A") end - if mp.get_property("aid") ~= "no" then + if mp.get_property("vid") ~= "no" then atsl("V") end @@ -43,7 +43,7 @@ function update_status_line() r = mp.get_property_number("avsync", nil) if r ~= nil then - atsl(string.format(" A-V: %7.3f", r)) + atsl(string.format(" A-V: %f", r)) end r = mp.get_property("total-avsync-change", 0) @@ -51,12 +51,24 @@ function update_status_line() atsl(string.format(" ct:%7.3f", r)) end - r = mp.get_property_number("drop-frame-count", -1) + r = mp.get_property_number("decoder-drop-frame-count", -1) if r > 0 then atsl(" Late: ") atsl(r) end + r = mp.get_property_osd("video-bitrate") + if r ~= nil and r ~= "" then + atsl(" Vb: ") + atsl(r) + end + + r = mp.get_property_osd("audio-bitrate") + if r ~= nil and r ~= "" then + atsl(" Ab: ") + atsl(r) + end + r = mp.get_property_number("cache", 0) if r > 0 then atsl(string.format(" Cache: %d%% ", r)) @@ -66,6 +78,15 @@ function update_status_line() mp.set_property("options/term-status-msg", newStatus) end --- Register the event -mp.register_event("tick", update_status_line) +timer = mp.add_periodic_timer(1, update_status_line) +function on_pause_change(name, value) + if value == false then + timer:resume() + else + timer:stop() + end + mp.add_timeout(0.1, update_status_line) +end +mp.observe_property("pause", "bool", on_pause_change) +mp.register_event("seek", update_status_line) -- cgit v1.2.3