mpv icon indicating copy to clipboard operation
mpv copied to clipboard

"eof-reached" inconsistent behavior

Open quilloss opened this issue 10 years ago • 5 comments

I noticed some inconsistent behavior in how the eof-reached property is set.

  1. Normal playback to the end would set this property while seeking past the end would not.
  2. Seeking from the end would not clear the property. It would only be cleared after a pause/unpause.
  3. Depending on the moment the pause property is set in Lua the eof-reached property might not change. See the short examples below.
-- Does not change the "eof-reached" property
function eofHandler(name, val)
    if val then
        mp.set_property_number('percent-pos', 50)
        mp.set_property_bool('pause', false)
    end
end
mp.observe_property('eof-reached', 'bool', eofHandler)
-- Changes the "eof-reached" property
local unpause = false

function eofHandler(name, val)
    if val then
        mp.set_property_number('percent-pos', 50)
        unpause = true
    end
end
mp.observe_property('eof-reached', 'bool', eofHandler)

function seekUnpause()
    if unpause then
        unpause = false
        mp.set_property_bool('pause', false)
    end
end
mp.register_event('seek', seekUnpause)

quilloss avatar Dec 19 '15 10:12 quilloss

I'm having trouble following this description. Is this with --keep-open or so?

ghost avatar Dec 23 '15 21:12 ghost

Yes this is with keep-open.

quilloss avatar Dec 24 '15 09:12 quilloss

One problem with your expectations is that --keep-open seeks to the last video frame when seeking past it, but at this point the file didn't necessarily end - there could still be audio left.

ghost avatar Dec 24 '15 10:12 ghost

One problem with your expectations is that --keep-open seeks to the last video frame when seeking past it, but at this point the file didn't necessarily end - there could still be audio left.

Ok just tested without audio and you are right. This addressed my 1st point.

My 2nd point: It turns out that the property is being set correctly all along. Its just Lua that fails to observe the change of the property.

Try setting --osd-msg1="eof-reached: ${eof-reached}" and the Lua script

function eofHandler(name, val)
    mp.msg.info('eof-reached: ' .. tostring(val))
end
mp.observe_property('eof-reached', 'bool', eofHandler)

When eof is reached it would be shown on the OSD and in the console. Next try seeking to the middle. Seeking to the middle of the file will only result in the OSD message being updated. Lua seems to fail to observe the change in the property until the video is unpaused.

My 3rd point: Why does the 2 Lua scripts in my first post results in completely different behavior? The first one will play the file to the end, seek to the middle, play to the end and pause. The second one will play to the end and continuously loop from the middle to the end.

quilloss avatar Dec 24 '15 14:12 quilloss

Ok just tested without audio and you are right. This addressed my 1st point.

Still not entirely what one would expect. Maybe it could just seek to the end of anything, and keep the last video frame. But it's messy.

Lua seems to fail to observe the change in the property until the video is unpaused.

Fixed this one, hopefully.

The first one will play the file to the end, seek to the middle, play to the end and pause.

Can't reproduce anymore after the change, but I didn't try too hard.

ghost avatar Dec 24 '15 16:12 ghost