detuur / mpv-scripts

This is a collection of my own mpv scripts.
MIT License
54 stars 9 forks source link

Histogram doesn't show #5

Closed microraptor closed 2 years ago

microraptor commented 2 years ago

Pressing h does nothing and pressing Shift+h or Ctrl+h gives the corresponding OSD messages, but no histogram is displayed.

MPV is loaded with no config or other scripts: mpv --no-config --load-scripts=no -player-operation-mode=pseudo-gui --log-file=log.txt --script=histogram.lua test.mp4

I am running Ubuntu 20.04 and tried it with multiple video files.

[   0.003][v][cplayer] mpv 0.32.0 Copyright © 2000-2020 mpv/MPlayer/mplayer2 projects
[   0.003][v][cplayer]  built on UNKNOWN
[   0.003][v][cplayer] ffmpeg library versions:
[   0.003][v][cplayer]    libavutil       56.31.100
[   0.003][v][cplayer]    libavcodec      58.54.100
[   0.003][v][cplayer]    libavformat     58.29.100
[   0.003][v][cplayer]    libswscale      5.5.100
[   0.003][v][cplayer]    libavfilter     7.57.100
[   0.003][v][cplayer]    libswresample   3.5.100
[   0.003][v][cplayer] ffmpeg version: 4.2.4-1ubuntu0.1

I added some debug messages:

function toggleFilter()
    local vf_table = mp.get_property_native("vf")
    msg.debug("histdebug 1")
    if #vf_table > 0 then
        msg.debug("2")
        for i = #vf_table, 1, -1 do
            msg.debug("3")
            if vf_table[i].label == "histogram" then
                msg.debug("4")
                for j = i, #vf_table-1 do
                    msg.debug("5")
                    vf_table[j] = vf_table[j+1]
                end
                vf_table[#vf_table] = nil
            else
                msg.debug("6")
                vf_table[#vf_table + 1] = {
                    label="histogram",
                    name="lavfi",
                    params= {
                        graph = buildGraph()
                    }
                }
            end
            mp.set_property_native("vf", vf_table)
            msg.debug("7")
            return
        end
        msg.debug("8")
    end
    msg.debug("9")
end

The log output:

[   3.435][d][cplayer] Run command: script-binding, flags=73, args=["histogram/toggle-histogram"]
[   3.435][d][histogram] histdebug 1 
[   3.436][d][histogram] 9 

#vf_table > 0 returns false apparently and the problem seems to be with the vf_table.

microraptor commented 2 years ago

I updated MPV, but the histogram still doesn't show:

[   0.004][v][cplayer] mpv 0.34.1 Copyright © 2000-2021 mpv/MPlayer/mplayer2 projects
[   0.004][v][cplayer]  built on Thu Jan 13 05:58:50 UTC 2022
[   0.004][v][cplayer] FFmpeg library versions:
[   0.004][v][cplayer]    libavutil       56.70.100
[   0.004][v][cplayer]    libavcodec      58.134.100
[   0.004][v][cplayer]    libavformat     58.76.100
[   0.004][v][cplayer]    libswscale      5.9.100
[   0.004][v][cplayer]    libavfilter     7.110.100
[   0.004][v][cplayer]    libswresample   3.9.100
[   0.004][v][cplayer] FFmpeg version: 4.4.1
detuur commented 2 years ago

I'll try reproducing it. Which build of mpv are you using? Default Ubuntu packages?

microraptor commented 2 years ago

I tried it first on Ubuntu 20.04 with the built of the default repo, then updated to this built linked at mpv.io: https://non-gnu.uvt.nl/debian/focal/mpv/mpv_0.34.1+fruit.2_amd64.deb

I also tried it on another computer running Win 10 with mpv 0.34.1 and an old Ubuntu with mpv 0.27.

They all have the same behavior where 'h' doesn't seem to do anything and the other keybindings show only the OSD message.

microraptor commented 2 years ago

I narrowed the problem down and got it wo work if these conditions are met:

I tested it without any .conf file settings on Win 10 and Ubuntu

microraptor commented 2 years ago

I fixed the weird behavior described in the previous comment with PR #6. On one computer the script now functions correctly on Win 10 and Ubuntu. However, on my other computer there is a new error now, if I toggle the histogram on. The video filter is created, but immediately disabled without showing anything onscreen, and the log messages output this error from ffmpeg: Impossible to convert between the formats supported by the filter 'Parsed_split_0' and the filter 'auto_scaler_0' After a quick google search it seems such an error message is often related to specific hardware. I am running integrated Intel graphics on that computer.

microraptor commented 2 years ago

Sorry, I made a mistake and still had hardware decoding enabled on that one computer, which lead to the error message. As explained in PR #6 hardware decoding can be easily toggled off, if one of the key bindings is changed. I also noted it in the readme. With those changes the PR fully resolves this issue.

detuur commented 2 years ago

I haven't had time to look at this issue due to other work, but I'm very glad to see you've managed to resolve it yourself and produced some quality PRs in the process. Thank you for your contributions.