CarterLi / iina

The modern video player for macOS with additional features and bug fixes.
https://iina.io
GNU General Public License v3.0
678 stars 29 forks source link

Support showing mpv statistics and possibly key binding via scripts #29

Open John-He-928 opened 2 years ago

John-He-928 commented 2 years ago

This is actually a bug in official IINA that not (fully) fixed I think. The official issue: https://github.com/iina/iina/issues/1053

The mpv-stats.lua script is not able to add key bindings to IINA, so the statistics feature in mpv is somewhat unusable. IINA official gives a workaround that add key bindings manually to switch pages. I don't think this is a perfect solution. Also, the page 2 of the statistics, frame timing, don't shown up even with a key binding. The frame timing page is very useful when debugging video filters or custom shader scripts.

What you want IINA to do:

What IINA does currently:

When switching to frame timing page, it shows no contents.

Why you think this should be added:

The frame timing page is very useful when debugging video filters or custom shader scripts.

Examples of other projects that have something similar: The mpv official manual page: https://mpv.io/manual/master/#stats

CarterLi commented 2 years ago

Is there any runtime flags for showing mpv statistics?

CarterLi commented 2 years ago

possibly key binding via scripts

Afraid no. IINA uses MPV as a player core (engine) but dont use MPV's UI part. Key binding is completely about UI, keyboard events, etc.

John-He-928 commented 2 years ago

@CarterLi mpv statistics is enabled by key action script-binding stats/display-stats-toggle, which default to I in mpv.

The official IINA do support showing statistics when assigning a key to script-binding stats/display-stats-toggle, script-binding show-page-1, script-binding show-page-2, ... However, frame timing page(script-binding show-page-2), the most important page I think, is empty when shown. IINA closed the issue long ago, with this left unfixed.

Frame timing page looks like this in mpv: frame timing

John-He-928 commented 2 years ago

I dug a bit into the stats.lua script.

The script queries properties from mpv periodically via mp.get_property() interface, formats them into ASS subtitle script text and prints them using mp.set_osd_ass(). Different pages shows different sets of properties.

The reason that the frame timing page is empty, is IINA lacks some required properties.

local function append_perfdata(s, dedicated_page)
    local vo_p = mp.get_property_native("vo-passes")
    print("vo_p = ", vo_p)
    if not vo_p then
        return
    end

vo_p here is nil so the following routines are skipped.

If IINA can provide the vo-passes property as mpv does, the frame timing page show be available.

low-batt commented 2 years ago

There are multiple issues here. Since the Lua stats script is now built into mpv, IINA probably should add the two key bindings that are active by default to the "mpv Default" key bindings. From mpv manual / STATS:

The following key bindings are active by default unless something else is already bound to them:

i Show stats for a fixed duration I Toggle stats (shown until toggled again)

Not sure how IINA could support the dynamic activation of key bindings the stats script supports.

Note that the mpv command to display a particular page is not "show-page-\<number>" according to the mpv documentation:

And to display a certain page directly:

i script-binding stats/display-page-1 e script-binding stats/display-page-2

By adding key bindings I was able to display pages 1 and 3. I expect page 2 is blank due to this issue https://github.com/iina/iina/issues/3281

On the vo-passes property the mpv manual / Property list says:

vo-passes

Contains introspection about the VO's active render passes and their execution times. Not implemented by all VOs.

I looked through the mpv client API and didn't spot any discussion of statistics. Would have to dig deeply into mpv code to see if there is a way for IINA to supply these statistics to work.