Commit Graph

245 Commits

Author SHA1 Message Date
Kacper Michajłow d3ec15bca8 stats.lua: remove prefix from display luminance metadata
People are getting confused about "HDR10" part.
2025-10-31 12:53:43 +01:00
Kacper Michajłow 0fb40b654d stats.lua: split lines to make them shorter
Fixes: 92aeb63479
2025-10-10 06:14:42 +02:00
Kacper Michajłow 43b230b089 stats.lua: skip codec params if they are not available
Fixes: 2fd88ffbae
2025-10-10 06:14:42 +02:00
llyyr 92aeb63479 stats.lua: make video block even when no video track
fixes formatting with `mpv --idle --force-window` with no files loaded
2025-10-10 05:41:56 +02:00
Kacper Michajłow 0e966ba071 stats.lua: show also min_luma if max_luma is nominal SDR
Useful to see set black point.
2025-08-24 01:21:35 +02:00
Kacper Michajłow 01b7edcc71 stats.lua: round max-cll to integer
In source-dynamic mode this can be converted from PQ, round it to
integer, same as max-luma already is.
2025-08-09 20:42:17 +02:00
Kacper Michajłow 5b1df3c5d9 command: add video-params/prim-* properies
Available if raw primaries differ than named primaries value.
2025-07-11 21:53:58 +02:00
nanahi 18defc8530 stats.lua: fix append_property exclusions
f676a9ff20 changed some append_property
calls to append, but append does not support the exclusion feature
which results in "HW: no" shown when no hwdec is active when this
was not displayed before.

Fix this by adding option to append_property to use get_property_cached.

Fixes: f676a9ff20
2025-06-20 16:13:14 +02:00
Kacper Michajłow bff0d59cbe stats.lua: set plot_{perfdata,vsync_ratio,vsync_jitter} to no
Disables perf graphs from stats.lua. They are relatively expensive to
render, causes a lot of memory to be used for caches which are never
reused because graph is rarely the same. And most importantly those
graphs are not that useful beyond quick visual inspection of jitter.

Can be enable in script-opt if needed. Cache graph is left enabled,
because it shows if cache readhead grows or not nicely.
2025-04-16 23:58:46 +02:00
Kacper Michajłow fd1007260c stats.lua: add stats-plot_cache script-opt
Allows to disable cache graphs on page 3 of stats.lua.

Fixes: #13894
2025-04-16 23:58:46 +02:00
nanahi f676a9ff20 stats.lua: cache some properties
Some properties can take a long time to query, especially those which
require voctrl like current-window-scale and display-names.

Similar to d37521b5ef, make the script
observe these properties and cache the values to avoid querying them
on every refresh. This alleviates the issue when holding down "i" key
for a while and releasing it results in stats being stuck on display
for a long time because of the time required to query there properties.
2025-03-26 01:30:46 +01:00
SeaHOH 5459b0ff19 stats.lua: use fixed naming for single invocation key bindings
The names of single invocation key bindings for specific pages will be
changed if defines user key bindings, then original invocation fails.

e.g. : when user defines `key_page_4=F4`, then key binding name
`stats/display-page-4-toggle`
becomes
`stats/display-page-F4-toggle`,
and OSC menu `Help` fails.
2025-02-25 08:49:35 +01:00
SeaHOH 883b94841a stats.lua: change key bindings of toggle page as nonrepeatable
Be consistent with behavior of `display-stats-toggle`.
2025-02-25 08:49:35 +01:00
Guido Cella 996c098725 console.lua: add a keep_open flag to mp.input
With input.select this allows building nested submenus without the
flicker of console quickly closing and reopening, and also doing
multiple selections, to e.g. cycle through different values of a
property, or increase a property multiple times.

With input.get this is used to change the default behavior to closing by
default on submit. It was argued by avih that this is more useful, and
indeed Github code search shows that everybody is calling
input.terminate() unconditionally on submit, so the impact of the change
should be low, and restoring the old behavior is as easy as passing
keep_open = true, which is just ignored in older mpv versions.
2025-02-24 16:26:58 +01:00
Guido Cella 996e58a738 stats.lua: only reprint stats on video-reconfig when toggled
Make this behave like the comment says it should, because currently when
you show oneshot stats and change file, stats are printed again and hide
--osd-playing-msg. This happens even if you hide the stats by
show-texting something else and change file before the timer expires.
2025-01-05 00:52:49 +01:00
Guido Cella 0d9763872c stats.lua: fix page 2 and 0 layout
Fixes d84e1b3582.
2025-01-04 20:45:31 +01:00
Guido Cella d84e1b3582 stats.lua: inherit --osd-shadow-offset
Unlike font and border sizes, the default stats shadow offset is 0 like
--osd-shadow-offset, so it can be inherited from it by default to not
make users configure it in 2 places.

Since 0 and negative numbers are valid offsets, use infinity as the
placeholder for unconfigured values.
2025-01-04 20:07:49 +01:00
Guido Cella 38c46e4d89 stats.lua: enable runtime script-opt changes
This doesn't work for changing page key script-opts at runtime because
they are used as the indexes of the pages variable, but nothing actually
breaks if you do, it just uses the initial values. This is still useful
for conditionally changing sizes at runtime or for trying out the
osd-box profile by applying it from the console.
2024-12-20 14:54:20 +00:00
Kacper Michajłow a0d7265ce9 sub/osd/console/stats: use the same 1.65 outline size 2024-11-18 09:50:22 +01:00
Kacper Michajłow fedd34e83c stats.lua: set border size to have similar relative thickness as OSD
It is 6% of font size. Little bit more relativelly to OSD, but stats has
smaller text, so we need to compensate for that.
2024-11-18 09:50:22 +01:00
Guido Cella 3986f34e2a stats.lua: calculate sizes like --osd-*-size options
Currently --script-opt=stats-font_size=n is much bigger than
--osd-font-size=n, which can confuse users, so calculate sizes the same
way.

The \fs value to replicate --osd-font-size is
${osd-font-size} * 288 / 720 with --osd-scale-by-window, and
\fs${osd-font-size} * 288 / ${osd-height}
with --osd-scale-by-window=no. This is because
sub/osd_libass.c:update_playres() sets
track->PlayResY = ass->res_y ? ass->res_y : MP_ASS_FONT_PLAYRESY,
where MP_ASS_FONT_PLAYRESY is 288.

This also works with persistent_overlay=yes.

{\fscx100}{\fscy100} would also replicate --osd-font-size with show-text
and with osd-verlay + --osd-scale-by-window, but not with osd-overlay +
--osd-scale-by-window=no.

The default sizes are multiplied by 720/288 = 2.5 to keep them the same
as before.
2024-10-29 20:35:35 +01:00
Guido Cella 15ad917bb1 stats.lua: remove term_height_limit script-opt
It is excessive control to manually configure the terminal height limit
just for stats, if anything this should be added as an option used all
throughout mpv.
2024-10-21 20:07:01 +02:00
Guido Cella d6951e4039 stats.lua: don't print the scroll hint with bindlist 2024-10-21 20:07:01 +02:00
Guido Cella a187110f4a stats.lua: clip lines with ${term-clip-cc}
Use the property introduced in bf025cd289 to clip the lines of stats.lua
with accurate unicode width detection and considering --msg-module and
--msg-time. This allows removing the term ellipsis functions.

Also use script-opts-append instead of script-opts in the docs so
script-opts in mpv.conf, which could change keybindings, are not
overriden.
2024-10-21 20:07:01 +02:00
Guido Cella f72f6b0fc4 stats.lua: indent terminal output with 4 spaces instead of tab
Because the default tab width of 8 cells wastes too much space, and 4
spaces is closer to the width of ass_indent.
2024-10-21 20:07:01 +02:00
Kacper Michajłow 08e2acbae1 stats.lua: don't use io.write from builtin script
Scripts and especially internal scripts shouln't bypass msg.c logging
code for various resons, ranging from processing the input, filtering
the log levels, truncating the output and so on. io.write() is lazy way
of outputing to stdout without respecting mpv's logging module.

Uses osd message, because this has no prefixes. Added internal
flush-status-line command to flush current output without clearing
before exiting.

This commit will allow us to remove duplicated terminal handling code
from stats.lua, mpv core already handles all that and does it in better
way, without taking shortcuts.
2024-10-17 22:32:10 +02:00
Guido Cella 50faafd8bd stats.lua: exit with ESC if being toggled
If not opened in oneshot mode, close the stats with ESC. Especially now
that ? toggles showing key bindings by default, this provides an
intuitive way to close the stats.

Also do some minor reformatting of key binding documentation.
2024-10-17 16:57:35 +02:00
nanahi 86e8cae9ca stats.lua: add nonscalable prefix to cmd_prefixes 2024-10-14 01:55:49 +02:00
Guido Cella e34f6569ee stats.lua: rename a variable 2024-10-12 21:24:41 +02:00
Guido Cella 493cab7efc stats.lua: allow keybindings to toggle the display of a specific page
This lets you define bindings like h script-binding
stats/display-page-4-toggle. Requested in #14966.
2024-10-04 21:13:29 +03:00
Guido Cella be814e3753 stats.lua: scroll keybindings while filtering them
console.lua binds up and down to navigate its history. Add a private
flag to mp.input.get to instruct console.lua not to bind up and down, so
you can use them to scroll the keybindings page while filtering
keybindings.

If it is requested, this can be replaced with an argument to input.get
to not bind arbitrary keys.

Fixes #14966.
2024-10-04 21:13:29 +03:00
Guido Cella dcd681ecdd stats.lua: filter keybindings by comment
Requested in #14966.
2024-10-04 21:13:29 +03:00
Kacper Michajłow 1c55d600ab stats.lua: add timecode display 2024-09-24 19:47:42 +02:00
Kacper Michajłow e7f153db58 stats.lua: don't use ASS tags when use_ass is false
Fixes terminal output.
2024-09-08 17:33:03 +02:00
nanahi f02b8bc9fd stats.lua: fix text size/alignment for key bindings page
After a subject line, the text style needs to be reset to make
sure that key binding lines have correct size and alignment
while scrolling the page.
2024-09-05 14:06:05 +02:00
Guido Cella 8110bdac6d command: remove deprecated packet-*-bitrate properties
These have been deprecated for 9 years so it's fine to remove them.

Using the replacement properties like video-bitrate in stats.lua will
convert big enough bitrates to Mbps.
2024-07-18 22:52:35 +02:00
Guido Cella 7bcd525dce various: sync shown track flags
Show the same flags in loadfile.c, select.lua and stats.lua. The only
differences are that only stats.lua prints both image and albumart
because it's supposed to show detailed track information, and select.lua
prints the image flag because pressing g-v doesn't show Video or Image
like in loadfile.c and stats.lua.
2024-07-18 22:52:35 +02:00
Guido Cella 2fd88ffbae various: print Image instead or Video for image tracks
Fixes #8561.
2024-07-18 22:52:35 +02:00
verygoodlee bcc72f97ef stats.lua: active key bindings: identify prefix nonrepeatable
The nonrepeatable prefix was added at commit bc5863a
2024-07-05 16:42:31 +03:00
Kacper Michajłow a3f72ea87c stats.lua: fix codec-profile position for audio 2024-06-27 20:24:13 +02:00
Kacper Michajłow a41cdf0289 stats.lua: align 100% correctly on page 2
It is not common to have one pass with 100% usage, but it is not
impossible, so handle this case too.
2024-06-14 00:26:04 +02:00
nanahi d2bd77ada0 stats.lua: display file tags
This adds file tags to display along with the title, including
album/artist etc. for music, and series etc. for some videos.
The list of tags to display is identical to the tags printed to
the terminal and is controlled by the --display-tags option.

To filter out overlength tags (such as long comments and lyrics) and
files with too many tags, add file_tag_max_length and file_tag_max_count
options so that tags longer than this length are not displayed, and only
the first few tags are displayed.

Also makes tags show on page 5 only.
2024-06-09 00:58:48 +02:00
Guido Cella 948faa5482 lua: don't pass nil as the second argument of mp.get_property_number
This doesn't do anything because nil is already the default value of
unavailable properties.
2024-06-08 23:10:37 +02:00
Guido Cella 1a5edb1e49 stats.lua: remove print_perfdata_passes
22a8b99 introduced print_perfdata_passes as a stopgap until a dedicated
performance stats page would be implemented. Since it has been
implemented for many years, remove this option, which isn't even
documented, and is likely to make the stats overflow beyond the screen.
2024-06-08 23:07:17 +02:00
Kacper Michajłow 73e779a1ee stats.lua: add page 5 for currently selected tracks information 2024-06-08 23:06:22 +02:00
nanahi 6679ef003e stats.lua: make the append function increment index only on newline
To avoid a large append parameter refactoring is to make the append
function add the table index only if the newline character is not empty.
Otherwise, new strings are appended to the existing string.
2024-06-08 23:06:22 +02:00
nanahi de371a579f stats.lua: handle osd-scale-by-window runtime update
Allows the scale mode to be changed at runtime if vidscale is set to auto.
2024-05-20 18:29:44 +02:00
nanahi 85b3a6e567 {stats,osc}.lua: respect --osd-scale-by-window by default
This lets these scripts scale the elements with OSD by default.
2024-05-20 18:29:44 +02:00
nanahi 1f29d037a0 stats.lua: add add auto value to vidscale option
This adds auto to vidscale script option, which lets the scale be
inherited from OSD --osd-scale-by-window option.
2024-05-20 18:29:44 +02:00
Guido Cella daba15b272 stats.lua: prevent freeze in certain cases with vidscale=no
If using --script-opts=stats-vidscale=no, until osd-height changes from
0 to the correct value, stats.lua's text sizes are multiplied by a scale
of 720, which with the default font size results in a font size of 5760.
Depending on the order of operations, if the stats are drawn at this
size before osd-height is updated, mpv freezes. I get this with
--input-commands=script-message-to stats display-stats-toggle in
conditional profiles, e.g.:

mpv --script-opts=stats-vidscale=no --include=<(echo $'[test]\nprofile-cond=true\ninput-commands=script-message-to stats display-stats-toggle') av://lavfi:testsrc

Fix this by setting a scale to 1 until osd-height is updated to the
correct value.
2024-05-20 17:56:17 +02:00