2015-04-03 15:22:32 +00:00
|
|
|
-- Display some stats.
|
|
|
|
--
|
2016-07-08 08:53:02 +00:00
|
|
|
-- Please consult the readme for information about usage and configuration:
|
|
|
|
-- https://github.com/Argon-/mpv-stats
|
2015-04-03 15:22:32 +00:00
|
|
|
--
|
|
|
|
-- Please note: not every property is always available and therefore not always
|
|
|
|
-- visible.
|
|
|
|
|
2016-07-12 15:46:40 +00:00
|
|
|
local mp = require 'mp'
|
2015-05-29 14:04:57 +00:00
|
|
|
local options = require 'mp.options'
|
2017-12-26 16:54:03 +00:00
|
|
|
local utils = require 'mp.utils'
|
2015-04-03 15:22:32 +00:00
|
|
|
|
2015-05-29 14:04:57 +00:00
|
|
|
-- Options
|
2015-04-03 15:22:32 +00:00
|
|
|
local o = {
|
2016-05-17 20:23:11 +00:00
|
|
|
-- Default key bindings
|
|
|
|
key_oneshot = "i",
|
|
|
|
key_toggle = "I",
|
stats: support for multiple "pages" of stats
Please note that the latest version of this script needs a very recent
version of mpv (from yesterday, to be precise, see the readme).
For older versions, please go to "releases".
HOW IT WORKS:
While the stats are visible (i.e. text is printed to the OSD) a
subsequent click on a numeric key (1, 2, ...) will display the
corresponding "page".
This works no matter if the stats are toggled or just shown as a single
invocation. In case of a single invocation, the newly displayed page
will be shown for the full duration again.
The selected page will be remembered (not persistantly though).
So far, only 3 pages are available.
1: the default page, stats as they used to be
2: extensive VO performance stats (to be redesigned/changed soon)
3: dummy
In the future, many more pages are possible.
Implementation is likely to change again (functionality will stay
the same). A new timer had to be introduced to remove the forced
keybindings in the oneshot case. The toggle case can remove them without
a timer. Ensuring that each mode won't remove timers of the other mode
didn't really turn out neat.
Therefore, I intend to change this again, maybe by merging the
oneshot case into the toggle case.
2017-07-02 01:00:49 +00:00
|
|
|
key_page_1 = "1",
|
|
|
|
key_page_2 = "2",
|
|
|
|
key_page_3 = "3",
|
2016-05-17 20:23:11 +00:00
|
|
|
|
stats: support for multiple "pages" of stats
Please note that the latest version of this script needs a very recent
version of mpv (from yesterday, to be precise, see the readme).
For older versions, please go to "releases".
HOW IT WORKS:
While the stats are visible (i.e. text is printed to the OSD) a
subsequent click on a numeric key (1, 2, ...) will display the
corresponding "page".
This works no matter if the stats are toggled or just shown as a single
invocation. In case of a single invocation, the newly displayed page
will be shown for the full duration again.
The selected page will be remembered (not persistantly though).
So far, only 3 pages are available.
1: the default page, stats as they used to be
2: extensive VO performance stats (to be redesigned/changed soon)
3: dummy
In the future, many more pages are possible.
Implementation is likely to change again (functionality will stay
the same). A new timer had to be introduced to remove the forced
keybindings in the oneshot case. The toggle case can remove them without
a timer. Ensuring that each mode won't remove timers of the other mode
didn't really turn out neat.
Therefore, I intend to change this again, maybe by merging the
oneshot case into the toggle case.
2017-07-02 01:00:49 +00:00
|
|
|
duration = 4,
|
2016-07-12 15:46:40 +00:00
|
|
|
redraw_delay = 1, -- acts as duration in the toggling case
|
2016-05-17 20:23:11 +00:00
|
|
|
ass_formatting = true,
|
2017-09-23 15:54:40 +00:00
|
|
|
persistent_overlay = false, -- whether the stats can be overwritten by other output
|
2017-06-30 19:46:16 +00:00
|
|
|
print_perfdata_passes = false, -- when true, print the full information about all passes
|
2017-07-25 13:37:09 +00:00
|
|
|
filter_params_max_length = 100, -- a filter list longer than this many characters will be shown one filter per line instead
|
2015-05-22 19:41:55 +00:00
|
|
|
debug = false,
|
2015-05-29 14:04:57 +00:00
|
|
|
|
2016-07-08 08:53:02 +00:00
|
|
|
-- Graph options and style
|
2016-09-12 00:30:09 +00:00
|
|
|
plot_perfdata = true,
|
|
|
|
plot_vsync_ratio = true,
|
|
|
|
plot_vsync_jitter = true,
|
2016-07-12 15:46:40 +00:00
|
|
|
skip_frames = 5,
|
|
|
|
global_max = true,
|
2016-09-12 00:30:09 +00:00
|
|
|
flush_graph_data = true, -- clear data buffers when toggling
|
2016-06-10 22:04:14 +00:00
|
|
|
plot_bg_border_color = "0000FF",
|
|
|
|
plot_bg_color = "262626",
|
|
|
|
plot_color = "FFFFFF",
|
|
|
|
|
2015-05-29 14:04:57 +00:00
|
|
|
-- Text style
|
2018-09-08 21:13:35 +00:00
|
|
|
font = "sans",
|
|
|
|
font_mono = "monospace", -- monospaced digits are sufficient
|
2017-07-27 19:26:54 +00:00
|
|
|
font_size = 8,
|
2015-04-03 15:22:32 +00:00
|
|
|
font_color = "FFFFFF",
|
2016-07-12 15:46:40 +00:00
|
|
|
border_size = 0.8,
|
2015-04-03 15:22:32 +00:00
|
|
|
border_color = "262626",
|
|
|
|
shadow_x_offset = 0.0,
|
|
|
|
shadow_y_offset = 0.0,
|
|
|
|
shadow_color = "000000",
|
|
|
|
alpha = "11",
|
2015-04-28 00:13:27 +00:00
|
|
|
|
|
|
|
-- Custom header for ASS tags to style the text output.
|
|
|
|
-- Specifying this will ignore the text style values above and just
|
|
|
|
-- use this string instead.
|
|
|
|
custom_header = "",
|
|
|
|
|
2015-05-29 14:04:57 +00:00
|
|
|
-- Text formatting
|
|
|
|
-- With ASS
|
2017-07-04 22:31:44 +00:00
|
|
|
ass_nl = "\\N",
|
|
|
|
ass_indent = "\\h\\h\\h\\h\\h",
|
|
|
|
ass_prefix_sep = "\\h\\h",
|
|
|
|
ass_b1 = "{\\b1}",
|
|
|
|
ass_b0 = "{\\b0}",
|
2017-07-25 13:37:09 +00:00
|
|
|
ass_it1 = "{\\i1}",
|
|
|
|
ass_it0 = "{\\i0}",
|
2015-05-29 14:04:57 +00:00
|
|
|
-- Without ASS
|
2015-04-28 00:13:27 +00:00
|
|
|
no_ass_nl = "\n",
|
2015-10-14 07:53:01 +00:00
|
|
|
no_ass_indent = "\t",
|
|
|
|
no_ass_prefix_sep = " ",
|
2015-07-21 19:53:23 +00:00
|
|
|
no_ass_b1 = "\027[1m",
|
|
|
|
no_ass_b0 = "\027[0m",
|
2017-07-25 13:37:09 +00:00
|
|
|
no_ass_it1 = "\027[3m",
|
|
|
|
no_ass_it0 = "\027[0m",
|
2015-04-03 15:22:32 +00:00
|
|
|
}
|
2015-05-29 14:04:57 +00:00
|
|
|
options.read_options(o)
|
2015-04-03 15:22:32 +00:00
|
|
|
|
2016-07-08 08:53:02 +00:00
|
|
|
local format = string.format
|
2016-09-12 00:30:09 +00:00
|
|
|
local max = math.max
|
2017-07-24 20:46:01 +00:00
|
|
|
local min = math.min
|
stats: support for multiple "pages" of stats
Please note that the latest version of this script needs a very recent
version of mpv (from yesterday, to be precise, see the readme).
For older versions, please go to "releases".
HOW IT WORKS:
While the stats are visible (i.e. text is printed to the OSD) a
subsequent click on a numeric key (1, 2, ...) will display the
corresponding "page".
This works no matter if the stats are toggled or just shown as a single
invocation. In case of a single invocation, the newly displayed page
will be shown for the full duration again.
The selected page will be remembered (not persistantly though).
So far, only 3 pages are available.
1: the default page, stats as they used to be
2: extensive VO performance stats (to be redesigned/changed soon)
3: dummy
In the future, many more pages are possible.
Implementation is likely to change again (functionality will stay
the same). A new timer had to be introduced to remove the forced
keybindings in the oneshot case. The toggle case can remove them without
a timer. Ensuring that each mode won't remove timers of the other mode
didn't really turn out neat.
Therefore, I intend to change this again, maybe by merging the
oneshot case into the toggle case.
2017-07-02 01:00:49 +00:00
|
|
|
|
2016-07-19 07:11:51 +00:00
|
|
|
-- Function used to record performance data
|
2016-07-08 08:53:02 +00:00
|
|
|
local recorder = nil
|
2017-09-23 15:54:40 +00:00
|
|
|
-- Timer used for redrawing (toggling) and clearing the screen (oneshot)
|
|
|
|
local display_timer = nil
|
2019-06-22 22:30:56 +00:00
|
|
|
-- Timer used to update cache stats.
|
|
|
|
local cache_recorder_timer = nil
|
stats: support for multiple "pages" of stats
Please note that the latest version of this script needs a very recent
version of mpv (from yesterday, to be precise, see the readme).
For older versions, please go to "releases".
HOW IT WORKS:
While the stats are visible (i.e. text is printed to the OSD) a
subsequent click on a numeric key (1, 2, ...) will display the
corresponding "page".
This works no matter if the stats are toggled or just shown as a single
invocation. In case of a single invocation, the newly displayed page
will be shown for the full duration again.
The selected page will be remembered (not persistantly though).
So far, only 3 pages are available.
1: the default page, stats as they used to be
2: extensive VO performance stats (to be redesigned/changed soon)
3: dummy
In the future, many more pages are possible.
Implementation is likely to change again (functionality will stay
the same). A new timer had to be introduced to remove the forced
keybindings in the oneshot case. The toggle case can remove them without
a timer. Ensuring that each mode won't remove timers of the other mode
didn't really turn out neat.
Therefore, I intend to change this again, maybe by merging the
oneshot case into the toggle case.
2017-07-02 01:00:49 +00:00
|
|
|
-- Current page and <page key>:<page function> mappings
|
|
|
|
local curr_page = o.key_page_1
|
|
|
|
local pages = {}
|
2016-07-19 07:11:51 +00:00
|
|
|
-- Save these sequences locally as we'll need them a lot
|
|
|
|
local ass_start = mp.get_property_osd("osd-ass-cc/0")
|
|
|
|
local ass_stop = mp.get_property_osd("osd-ass-cc/1")
|
2016-09-12 00:30:09 +00:00
|
|
|
-- Ring buffers for the values used to construct a graph.
|
|
|
|
-- .pos denotes the current position, .len the buffer length
|
stats: support for multiple "pages" of stats
Please note that the latest version of this script needs a very recent
version of mpv (from yesterday, to be precise, see the readme).
For older versions, please go to "releases".
HOW IT WORKS:
While the stats are visible (i.e. text is printed to the OSD) a
subsequent click on a numeric key (1, 2, ...) will display the
corresponding "page".
This works no matter if the stats are toggled or just shown as a single
invocation. In case of a single invocation, the newly displayed page
will be shown for the full duration again.
The selected page will be remembered (not persistantly though).
So far, only 3 pages are available.
1: the default page, stats as they used to be
2: extensive VO performance stats (to be redesigned/changed soon)
3: dummy
In the future, many more pages are possible.
Implementation is likely to change again (functionality will stay
the same). A new timer had to be introduced to remove the forced
keybindings in the oneshot case. The toggle case can remove them without
a timer. Ensuring that each mode won't remove timers of the other mode
didn't really turn out neat.
Therefore, I intend to change this again, maybe by merging the
oneshot case into the toggle case.
2017-07-02 01:00:49 +00:00
|
|
|
-- .max is the max value in the corresponding buffer
|
2019-06-22 22:30:56 +00:00
|
|
|
local vsratio_buf, vsjitter_buf, cache_ahead_buf, cache_total_buf
|
2016-09-12 00:30:09 +00:00
|
|
|
local function init_buffers()
|
|
|
|
vsratio_buf = {0, pos = 1, len = 50, max = 0}
|
|
|
|
vsjitter_buf = {0, pos = 1, len = 50, max = 0}
|
2019-06-22 22:30:56 +00:00
|
|
|
cache_ahead_buf = {0, pos = 1, len = 50, max = 0}
|
|
|
|
cache_total_buf = {0, pos = 1, len = 50, max = 0}
|
2016-09-12 00:30:09 +00:00
|
|
|
end
|
2017-06-16 10:38:41 +00:00
|
|
|
-- Save all properties known to this version of mpv
|
|
|
|
local property_list = {}
|
|
|
|
for p in string.gmatch(mp.get_property("property-list"), "([^,]+)") do property_list[p] = true end
|
|
|
|
-- Mapping of properties to their deprecated names
|
|
|
|
local property_aliases = {
|
|
|
|
["decoder-frame-drop-count"] = "drop-frame-count",
|
|
|
|
["frame-drop-count"] = "vo-drop-frame-count",
|
|
|
|
["container-fps"] = "fps",
|
|
|
|
}
|
stats: support for multiple "pages" of stats
Please note that the latest version of this script needs a very recent
version of mpv (from yesterday, to be precise, see the readme).
For older versions, please go to "releases".
HOW IT WORKS:
While the stats are visible (i.e. text is printed to the OSD) a
subsequent click on a numeric key (1, 2, ...) will display the
corresponding "page".
This works no matter if the stats are toggled or just shown as a single
invocation. In case of a single invocation, the newly displayed page
will be shown for the full duration again.
The selected page will be remembered (not persistantly though).
So far, only 3 pages are available.
1: the default page, stats as they used to be
2: extensive VO performance stats (to be redesigned/changed soon)
3: dummy
In the future, many more pages are possible.
Implementation is likely to change again (functionality will stay
the same). A new timer had to be introduced to remove the forced
keybindings in the oneshot case. The toggle case can remove them without
a timer. Ensuring that each mode won't remove timers of the other mode
didn't really turn out neat.
Therefore, I intend to change this again, maybe by merging the
oneshot case into the toggle case.
2017-07-02 01:00:49 +00:00
|
|
|
|
|
|
|
|
2017-06-16 10:38:41 +00:00
|
|
|
-- Return deprecated name for the given property
|
|
|
|
local function compat(p)
|
|
|
|
while not property_list[p] and property_aliases[p] do
|
|
|
|
p = property_aliases[p]
|
|
|
|
end
|
|
|
|
return p
|
|
|
|
end
|
|
|
|
|
2015-04-27 17:10:08 +00:00
|
|
|
|
2016-07-12 17:19:34 +00:00
|
|
|
local function set_ASS(b)
|
2017-09-23 15:54:40 +00:00
|
|
|
if not o.use_ass or o.persistent_overlay then
|
2016-07-12 17:19:34 +00:00
|
|
|
return ""
|
2015-07-05 19:24:36 +00:00
|
|
|
end
|
2016-07-19 07:11:51 +00:00
|
|
|
return b and ass_start or ass_stop
|
2015-04-03 15:22:32 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
2016-07-12 17:19:34 +00:00
|
|
|
local function no_ASS(t)
|
|
|
|
return set_ASS(false) .. t .. set_ASS(true)
|
2015-04-03 15:22:32 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
2016-07-12 17:19:34 +00:00
|
|
|
local function b(t)
|
|
|
|
return o.b1 .. t .. o.b0
|
2016-06-10 22:04:14 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
2017-07-25 13:37:09 +00:00
|
|
|
local function it(t)
|
|
|
|
return o.it1 .. t .. o.it0
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2016-07-12 17:19:34 +00:00
|
|
|
local function text_style()
|
2017-07-04 22:31:44 +00:00
|
|
|
if not o.use_ass then
|
2016-06-10 22:04:14 +00:00
|
|
|
return ""
|
2015-04-27 17:10:08 +00:00
|
|
|
end
|
2015-04-03 15:22:32 +00:00
|
|
|
if o.custom_header and o.custom_header ~= "" then
|
2016-06-10 22:04:14 +00:00
|
|
|
return set_ASS(true) .. o.custom_header
|
2015-04-03 15:22:32 +00:00
|
|
|
else
|
2017-09-23 15:54:40 +00:00
|
|
|
return format("%s{\\r}{\\an7}{\\fs%d}{\\fn%s}{\\bord%f}{\\3c&H%s&}" ..
|
|
|
|
"{\\1c&H%s&}{\\alpha&H%s&}{\\xshad%f}{\\yshad%f}{\\4c&H%s&}",
|
|
|
|
set_ASS(true), o.font_size, o.font, o.border_size,
|
|
|
|
o.border_color, o.font_color, o.alpha, o.shadow_x_offset,
|
|
|
|
o.shadow_y_offset, o.shadow_color)
|
2015-04-03 15:22:32 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2016-07-12 17:19:34 +00:00
|
|
|
local function has_vo_window()
|
|
|
|
return mp.get_property("vo-configured") == "yes"
|
|
|
|
end
|
2015-04-03 15:22:32 +00:00
|
|
|
|
2015-07-05 19:24:36 +00:00
|
|
|
|
2016-07-12 17:19:34 +00:00
|
|
|
local function has_ansi()
|
2017-09-23 15:54:40 +00:00
|
|
|
local is_windows = type(package) == 'table'
|
|
|
|
and type(package.config) == 'string'
|
|
|
|
and package.config:sub(1, 1) == '\\'
|
2016-07-12 17:19:34 +00:00
|
|
|
if is_windows then
|
|
|
|
return os.getenv("ANSICON")
|
|
|
|
end
|
2015-04-03 15:22:32 +00:00
|
|
|
return true
|
|
|
|
end
|
|
|
|
|
2016-09-12 00:30:09 +00:00
|
|
|
|
2016-09-11 09:34:11 +00:00
|
|
|
-- Generate a graph from the given values.
|
|
|
|
-- Returns an ASS formatted vector drawing as string.
|
|
|
|
--
|
stats: support for multiple "pages" of stats
Please note that the latest version of this script needs a very recent
version of mpv (from yesterday, to be precise, see the readme).
For older versions, please go to "releases".
HOW IT WORKS:
While the stats are visible (i.e. text is printed to the OSD) a
subsequent click on a numeric key (1, 2, ...) will display the
corresponding "page".
This works no matter if the stats are toggled or just shown as a single
invocation. In case of a single invocation, the newly displayed page
will be shown for the full duration again.
The selected page will be remembered (not persistantly though).
So far, only 3 pages are available.
1: the default page, stats as they used to be
2: extensive VO performance stats (to be redesigned/changed soon)
3: dummy
In the future, many more pages are possible.
Implementation is likely to change again (functionality will stay
the same). A new timer had to be introduced to remove the forced
keybindings in the oneshot case. The toggle case can remove them without
a timer. Ensuring that each mode won't remove timers of the other mode
didn't really turn out neat.
Therefore, I intend to change this again, maybe by merging the
oneshot case into the toggle case.
2017-07-02 01:00:49 +00:00
|
|
|
-- values: Array/table of numbers representing the data. Used like a ring buffer
|
2016-09-11 09:34:11 +00:00
|
|
|
-- it will get iterated backwards `len` times starting at position `i`.
|
|
|
|
-- i : Index of the latest data value in `values`.
|
|
|
|
-- len : The length/amount of numbers in `values`.
|
|
|
|
-- v_max : The maximum number in `values`. It is used to scale all data
|
|
|
|
-- values to a range of 0 to `v_max`.
|
2017-06-30 22:31:05 +00:00
|
|
|
-- v_avg : The average number in `values`. It is used to try and center graphs
|
|
|
|
-- if possible. May be left as nil
|
2016-09-11 09:34:11 +00:00
|
|
|
-- scale : A value that will be multiplied with all data values.
|
2017-06-30 19:46:16 +00:00
|
|
|
-- x_tics: Horizontal width multiplier for the steps
|
2017-06-30 22:31:05 +00:00
|
|
|
local function generate_graph(values, i, len, v_max, v_avg, scale, x_tics)
|
2016-09-12 00:30:09 +00:00
|
|
|
-- Check if at least one value exists
|
|
|
|
if not values[i] then
|
2016-07-08 08:53:02 +00:00
|
|
|
return ""
|
|
|
|
end
|
|
|
|
|
2016-09-11 01:34:44 +00:00
|
|
|
local x_max = (len - 1) * x_tics
|
2016-06-10 22:04:14 +00:00
|
|
|
local y_offset = o.border_size
|
2016-07-12 15:46:40 +00:00
|
|
|
local y_max = o.font_size * 0.66
|
2016-06-10 22:04:14 +00:00
|
|
|
local x = 0
|
|
|
|
|
2017-06-30 22:31:05 +00:00
|
|
|
-- try and center the graph if possible, but avoid going above `scale`
|
|
|
|
if v_avg then
|
2017-07-24 20:46:01 +00:00
|
|
|
scale = min(scale, v_max / (2 * v_avg))
|
2017-06-30 22:31:05 +00:00
|
|
|
end
|
|
|
|
|
2016-07-12 15:46:40 +00:00
|
|
|
local s = {format("m 0 0 n %f %f l ", x, y_max - (y_max * values[i] / v_max * scale))}
|
2016-09-11 01:34:44 +00:00
|
|
|
i = ((i - 2) % len) + 1
|
2016-06-10 22:04:14 +00:00
|
|
|
|
2016-09-11 01:34:44 +00:00
|
|
|
for p = 1, len - 1 do
|
2016-06-10 22:04:14 +00:00
|
|
|
if values[i] then
|
|
|
|
x = x - x_tics
|
2016-07-12 15:46:40 +00:00
|
|
|
s[#s+1] = format("%f %f ", x, y_max - (y_max * values[i] / v_max * scale))
|
2016-06-10 22:04:14 +00:00
|
|
|
end
|
2016-09-11 01:34:44 +00:00
|
|
|
i = ((i - 2) % len) + 1
|
2016-06-10 22:04:14 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
s[#s+1] = format("%f %f %f %f", x, y_max, 0, y_max)
|
|
|
|
|
2016-07-08 08:53:02 +00:00
|
|
|
local bg_box = format("{\\bord0.5}{\\3c&H%s&}{\\1c&H%s&}m 0 %f l %f %f %f 0 0 0",
|
|
|
|
o.plot_bg_border_color, o.plot_bg_color, y_max, x_max, y_max, x_max)
|
2017-07-10 21:12:03 +00:00
|
|
|
return format("%s{\\r}{\\pbo%f}{\\shad0}{\\alpha&H00}{\\p1}%s{\\p0}{\\bord0}{\\1c&H%s}{\\p1}%s{\\p0}%s",
|
2016-07-13 08:11:18 +00:00
|
|
|
o.prefix_sep, y_offset, bg_box, o.plot_color, table.concat(s), text_style())
|
2016-07-08 08:53:02 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
2017-12-26 16:54:03 +00:00
|
|
|
local function append(s, str, attr)
|
2018-03-24 21:36:01 +00:00
|
|
|
if not str then
|
|
|
|
return false
|
|
|
|
end
|
2017-12-26 16:54:03 +00:00
|
|
|
attr.prefix_sep = attr.prefix_sep or o.prefix_sep
|
|
|
|
attr.indent = attr.indent or o.indent
|
|
|
|
attr.nl = attr.nl or o.nl
|
|
|
|
attr.suffix = attr.suffix or ""
|
|
|
|
attr.prefix = attr.prefix or ""
|
|
|
|
attr.no_prefix_markup = attr.no_prefix_markup or false
|
|
|
|
attr.prefix = attr.no_prefix_markup and attr.prefix or b(attr.prefix)
|
|
|
|
s[#s+1] = format("%s%s%s%s%s%s", attr.nl, attr.indent,
|
|
|
|
attr.prefix, attr.prefix_sep, no_ASS(str), attr.suffix)
|
2018-03-24 21:36:01 +00:00
|
|
|
return true
|
2017-12-26 16:54:03 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
2016-09-12 00:30:09 +00:00
|
|
|
-- Format and append a property.
|
|
|
|
-- A property whose value is either `nil` or empty (hereafter called "invalid")
|
|
|
|
-- is skipped and not appended.
|
|
|
|
-- Returns `false` in case nothing was appended, otherwise `true`.
|
|
|
|
--
|
|
|
|
-- s : Table containing strings.
|
|
|
|
-- prop : The property to query and format (based on its OSD representation).
|
|
|
|
-- attr : Optional table to overwrite certain (formatting) attributes for
|
|
|
|
-- this property.
|
|
|
|
-- exclude: Optional table containing keys which are considered invalid values
|
|
|
|
-- for this property. Specifying this will replace empty string as
|
|
|
|
-- default invalid value (nil is always invalid).
|
|
|
|
local function append_property(s, prop, attr, excluded)
|
|
|
|
excluded = excluded or {[""] = true}
|
|
|
|
local ret = mp.get_property_osd(prop)
|
|
|
|
if not ret or excluded[ret] then
|
|
|
|
if o.debug then
|
|
|
|
print("No value for property: " .. prop)
|
|
|
|
end
|
|
|
|
return false
|
|
|
|
end
|
2018-03-24 21:36:01 +00:00
|
|
|
return append(s, ret, attr)
|
2016-09-12 00:30:09 +00:00
|
|
|
end
|
|
|
|
|
stats: support for multiple "pages" of stats
Please note that the latest version of this script needs a very recent
version of mpv (from yesterday, to be precise, see the readme).
For older versions, please go to "releases".
HOW IT WORKS:
While the stats are visible (i.e. text is printed to the OSD) a
subsequent click on a numeric key (1, 2, ...) will display the
corresponding "page".
This works no matter if the stats are toggled or just shown as a single
invocation. In case of a single invocation, the newly displayed page
will be shown for the full duration again.
The selected page will be remembered (not persistantly though).
So far, only 3 pages are available.
1: the default page, stats as they used to be
2: extensive VO performance stats (to be redesigned/changed soon)
3: dummy
In the future, many more pages are possible.
Implementation is likely to change again (functionality will stay
the same). A new timer had to be introduced to remove the forced
keybindings in the oneshot case. The toggle case can remove them without
a timer. Ensuring that each mode won't remove timers of the other mode
didn't really turn out neat.
Therefore, I intend to change this again, maybe by merging the
oneshot case into the toggle case.
2017-07-02 01:00:49 +00:00
|
|
|
|
2017-07-24 21:10:20 +00:00
|
|
|
local function append_perfdata(s, dedicated_page)
|
2017-06-30 19:46:16 +00:00
|
|
|
local vo_p = mp.get_property_native("vo-passes")
|
2016-07-08 08:53:02 +00:00
|
|
|
if not vo_p then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
2016-07-27 18:28:42 +00:00
|
|
|
local ds = mp.get_property_bool("display-sync-active", false)
|
2016-12-19 12:34:21 +00:00
|
|
|
local target_fps = ds and mp.get_property_number("display-fps", 0)
|
2017-06-16 10:38:41 +00:00
|
|
|
or mp.get_property_number(compat("container-fps"), 0)
|
2017-06-30 19:46:16 +00:00
|
|
|
if target_fps > 0 then target_fps = 1 / target_fps * 1e9 end
|
2016-06-10 22:04:14 +00:00
|
|
|
|
2017-07-24 20:46:01 +00:00
|
|
|
-- Sums of all last/avg/peak values
|
2017-06-30 19:46:16 +00:00
|
|
|
local last_s, avg_s, peak_s = {}, {}, {}
|
|
|
|
for frame, data in pairs(vo_p) do
|
|
|
|
last_s[frame], avg_s[frame], peak_s[frame] = 0, 0, 0
|
|
|
|
for _, pass in ipairs(data) do
|
|
|
|
last_s[frame] = last_s[frame] + pass["last"]
|
|
|
|
avg_s[frame] = avg_s[frame] + pass["avg"]
|
|
|
|
peak_s[frame] = peak_s[frame] + pass["peak"]
|
|
|
|
end
|
|
|
|
end
|
2016-06-10 22:04:14 +00:00
|
|
|
|
2017-09-16 23:21:44 +00:00
|
|
|
-- Pretty print measured time
|
|
|
|
local function pp(i)
|
2017-06-30 19:46:16 +00:00
|
|
|
-- rescale to microseconds for a saner display
|
2017-09-16 23:21:44 +00:00
|
|
|
return format("%05d", i / 1000)
|
2016-07-08 08:53:02 +00:00
|
|
|
end
|
|
|
|
|
2017-07-24 20:46:01 +00:00
|
|
|
-- Format n/m with a font weight based on the ratio
|
|
|
|
local function p(n, m)
|
|
|
|
local i = 0
|
|
|
|
if m > 0 then
|
|
|
|
i = tonumber(n) / m
|
|
|
|
end
|
|
|
|
-- Calculate font weight. 100 is minimum, 400 is normal, 700 bold, 900 is max
|
|
|
|
local w = (700 * math.sqrt(i)) + 200
|
2017-07-24 21:40:09 +00:00
|
|
|
return format("{\\b%d}%02d%%{\\b0}", w, i * 100)
|
2017-07-24 20:46:01 +00:00
|
|
|
end
|
|
|
|
|
2017-09-23 15:54:40 +00:00
|
|
|
s[#s+1] = format("%s%s%s%s{\\fs%s}%s{\\fs%s}",
|
|
|
|
dedicated_page and "" or o.nl, dedicated_page and "" or o.indent,
|
2017-07-28 07:30:24 +00:00
|
|
|
b("Frame Timings:"), o.prefix_sep, o.font_size * 0.66,
|
2017-06-30 19:46:16 +00:00
|
|
|
"(last/average/peak μs)", o.font_size)
|
2016-07-12 15:46:40 +00:00
|
|
|
|
2017-06-30 19:46:16 +00:00
|
|
|
for frame, data in pairs(vo_p) do
|
2017-07-24 21:10:20 +00:00
|
|
|
local f = "%s%s%s{\\fn%s}%s / %s / %s %s%s{\\fn%s}%s%s%s"
|
2016-07-12 15:46:40 +00:00
|
|
|
|
2017-07-24 21:10:20 +00:00
|
|
|
if dedicated_page then
|
|
|
|
s[#s+1] = format("%s%s%s:", o.nl, o.indent,
|
2017-06-30 19:46:16 +00:00
|
|
|
b(frame:gsub("^%l", string.upper)))
|
2016-07-12 15:46:40 +00:00
|
|
|
|
2017-06-30 19:46:16 +00:00
|
|
|
for _, pass in ipairs(data) do
|
2017-07-24 21:10:20 +00:00
|
|
|
s[#s+1] = format(f, o.nl, o.indent, o.indent,
|
2017-09-16 23:21:44 +00:00
|
|
|
o.font_mono, pp(pass["last"]),
|
|
|
|
pp(pass["avg"]), pp(pass["peak"]),
|
2017-07-24 20:46:01 +00:00
|
|
|
o.prefix_sep .. o.prefix_sep, p(pass["last"], last_s[frame]),
|
2017-07-24 21:10:20 +00:00
|
|
|
o.font, o.prefix_sep, o.prefix_sep, pass["desc"])
|
2016-07-12 15:46:40 +00:00
|
|
|
|
2017-07-04 22:31:44 +00:00
|
|
|
if o.plot_perfdata and o.use_ass then
|
2017-06-30 19:46:16 +00:00
|
|
|
s[#s+1] = generate_graph(pass["samples"], pass["count"],
|
|
|
|
pass["count"], pass["peak"],
|
2017-06-30 22:31:05 +00:00
|
|
|
pass["avg"], 0.9, 0.25)
|
2017-06-30 19:46:16 +00:00
|
|
|
end
|
|
|
|
end
|
2016-07-12 15:46:40 +00:00
|
|
|
|
2017-07-24 20:46:01 +00:00
|
|
|
-- Print sum of timing values as "Total"
|
2017-07-24 21:10:20 +00:00
|
|
|
s[#s+1] = format(f, o.nl, o.indent, o.indent,
|
2017-09-16 23:21:44 +00:00
|
|
|
o.font_mono, pp(last_s[frame]),
|
|
|
|
pp(avg_s[frame]), pp(peak_s[frame]), "", "", o.font,
|
2017-07-24 21:10:20 +00:00
|
|
|
o.prefix_sep, o.prefix_sep, b("Total"))
|
2017-06-30 19:46:16 +00:00
|
|
|
else
|
|
|
|
-- for the simplified view, we just print the sum of each pass
|
2017-07-24 21:10:20 +00:00
|
|
|
s[#s+1] = format(f, o.nl, o.indent, o.indent, o.font_mono,
|
2017-09-16 23:21:44 +00:00
|
|
|
pp(last_s[frame]), pp(avg_s[frame]), pp(peak_s[frame]),
|
2017-07-24 21:10:20 +00:00
|
|
|
"", "", o.font, o.prefix_sep, o.prefix_sep,
|
2017-07-24 20:46:01 +00:00
|
|
|
frame:gsub("^%l", string.upper))
|
2017-06-30 19:46:16 +00:00
|
|
|
end
|
2016-07-13 08:11:18 +00:00
|
|
|
end
|
2016-06-10 22:04:14 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
2017-01-18 20:35:59 +00:00
|
|
|
local function append_display_sync(s)
|
2016-09-12 00:30:09 +00:00
|
|
|
if not mp.get_property_bool("display-sync-active", false) then
|
|
|
|
return
|
2016-07-12 17:19:34 +00:00
|
|
|
end
|
|
|
|
|
2016-09-12 00:30:09 +00:00
|
|
|
local vspeed = append_property(s, "video-speed-correction", {prefix="DS:"})
|
|
|
|
if vspeed then
|
|
|
|
append_property(s, "audio-speed-correction",
|
|
|
|
{prefix="/", nl="", indent=" ", prefix_sep=" ", no_prefix_markup=true})
|
|
|
|
else
|
|
|
|
append_property(s, "audio-speed-correction",
|
|
|
|
{prefix="DS:" .. o.prefix_sep .. " - / ", prefix_sep=""})
|
|
|
|
end
|
2016-07-12 17:19:34 +00:00
|
|
|
|
2017-08-12 12:08:35 +00:00
|
|
|
append_property(s, "mistimed-frame-count", {prefix="Mistimed:", nl=""})
|
|
|
|
append_property(s, "vo-delayed-frame-count", {prefix="Delayed:", nl=""})
|
|
|
|
|
2017-01-21 13:31:46 +00:00
|
|
|
-- As we need to plot some graphs we print jitter and ratio on their own lines
|
2017-09-23 15:54:40 +00:00
|
|
|
if not display_timer.oneshot and (o.plot_vsync_ratio or o.plot_vsync_jitter) and o.use_ass then
|
2017-01-21 13:31:46 +00:00
|
|
|
local ratio_graph = ""
|
|
|
|
local jitter_graph = ""
|
2016-09-12 00:30:09 +00:00
|
|
|
if o.plot_vsync_ratio then
|
2017-06-30 22:31:05 +00:00
|
|
|
ratio_graph = generate_graph(vsratio_buf, vsratio_buf.pos, vsratio_buf.len, vsratio_buf.max, nil, 0.8, 1)
|
2016-09-12 00:30:09 +00:00
|
|
|
end
|
|
|
|
if o.plot_vsync_jitter then
|
2017-06-30 22:31:05 +00:00
|
|
|
jitter_graph = generate_graph(vsjitter_buf, vsjitter_buf.pos, vsjitter_buf.len, vsjitter_buf.max, nil, 0.8, 1)
|
2016-09-12 00:30:09 +00:00
|
|
|
end
|
2017-01-21 13:31:46 +00:00
|
|
|
append_property(s, "vsync-ratio", {prefix="VSync Ratio:", suffix=o.prefix_sep .. ratio_graph})
|
|
|
|
append_property(s, "vsync-jitter", {prefix="VSync Jitter:", suffix=o.prefix_sep .. jitter_graph})
|
|
|
|
else
|
|
|
|
-- Since no graph is needed we can print ratio/jitter on the same line and save some space
|
|
|
|
local vratio = append_property(s, "vsync-ratio", {prefix="VSync Ratio:"})
|
|
|
|
append_property(s, "vsync-jitter", {prefix="VSync Jitter:", nl="" or o.nl})
|
2016-09-12 00:30:09 +00:00
|
|
|
end
|
2015-04-03 15:22:32 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
2017-07-25 13:37:09 +00:00
|
|
|
local function append_filters(s, prop, prefix)
|
|
|
|
local length = 0
|
|
|
|
local filters = {}
|
|
|
|
|
|
|
|
for _,f in ipairs(mp.get_property_native(prop, {})) do
|
|
|
|
local n = f.name
|
|
|
|
if f.enabled ~= nil and not f.enabled then
|
|
|
|
n = n .. " (disabled)"
|
|
|
|
end
|
|
|
|
|
|
|
|
local p = {}
|
|
|
|
for key,value in pairs(f.params) do
|
|
|
|
p[#p+1] = key .. "=" .. value
|
|
|
|
end
|
|
|
|
if #p > 0 then
|
|
|
|
p = " [" .. table.concat(p, " ") .. "]"
|
|
|
|
else
|
|
|
|
p = ""
|
|
|
|
end
|
|
|
|
|
|
|
|
length = length + n:len() + p:len()
|
|
|
|
filters[#filters+1] = no_ASS(n) .. it(no_ASS(p))
|
|
|
|
end
|
|
|
|
|
|
|
|
if #filters > 0 then
|
|
|
|
local ret
|
|
|
|
if length < o.filter_params_max_length then
|
|
|
|
ret = table.concat(filters, ", ")
|
|
|
|
else
|
|
|
|
local sep = o.nl .. o.indent .. o.indent
|
|
|
|
ret = sep .. table.concat(filters, sep)
|
|
|
|
end
|
|
|
|
s[#s+1] = o.nl .. o.indent .. b(prefix) .. o.prefix_sep .. ret
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2016-07-12 17:19:34 +00:00
|
|
|
local function add_header(s)
|
2017-07-10 21:12:03 +00:00
|
|
|
s[#s+1] = text_style()
|
2015-04-03 15:22:32 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
2016-07-12 17:19:34 +00:00
|
|
|
local function add_file(s)
|
2018-06-08 21:54:22 +00:00
|
|
|
append(s, "", {prefix="File:", nl="", indent=""})
|
2018-03-24 21:43:04 +00:00
|
|
|
append_property(s, "filename", {prefix_sep="", nl="", indent=""})
|
2016-07-12 17:19:34 +00:00
|
|
|
if not (mp.get_property_osd("filename") == mp.get_property_osd("media-title")) then
|
|
|
|
append_property(s, "media-title", {prefix="Title:"})
|
|
|
|
end
|
2017-08-25 21:57:17 +00:00
|
|
|
|
2019-01-13 12:34:15 +00:00
|
|
|
local fs = append_property(s, "file-size", {prefix="Size:"})
|
|
|
|
append_property(s, "file-format", {prefix="Format/Protocol:", nl=fs and "" or o.nl})
|
2018-09-22 09:35:32 +00:00
|
|
|
|
2017-08-25 21:57:17 +00:00
|
|
|
local ch_index = mp.get_property_number("chapter")
|
|
|
|
if ch_index and ch_index >= 0 then
|
|
|
|
append_property(s, "chapter-list/" .. tostring(ch_index) .. "/title", {prefix="Chapter:"})
|
|
|
|
append_property(s, "chapter-list/count",
|
|
|
|
{prefix="(" .. tostring(ch_index + 1) .. "/", suffix=")", nl="",
|
|
|
|
indent=" ", prefix_sep=" ", no_prefix_markup=true})
|
|
|
|
end
|
2017-12-26 16:54:03 +00:00
|
|
|
|
|
|
|
local demuxer_cache = mp.get_property_native("demuxer-cache-state", {})
|
|
|
|
if demuxer_cache["fw-bytes"] then
|
|
|
|
demuxer_cache = demuxer_cache["fw-bytes"] -- returns bytes
|
|
|
|
else
|
|
|
|
demuxer_cache = 0
|
|
|
|
end
|
|
|
|
local demuxer_secs = mp.get_property_number("demuxer-cache-duration", 0)
|
2018-12-06 18:01:26 +00:00
|
|
|
if demuxer_cache + demuxer_secs > 0 then
|
|
|
|
append(s, utils.format_bytes_humanized(demuxer_cache), {prefix="Total Cache:"})
|
|
|
|
append(s, format("%.1f", demuxer_secs), {prefix="(", suffix=" sec)", nl="",
|
|
|
|
no_prefix_markup=true, prefix_sep="", indent=o.prefix_sep})
|
2017-12-26 16:54:03 +00:00
|
|
|
local speed = mp.get_property_number("cache-speed", 0)
|
|
|
|
if speed > 0 then
|
|
|
|
append(s, utils.format_bytes_humanized(speed) .. "/s", {prefix="Speed:", nl="",
|
|
|
|
indent=o.prefix_sep, no_prefix_markup=true})
|
|
|
|
end
|
2016-07-12 17:19:34 +00:00
|
|
|
end
|
2015-04-28 00:13:27 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
2016-07-12 17:19:34 +00:00
|
|
|
local function add_video(s)
|
2018-03-24 21:36:01 +00:00
|
|
|
local r = mp.get_property_native("video-params")
|
|
|
|
-- in case of e.g. lavi-complex there can be no input video, only output
|
|
|
|
if not r then
|
|
|
|
r = mp.get_property_native("video-out-params")
|
|
|
|
end
|
|
|
|
if not r then
|
2016-07-12 17:19:34 +00:00
|
|
|
return
|
|
|
|
end
|
|
|
|
|
2018-03-24 21:43:04 +00:00
|
|
|
append(s, "", {prefix=o.nl .. o.nl .. "Video:", nl="", indent=""})
|
|
|
|
if append_property(s, "video-codec", {prefix_sep="", nl="", indent=""}) then
|
2017-09-23 15:54:40 +00:00
|
|
|
append_property(s, "hwdec-current", {prefix="(hwdec:", nl="", indent=" ",
|
|
|
|
no_prefix_markup=true, suffix=")"}, {no=true, [""]=true})
|
2016-07-12 17:19:34 +00:00
|
|
|
end
|
|
|
|
append_property(s, "avsync", {prefix="A-V:"})
|
2017-09-23 15:54:40 +00:00
|
|
|
if append_property(s, compat("decoder-frame-drop-count"),
|
|
|
|
{prefix="Dropped Frames:", suffix=" (decoder)"}) then
|
2017-08-12 12:08:35 +00:00
|
|
|
append_property(s, compat("frame-drop-count"), {suffix=" (output)", nl="", indent=""})
|
2016-07-12 17:19:34 +00:00
|
|
|
end
|
|
|
|
if append_property(s, "display-fps", {prefix="Display FPS:", suffix=" (specified)"}) then
|
|
|
|
append_property(s, "estimated-display-fps",
|
|
|
|
{suffix=" (estimated)", nl="", indent=""})
|
|
|
|
else
|
|
|
|
append_property(s, "estimated-display-fps",
|
|
|
|
{prefix="Display FPS:", suffix=" (estimated)"})
|
|
|
|
end
|
2017-06-16 10:38:41 +00:00
|
|
|
if append_property(s, compat("container-fps"), {prefix="FPS:", suffix=" (specified)"}) then
|
2016-07-12 17:19:34 +00:00
|
|
|
append_property(s, "estimated-vf-fps",
|
|
|
|
{suffix=" (estimated)", nl="", indent=""})
|
|
|
|
else
|
|
|
|
append_property(s, "estimated-vf-fps",
|
|
|
|
{prefix="FPS:", suffix=" (estimated)"})
|
|
|
|
end
|
|
|
|
|
2016-09-12 00:30:09 +00:00
|
|
|
append_display_sync(s)
|
2017-06-30 19:46:16 +00:00
|
|
|
append_perfdata(s, o.print_perfdata_passes)
|
2016-07-12 17:19:34 +00:00
|
|
|
|
2018-03-24 21:36:01 +00:00
|
|
|
if append(s, r["w"], {prefix="Native Resolution:"}) then
|
|
|
|
append(s, r["h"], {prefix="x", nl="", indent=" ", prefix_sep=" ", no_prefix_markup=true})
|
2016-07-12 17:19:34 +00:00
|
|
|
end
|
|
|
|
append_property(s, "window-scale", {prefix="Window Scale:"})
|
2018-03-24 21:36:01 +00:00
|
|
|
append(s, format("%.2f", r["aspect"]), {prefix="Aspect Ratio:"})
|
|
|
|
append(s, r["pixelformat"], {prefix="Pixel Format:"})
|
2016-07-13 09:29:31 +00:00
|
|
|
|
|
|
|
-- Group these together to save vertical space
|
2018-03-24 21:36:01 +00:00
|
|
|
local prim = append(s, r["primaries"], {prefix="Primaries:"})
|
|
|
|
local cmat = append(s, r["colormatrix"], {prefix="Colormatrix:", nl=prim and "" or o.nl})
|
|
|
|
append(s, r["colorlevels"], {prefix="Levels:", nl=cmat and "" or o.nl})
|
2016-07-13 09:29:31 +00:00
|
|
|
|
|
|
|
-- Append HDR metadata conditionally (only when present and interesting)
|
2018-03-24 21:36:01 +00:00
|
|
|
local hdrpeak = r["sig-peak"] or 0
|
2016-07-13 09:29:31 +00:00
|
|
|
local hdrinfo = ""
|
2017-06-18 19:04:20 +00:00
|
|
|
if hdrpeak > 1 then
|
2018-03-24 21:36:01 +00:00
|
|
|
hdrinfo = " (HDR peak: " .. format("%.2f", hdrpeak) .. ")"
|
2016-07-13 09:29:31 +00:00
|
|
|
end
|
|
|
|
|
2018-03-24 21:36:01 +00:00
|
|
|
append(s, r["gamma"], {prefix="Gamma:", suffix=hdrinfo})
|
2016-07-12 17:19:34 +00:00
|
|
|
append_property(s, "packet-video-bitrate", {prefix="Bitrate:", suffix=" kbps"})
|
2017-07-25 13:37:09 +00:00
|
|
|
append_filters(s, "vf", "Filters:")
|
2015-04-03 15:22:32 +00:00
|
|
|
end
|
2015-04-28 00:13:27 +00:00
|
|
|
|
|
|
|
|
2016-07-12 17:19:34 +00:00
|
|
|
local function add_audio(s)
|
2018-03-24 21:36:01 +00:00
|
|
|
local r = mp.get_property_native("audio-params")
|
|
|
|
-- in case of e.g. lavi-complex there can be no input audio, only output
|
|
|
|
if not r then
|
|
|
|
r = mp.get_property_native("audio-out-params")
|
|
|
|
end
|
|
|
|
if not r then
|
2016-07-12 17:19:34 +00:00
|
|
|
return
|
|
|
|
end
|
|
|
|
|
2018-03-24 21:43:04 +00:00
|
|
|
append(s, "", {prefix=o.nl .. o.nl .. "Audio:", nl="", indent=""})
|
|
|
|
append_property(s, "audio-codec", {prefix_sep="", nl="", indent=""})
|
2019-01-13 12:34:15 +00:00
|
|
|
local cc = append(s, r["channel-count"], {prefix="Channels:"})
|
|
|
|
append(s, r["format"], {prefix="Format:", nl=cc and "" or o.nl})
|
2018-03-24 21:36:01 +00:00
|
|
|
append(s, r["samplerate"], {prefix="Sample Rate:", suffix=" Hz"})
|
2016-07-12 17:19:34 +00:00
|
|
|
append_property(s, "packet-audio-bitrate", {prefix="Bitrate:", suffix=" kbps"})
|
2017-07-25 13:37:09 +00:00
|
|
|
append_filters(s, "af", "Filters:")
|
2015-04-03 15:22:32 +00:00
|
|
|
end
|
2015-04-28 00:13:27 +00:00
|
|
|
|
2016-07-08 08:53:02 +00:00
|
|
|
|
2017-09-23 15:54:40 +00:00
|
|
|
-- Determine whether ASS formatting shall/can be used and set formatting sequences
|
stats: support for multiple "pages" of stats
Please note that the latest version of this script needs a very recent
version of mpv (from yesterday, to be precise, see the readme).
For older versions, please go to "releases".
HOW IT WORKS:
While the stats are visible (i.e. text is printed to the OSD) a
subsequent click on a numeric key (1, 2, ...) will display the
corresponding "page".
This works no matter if the stats are toggled or just shown as a single
invocation. In case of a single invocation, the newly displayed page
will be shown for the full duration again.
The selected page will be remembered (not persistantly though).
So far, only 3 pages are available.
1: the default page, stats as they used to be
2: extensive VO performance stats (to be redesigned/changed soon)
3: dummy
In the future, many more pages are possible.
Implementation is likely to change again (functionality will stay
the same). A new timer had to be introduced to remove the forced
keybindings in the oneshot case. The toggle case can remove them without
a timer. Ensuring that each mode won't remove timers of the other mode
didn't really turn out neat.
Therefore, I intend to change this again, maybe by merging the
oneshot case into the toggle case.
2017-07-02 01:00:49 +00:00
|
|
|
local function eval_ass_formatting()
|
2017-07-04 22:31:44 +00:00
|
|
|
o.use_ass = o.ass_formatting and has_vo_window()
|
|
|
|
if o.use_ass then
|
|
|
|
o.nl = o.ass_nl
|
|
|
|
o.indent = o.ass_indent
|
|
|
|
o.prefix_sep = o.ass_prefix_sep
|
|
|
|
o.b1 = o.ass_b1
|
|
|
|
o.b0 = o.ass_b0
|
2017-07-25 13:37:09 +00:00
|
|
|
o.it1 = o.ass_it1
|
|
|
|
o.it0 = o.ass_it0
|
2017-07-04 22:31:44 +00:00
|
|
|
else
|
2016-07-12 17:19:34 +00:00
|
|
|
o.nl = o.no_ass_nl
|
|
|
|
o.indent = o.no_ass_indent
|
|
|
|
o.prefix_sep = o.no_ass_prefix_sep
|
|
|
|
if not has_ansi() then
|
|
|
|
o.b1 = ""
|
|
|
|
o.b0 = ""
|
2017-07-25 13:37:09 +00:00
|
|
|
o.it1 = ""
|
|
|
|
o.it0 = ""
|
2016-07-12 17:19:34 +00:00
|
|
|
else
|
|
|
|
o.b1 = o.no_ass_b1
|
|
|
|
o.b0 = o.no_ass_b0
|
2017-07-25 13:37:09 +00:00
|
|
|
o.it1 = o.no_ass_it1
|
|
|
|
o.it0 = o.no_ass_it0
|
2016-07-12 17:19:34 +00:00
|
|
|
end
|
2015-07-21 19:53:23 +00:00
|
|
|
end
|
stats: support for multiple "pages" of stats
Please note that the latest version of this script needs a very recent
version of mpv (from yesterday, to be precise, see the readme).
For older versions, please go to "releases".
HOW IT WORKS:
While the stats are visible (i.e. text is printed to the OSD) a
subsequent click on a numeric key (1, 2, ...) will display the
corresponding "page".
This works no matter if the stats are toggled or just shown as a single
invocation. In case of a single invocation, the newly displayed page
will be shown for the full duration again.
The selected page will be remembered (not persistantly though).
So far, only 3 pages are available.
1: the default page, stats as they used to be
2: extensive VO performance stats (to be redesigned/changed soon)
3: dummy
In the future, many more pages are possible.
Implementation is likely to change again (functionality will stay
the same). A new timer had to be introduced to remove the forced
keybindings in the oneshot case. The toggle case can remove them without
a timer. Ensuring that each mode won't remove timers of the other mode
didn't really turn out neat.
Therefore, I intend to change this again, maybe by merging the
oneshot case into the toggle case.
2017-07-02 01:00:49 +00:00
|
|
|
end
|
2016-07-12 17:19:34 +00:00
|
|
|
|
stats: support for multiple "pages" of stats
Please note that the latest version of this script needs a very recent
version of mpv (from yesterday, to be precise, see the readme).
For older versions, please go to "releases".
HOW IT WORKS:
While the stats are visible (i.e. text is printed to the OSD) a
subsequent click on a numeric key (1, 2, ...) will display the
corresponding "page".
This works no matter if the stats are toggled or just shown as a single
invocation. In case of a single invocation, the newly displayed page
will be shown for the full duration again.
The selected page will be remembered (not persistantly though).
So far, only 3 pages are available.
1: the default page, stats as they used to be
2: extensive VO performance stats (to be redesigned/changed soon)
3: dummy
In the future, many more pages are possible.
Implementation is likely to change again (functionality will stay
the same). A new timer had to be introduced to remove the forced
keybindings in the oneshot case. The toggle case can remove them without
a timer. Ensuring that each mode won't remove timers of the other mode
didn't really turn out neat.
Therefore, I intend to change this again, maybe by merging the
oneshot case into the toggle case.
2017-07-02 01:00:49 +00:00
|
|
|
|
|
|
|
-- Returns an ASS string with "normal" stats
|
|
|
|
local function default_stats()
|
2017-07-02 21:24:51 +00:00
|
|
|
local stats = {}
|
stats: support for multiple "pages" of stats
Please note that the latest version of this script needs a very recent
version of mpv (from yesterday, to be precise, see the readme).
For older versions, please go to "releases".
HOW IT WORKS:
While the stats are visible (i.e. text is printed to the OSD) a
subsequent click on a numeric key (1, 2, ...) will display the
corresponding "page".
This works no matter if the stats are toggled or just shown as a single
invocation. In case of a single invocation, the newly displayed page
will be shown for the full duration again.
The selected page will be remembered (not persistantly though).
So far, only 3 pages are available.
1: the default page, stats as they used to be
2: extensive VO performance stats (to be redesigned/changed soon)
3: dummy
In the future, many more pages are possible.
Implementation is likely to change again (functionality will stay
the same). A new timer had to be introduced to remove the forced
keybindings in the oneshot case. The toggle case can remove them without
a timer. Ensuring that each mode won't remove timers of the other mode
didn't really turn out neat.
Therefore, I intend to change this again, maybe by merging the
oneshot case into the toggle case.
2017-07-02 01:00:49 +00:00
|
|
|
eval_ass_formatting()
|
2017-07-02 21:24:51 +00:00
|
|
|
add_header(stats)
|
|
|
|
add_file(stats)
|
|
|
|
add_video(stats)
|
|
|
|
add_audio(stats)
|
|
|
|
return table.concat(stats)
|
stats: support for multiple "pages" of stats
Please note that the latest version of this script needs a very recent
version of mpv (from yesterday, to be precise, see the readme).
For older versions, please go to "releases".
HOW IT WORKS:
While the stats are visible (i.e. text is printed to the OSD) a
subsequent click on a numeric key (1, 2, ...) will display the
corresponding "page".
This works no matter if the stats are toggled or just shown as a single
invocation. In case of a single invocation, the newly displayed page
will be shown for the full duration again.
The selected page will be remembered (not persistantly though).
So far, only 3 pages are available.
1: the default page, stats as they used to be
2: extensive VO performance stats (to be redesigned/changed soon)
3: dummy
In the future, many more pages are possible.
Implementation is likely to change again (functionality will stay
the same). A new timer had to be introduced to remove the forced
keybindings in the oneshot case. The toggle case can remove them without
a timer. Ensuring that each mode won't remove timers of the other mode
didn't really turn out neat.
Therefore, I intend to change this again, maybe by merging the
oneshot case into the toggle case.
2017-07-02 01:00:49 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
-- Returns an ASS string with extended VO stats
|
|
|
|
local function vo_stats()
|
|
|
|
local stats = {}
|
|
|
|
eval_ass_formatting()
|
|
|
|
add_header(stats)
|
|
|
|
append_perfdata(stats, true)
|
|
|
|
return table.concat(stats)
|
|
|
|
end
|
|
|
|
|
2019-06-14 18:14:42 +00:00
|
|
|
local function opt_time(t)
|
|
|
|
if type(t) == type(1.1) then
|
|
|
|
return mp.format_time(t)
|
|
|
|
end
|
|
|
|
return "?"
|
|
|
|
end
|
|
|
|
|
|
|
|
-- Returns an ASS string with stats about the demuxer cache etc.
|
|
|
|
local function cache_stats()
|
|
|
|
local stats = {}
|
|
|
|
|
|
|
|
add_header(stats)
|
|
|
|
append(stats, "", {prefix=o.nl .. o.nl .. "Cache info:", nl="", indent=""})
|
|
|
|
|
|
|
|
local info = mp.get_property_native("demuxer-cache-state")
|
|
|
|
if info == nil then
|
|
|
|
append(stats, "Unavailable.", {})
|
|
|
|
return table.concat(stats)
|
|
|
|
end
|
|
|
|
|
2019-06-22 22:30:56 +00:00
|
|
|
local a = info["reader-pts"]
|
|
|
|
local b = info["cache-end"]
|
|
|
|
|
|
|
|
append(stats, opt_time(a) .. " - " .. opt_time(b), {prefix = "Packet queue:"})
|
|
|
|
|
|
|
|
local r = nil
|
|
|
|
if (a ~= nil) and (b ~= nil) then
|
|
|
|
r = b - a
|
|
|
|
end
|
|
|
|
|
|
|
|
local r_graph = nil
|
|
|
|
if not display_timer.oneshot and o.use_ass then
|
|
|
|
r_graph = generate_graph(cache_ahead_buf, cache_ahead_buf.pos,
|
|
|
|
cache_ahead_buf.len, cache_ahead_buf.max,
|
|
|
|
nil, 0.8, 1)
|
|
|
|
r_graph = o.prefix_sep .. r_graph
|
|
|
|
end
|
|
|
|
append(stats, opt_time(r), {prefix = "Read-ahead:", suffix = r_graph})
|
2019-06-14 18:14:42 +00:00
|
|
|
|
|
|
|
-- These states are not necessarily exclusive. They're about potentially
|
|
|
|
-- separate mechanisms, whose states may be decoupled.
|
|
|
|
local state = "reading"
|
|
|
|
local seek_ts = info["debug-seeking"]
|
|
|
|
if seek_ts ~= nil then
|
|
|
|
state = "seeking (to " .. mp.format_time(seek_ts) .. ")"
|
|
|
|
elseif info["eof"] == true then
|
|
|
|
state = "eof"
|
|
|
|
elseif info["underrun"] then
|
|
|
|
state = "underrun"
|
|
|
|
elseif info["idle"] == true then
|
|
|
|
state = "inactive"
|
|
|
|
end
|
|
|
|
append(stats, state, {prefix = "State:"})
|
|
|
|
|
2019-06-22 22:30:56 +00:00
|
|
|
local total_graph = nil
|
|
|
|
if not display_timer.oneshot and o.use_ass then
|
|
|
|
total_graph = generate_graph(cache_total_buf, cache_total_buf.pos,
|
|
|
|
cache_total_buf.len, cache_total_buf.max,
|
|
|
|
nil, 0.8, 1)
|
|
|
|
total_graph = o.prefix_sep .. total_graph
|
|
|
|
end
|
2019-06-14 18:14:42 +00:00
|
|
|
append(stats, utils.format_bytes_humanized(info["total-bytes"]),
|
2019-06-22 22:30:56 +00:00
|
|
|
{prefix = "Total RAM:", suffix = total_graph})
|
2019-06-14 18:14:42 +00:00
|
|
|
append(stats, utils.format_bytes_humanized(info["fw-bytes"]),
|
|
|
|
{prefix = "Forward RAM:"})
|
|
|
|
|
|
|
|
local fc = info["file-cache-bytes"]
|
|
|
|
if fc ~= nil then
|
|
|
|
fc = utils.format_bytes_humanized(fc)
|
|
|
|
else
|
|
|
|
fc = "(disabled)"
|
|
|
|
end
|
|
|
|
append(stats, fc, {prefix = "Disk cache:"})
|
|
|
|
|
|
|
|
append(stats, info["debug-low-level-seeks"], {prefix = "Media seeks:"})
|
|
|
|
|
|
|
|
append(stats, "", {prefix=o.nl .. o.nl .. "Ranges:", nl="", indent=""})
|
|
|
|
|
|
|
|
append(stats, info["bof-cached"] and "yes" or "no",
|
|
|
|
{prefix = "Start cached:"})
|
|
|
|
append(stats, info["eof-cached"] and "yes" or "no",
|
|
|
|
{prefix = "End cached:"})
|
stats: support for multiple "pages" of stats
Please note that the latest version of this script needs a very recent
version of mpv (from yesterday, to be precise, see the readme).
For older versions, please go to "releases".
HOW IT WORKS:
While the stats are visible (i.e. text is printed to the OSD) a
subsequent click on a numeric key (1, 2, ...) will display the
corresponding "page".
This works no matter if the stats are toggled or just shown as a single
invocation. In case of a single invocation, the newly displayed page
will be shown for the full duration again.
The selected page will be remembered (not persistantly though).
So far, only 3 pages are available.
1: the default page, stats as they used to be
2: extensive VO performance stats (to be redesigned/changed soon)
3: dummy
In the future, many more pages are possible.
Implementation is likely to change again (functionality will stay
the same). A new timer had to be introduced to remove the forced
keybindings in the oneshot case. The toggle case can remove them without
a timer. Ensuring that each mode won't remove timers of the other mode
didn't really turn out neat.
Therefore, I intend to change this again, maybe by merging the
oneshot case into the toggle case.
2017-07-02 01:00:49 +00:00
|
|
|
|
2019-06-14 18:14:42 +00:00
|
|
|
local ranges = info["seekable-ranges"] or {}
|
|
|
|
for n, r in ipairs(ranges) do
|
|
|
|
append(stats, mp.format_time(r["start"]) .. " - " ..
|
|
|
|
mp.format_time(r["end"]),
|
|
|
|
{prefix = format("Range %s:", n)})
|
|
|
|
end
|
|
|
|
|
|
|
|
return table.concat(stats)
|
2015-07-21 19:53:23 +00:00
|
|
|
end
|
2015-04-28 00:13:27 +00:00
|
|
|
|
2019-06-22 22:30:56 +00:00
|
|
|
local function graph_add_value(graph, value)
|
|
|
|
graph.pos = (graph.pos % graph.len) + 1
|
|
|
|
graph[graph.pos] = value
|
|
|
|
graph.max = max(graph.max, value)
|
|
|
|
end
|
|
|
|
|
|
|
|
-- Record 1 sample of cache statistics.
|
|
|
|
-- (Unlike record_data(), this does not return a function, but runs directly.)
|
|
|
|
local function record_cache_stats()
|
|
|
|
local info = mp.get_property_native("demuxer-cache-state")
|
|
|
|
if info == nil then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
local a = info["reader-pts"]
|
|
|
|
local b = info["cache-end"]
|
|
|
|
if (a ~= nil) and (b ~= nil) then
|
|
|
|
graph_add_value(cache_ahead_buf, b - a)
|
|
|
|
end
|
|
|
|
|
|
|
|
graph_add_value(cache_total_buf, info["total-bytes"])
|
|
|
|
end
|
|
|
|
|
|
|
|
cache_recorder_timer = mp.add_periodic_timer(0.25, record_cache_stats)
|
|
|
|
cache_recorder_timer:kill()
|
2016-07-08 08:53:02 +00:00
|
|
|
|
2017-09-23 15:54:40 +00:00
|
|
|
-- Current page and <page key>:<page function> mapping
|
|
|
|
curr_page = o.key_page_1
|
|
|
|
pages = {
|
|
|
|
[o.key_page_1] = { f = default_stats, desc = "Default" },
|
|
|
|
[o.key_page_2] = { f = vo_stats, desc = "Extended Frame Timings" },
|
2019-06-14 18:14:42 +00:00
|
|
|
[o.key_page_3] = { f = cache_stats, desc = "Cache Statistics" },
|
2017-09-23 15:54:40 +00:00
|
|
|
}
|
stats: support for multiple "pages" of stats
Please note that the latest version of this script needs a very recent
version of mpv (from yesterday, to be precise, see the readme).
For older versions, please go to "releases".
HOW IT WORKS:
While the stats are visible (i.e. text is printed to the OSD) a
subsequent click on a numeric key (1, 2, ...) will display the
corresponding "page".
This works no matter if the stats are toggled or just shown as a single
invocation. In case of a single invocation, the newly displayed page
will be shown for the full duration again.
The selected page will be remembered (not persistantly though).
So far, only 3 pages are available.
1: the default page, stats as they used to be
2: extensive VO performance stats (to be redesigned/changed soon)
3: dummy
In the future, many more pages are possible.
Implementation is likely to change again (functionality will stay
the same). A new timer had to be introduced to remove the forced
keybindings in the oneshot case. The toggle case can remove them without
a timer. Ensuring that each mode won't remove timers of the other mode
didn't really turn out neat.
Therefore, I intend to change this again, maybe by merging the
oneshot case into the toggle case.
2017-07-02 01:00:49 +00:00
|
|
|
|
|
|
|
|
|
|
|
-- Returns a function to record vsratio/jitter with the specified `skip` value
|
2016-09-12 00:30:09 +00:00
|
|
|
local function record_data(skip)
|
|
|
|
init_buffers()
|
|
|
|
skip = max(skip, 0)
|
2016-07-12 17:19:34 +00:00
|
|
|
local i = skip
|
|
|
|
return function()
|
|
|
|
if i < skip then
|
|
|
|
i = i + 1
|
|
|
|
return
|
|
|
|
else
|
|
|
|
i = 0
|
|
|
|
end
|
|
|
|
|
2016-09-12 00:30:09 +00:00
|
|
|
if o.plot_vsync_jitter then
|
|
|
|
local r = mp.get_property_number("vsync-jitter", nil)
|
|
|
|
if r then
|
|
|
|
vsjitter_buf.pos = (vsjitter_buf.pos % vsjitter_buf.len) + 1
|
|
|
|
vsjitter_buf[vsjitter_buf.pos] = r
|
|
|
|
vsjitter_buf.max = max(vsjitter_buf.max, r)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
if o.plot_vsync_ratio then
|
|
|
|
local r = mp.get_property_number("vsync-ratio", nil)
|
|
|
|
if r then
|
|
|
|
vsratio_buf.pos = (vsratio_buf.pos % vsratio_buf.len) + 1
|
|
|
|
vsratio_buf[vsratio_buf.pos] = r
|
|
|
|
vsratio_buf.max = max(vsratio_buf.max, r)
|
|
|
|
end
|
2016-07-12 17:19:34 +00:00
|
|
|
end
|
|
|
|
end
|
2015-04-03 15:22:32 +00:00
|
|
|
end
|
|
|
|
|
2017-09-23 15:54:40 +00:00
|
|
|
-- Call the function for `page` and print it to OSD
|
|
|
|
local function print_page(page)
|
|
|
|
if o.persistent_overlay then
|
|
|
|
mp.set_osd_ass(0, 0, pages[page].f())
|
2016-05-17 20:23:11 +00:00
|
|
|
else
|
2017-09-23 15:54:40 +00:00
|
|
|
mp.osd_message(pages[page].f(), display_timer.oneshot and o.duration or o.redraw_delay + 1)
|
2016-05-17 20:23:11 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2017-09-23 15:54:40 +00:00
|
|
|
local function clear_screen()
|
|
|
|
if o.persistent_overlay then mp.set_osd_ass(0, 0, "") else mp.osd_message("", 0) end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
-- Add keybindings for every page
|
|
|
|
local function add_page_bindings()
|
|
|
|
local function a(k)
|
|
|
|
return function()
|
|
|
|
curr_page = k
|
|
|
|
print_page(k)
|
|
|
|
if display_timer.oneshot then display_timer:kill() ; display_timer:resume() end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
for k, _ in pairs(pages) do
|
|
|
|
mp.add_forced_key_binding(k, k, a(k), {repeatable=true})
|
2017-07-02 11:23:23 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2017-09-23 15:54:40 +00:00
|
|
|
-- Remove keybindings for every page
|
|
|
|
local function remove_page_bindings()
|
|
|
|
for k, _ in pairs(pages) do
|
|
|
|
mp.remove_key_binding(k)
|
|
|
|
end
|
|
|
|
end
|
stats: support for multiple "pages" of stats
Please note that the latest version of this script needs a very recent
version of mpv (from yesterday, to be precise, see the readme).
For older versions, please go to "releases".
HOW IT WORKS:
While the stats are visible (i.e. text is printed to the OSD) a
subsequent click on a numeric key (1, 2, ...) will display the
corresponding "page".
This works no matter if the stats are toggled or just shown as a single
invocation. In case of a single invocation, the newly displayed page
will be shown for the full duration again.
The selected page will be remembered (not persistantly though).
So far, only 3 pages are available.
1: the default page, stats as they used to be
2: extensive VO performance stats (to be redesigned/changed soon)
3: dummy
In the future, many more pages are possible.
Implementation is likely to change again (functionality will stay
the same). A new timer had to be introduced to remove the forced
keybindings in the oneshot case. The toggle case can remove them without
a timer. Ensuring that each mode won't remove timers of the other mode
didn't really turn out neat.
Therefore, I intend to change this again, maybe by merging the
oneshot case into the toggle case.
2017-07-02 01:00:49 +00:00
|
|
|
|
|
|
|
|
2017-09-23 15:54:40 +00:00
|
|
|
local function process_key_binding(oneshot)
|
|
|
|
-- Stats are already being displayed
|
|
|
|
if display_timer:is_enabled() then
|
|
|
|
-- Previous and current keys were oneshot -> restart timer
|
|
|
|
if display_timer.oneshot and oneshot then
|
|
|
|
display_timer:kill()
|
|
|
|
print_page(curr_page)
|
|
|
|
display_timer:resume()
|
|
|
|
-- Previous and current keys were toggling -> end toggling
|
|
|
|
elseif not display_timer.oneshot and not oneshot then
|
|
|
|
display_timer:kill()
|
2019-06-22 22:30:56 +00:00
|
|
|
cache_recorder_timer:stop()
|
2017-09-23 15:54:40 +00:00
|
|
|
clear_screen()
|
|
|
|
remove_page_bindings()
|
|
|
|
if recorder then
|
|
|
|
mp.unregister_event(recorder)
|
|
|
|
recorder = nil
|
|
|
|
end
|
|
|
|
end
|
|
|
|
-- No stats are being displayed yet
|
|
|
|
else
|
|
|
|
if not oneshot and (o.plot_vsync_jitter or o.plot_vsync_ratio) then
|
|
|
|
recorder = record_data(o.skip_frames)
|
|
|
|
mp.register_event("tick", recorder)
|
2019-06-22 22:30:56 +00:00
|
|
|
cache_recorder_timer:resume()
|
2017-09-23 15:54:40 +00:00
|
|
|
end
|
|
|
|
display_timer:kill()
|
|
|
|
display_timer.oneshot = oneshot
|
|
|
|
display_timer.timeout = oneshot and o.duration or o.redraw_delay
|
|
|
|
add_page_bindings()
|
|
|
|
print_page(curr_page)
|
|
|
|
display_timer:resume()
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
stats: support for multiple "pages" of stats
Please note that the latest version of this script needs a very recent
version of mpv (from yesterday, to be precise, see the readme).
For older versions, please go to "releases".
HOW IT WORKS:
While the stats are visible (i.e. text is printed to the OSD) a
subsequent click on a numeric key (1, 2, ...) will display the
corresponding "page".
This works no matter if the stats are toggled or just shown as a single
invocation. In case of a single invocation, the newly displayed page
will be shown for the full duration again.
The selected page will be remembered (not persistantly though).
So far, only 3 pages are available.
1: the default page, stats as they used to be
2: extensive VO performance stats (to be redesigned/changed soon)
3: dummy
In the future, many more pages are possible.
Implementation is likely to change again (functionality will stay
the same). A new timer had to be introduced to remove the forced
keybindings in the oneshot case. The toggle case can remove them without
a timer. Ensuring that each mode won't remove timers of the other mode
didn't really turn out neat.
Therefore, I intend to change this again, maybe by merging the
oneshot case into the toggle case.
2017-07-02 01:00:49 +00:00
|
|
|
|
2017-09-23 15:54:40 +00:00
|
|
|
-- Create the timer used for redrawing (toggling) or clearing the screen (oneshot)
|
|
|
|
-- The duration here is not important and always set in process_key_binding()
|
|
|
|
display_timer = mp.add_periodic_timer(o.duration,
|
2017-07-02 11:53:32 +00:00
|
|
|
function()
|
2017-09-23 15:54:40 +00:00
|
|
|
if display_timer.oneshot then
|
|
|
|
display_timer:kill() ; clear_screen() ; remove_page_bindings()
|
|
|
|
else
|
|
|
|
print_page(curr_page)
|
2017-07-02 11:53:32 +00:00
|
|
|
end
|
|
|
|
end)
|
2017-09-23 15:54:40 +00:00
|
|
|
display_timer:kill()
|
2016-07-12 17:19:34 +00:00
|
|
|
|
2016-07-08 08:53:02 +00:00
|
|
|
-- Single invocation key binding
|
2017-09-23 15:54:40 +00:00
|
|
|
mp.add_key_binding(o.key_oneshot, "display-stats", function() process_key_binding(true) end,
|
|
|
|
{repeatable=true})
|
|
|
|
|
|
|
|
-- Toggling key binding
|
|
|
|
mp.add_key_binding(o.key_toggle, "display-stats-toggle", function() process_key_binding(false) end,
|
|
|
|
{repeatable=false})
|
2017-07-02 11:23:23 +00:00
|
|
|
|
|
|
|
-- Single invocation bindings without key, can be used in input.conf to create
|
|
|
|
-- bindings for a specific page: "e script-binding stats/display-page-2"
|
|
|
|
for k, _ in pairs(pages) do
|
2017-09-23 15:54:40 +00:00
|
|
|
mp.add_key_binding(nil, "display-page-" .. k, function() process_key_binding(true) end,
|
|
|
|
{repeatable=true})
|
2017-07-02 11:23:23 +00:00
|
|
|
end
|
2016-07-08 08:53:02 +00:00
|
|
|
|
2017-07-02 11:23:23 +00:00
|
|
|
-- Reprint stats immediately when VO was reconfigured, only when toggled
|
2016-07-08 08:53:02 +00:00
|
|
|
mp.register_event("video-reconfig",
|
2017-09-23 15:54:40 +00:00
|
|
|
function()
|
|
|
|
if display_timer:is_enabled() then
|
|
|
|
print_page(curr_page)
|
|
|
|
end
|
|
|
|
end)
|