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.


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)

  • Neat. Can this be changed while the player is running? (I'm looking for a "stop after current song"-option…) – Caesar Feb 14 '19 at 8:47
  • 1
    @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. – derobert Feb 14 '19 at 15:06

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)
    reset_keep_open = false
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.")
function on_pause_change(name, value)
    if reset_keep_open then
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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.