mpv-player / mpv

🎥 Command line video player
https://mpv.io
Other
28.1k stars 2.88k forks source link

Lua receiving log messages failure #14588

Closed stax76 closed 2 months ago

stax76 commented 2 months ago

mpv Information

mpv v0.38.0-633-ge509ec0a Copyright © 2000-2024 mpv/MPlayer/mplayer2 projects
 built on Jul 20 2024 12:06:37
libplacebo version: v7.349.0 (v7.349.0-dirty)
FFmpeg version: N-116344-g5c8523cef
FFmpeg library versions:
   libavcodec      61.10.100
   libavdevice     61.2.100
   libavfilter     10.2.102
   libavformat     61.5.101
   libavutil       59.28.100
   libswresample   5.2.100
   libswscale      8.2.100

Other Information

Reproduction Steps

Lua script:

local msg = require "mp.msg"

mp.enable_messages("info")

-- e.prefix  e.level  e.text
mp.register_event('log-message', function(e)
    msg.info(e.level .. "; " .. e.prefix .. "; " .. e.text)
end)

Command line:

mpv --config=no --quiet --geometry=99%:11% --script='D:\Projects\LUA\mpv-scripts\test.lua' --log-file=E:\Desktop\mpv-log.txt 'E:\Video\Movie\Und täglich grüßt das Murmeltier - 1993.mkv'

Terminal output:

[test] fatal; overflow; log message buffer overflow: 2 messages skipped
[test]
[test] fatal; overflow; log message buffer overflow: 2 messages skipped
[test]
[test] fatal; overflow; log message buffer overflow: 2 messages skipped
[test]
[test] fatal; overflow; log message buffer overflow: 2 messages skipped
[test]
[test] fatal; overflow; log message buffer overflow: 2 messages skipped

Expected Behavior

Receiving messages with log level info.

Actual Behavior

Receiving only overflow messages.

Log File

Sample Files

No response

I carefully read all instruction and confirm that I did the following:

llyyr commented 2 months ago

console.lua simply ignores these https://github.com/mpv-player/mpv/blob/master/player/lua/console.lua#L1775-L1779

I don't know if we should be overflowing all the time though

stax76 commented 2 months ago

I didn't realize there is a recursion issue in this code. Going for a walk or taking a break sometimes helps.

stax76 commented 2 months ago

I thought using print instead of msg will solve the issue, it still happens.

I will try writing the log processing code without debug printing or append the debug messages to a debug-ouput.txt text file instead.

guidocella commented 2 months ago

You can use io.write().

stax76 commented 2 months ago

I tried that before, and it didn't work, maybe I was doing something wrong. It turned out my code was very simple, and I didn't need debug printing for it.

local BluRayTitles = {}

mp.enable_messages("info")

mp.register_event('log-message', function(e)
    if e.prefix ~= "bd" then
        return
    end

    if contains(e.text, " 0 duration: ") then
        BluRayTitles = {}
    end

    if contains(e.text, " duration: ") then
        local match = string.match(e.text, "%d%d:%d%d:%d%d")

        if match then
            table.insert(BluRayTitles, match)
        end
    end
end)

What also works is using the run input command and this tool:

https://github.com/stax76/show-args