Make mpv hold on the last picture instead of closing

mpv
11,738

Solution 1

You'd use mpv --keep-open=yes, which you can find in the mpv manpage.

It allows three values: no (close/advance to next at end of video, the default), yes (advance if there is a next video, otherwise pause), and always (always pause at end of video, even if there is a next video).

You should also be able to put keep-open=yes in your ~/.config/mpv/mpv.conf or ~/.mpv/config (whichever you're using)

Solution 2

Thanks to derobert for hinting me towards this:

If you do want to use keep-openbut don't want that behavior all the time, I wrote a little script to turn it on just once:

reset_keep_open = false
keep_open_val = nil
function nopause()
    print("Not pausing after current")
    if keep_open_val ~= nil then
        mp.set_property("keep-open", keep_open_val)
    end
    reset_keep_open = false
end
function pause_after_current()
    if reset_keep_open == false then
        keep_open_val = mp.get_property("keep-open")
        reset_keep_open = true
        mp.set_property("keep-open", "always")
        print("Pause after current.")
    else
        nopause()
    end
end
function on_pause_change(name, value)
    if reset_keep_open then
        nopause()
    end
end
mp.observe_property("pause", "bool", on_pause_change)
mp.add_key_binding("P", "pause_after_current", pause_after_current)

(Goes into ~/.config/mpv/scripts/pauseaftercurrent.lua)

However, I could have made my life a lot easier by just putting

P cycle keep-open up

into my input.conf.

Share:
11,738

Related videos on Youtube

student
Author by

student

Updated on September 18, 2022

Comments

  • student
    student almost 2 years

    If I watch a video with mpv, it closes after the video ends. How can I configure it such that it doesn't close, for example just freezes the last image of the movie, so that I can seek back and forth without restarting the video.

  • Caesar
    Caesar over 5 years
    Neat. Can this be changed while the player is running? (I'm looking for a "stop after current song"-option…)
  • derobert
    derobert over 5 years
    @Caesar I would guess yes, but haven't tested or checked the manpage. mpv allows a lot of options to be changed at runtime via "properties" which can be set by, e.g., Lua scripting. You can also manipulate the playlist via scripting.
  • EsmaeelE
    EsmaeelE over 3 years
    @derobert debian 10 have this config under .config/ directory, Then put it inside ~/.config/mpv/mpv.conf works on it.