mpv icon indicating copy to clipboard operation
mpv copied to clipboard

Add `--save-position-on-error` feature

Open etosan opened this issue 6 months ago • 2 comments

Expected behavior of the wanted feature

As youtube and other providers are cracking down on direct streaming outside of their platforms, various intermittent failures are increasing.

It would be really cool if user could define save-position-on-error=yes which would not save video playback position on normal quit, but only on explicit save-quit (which is handled by different option/command Shift+Q by default I think) AND also should streaming error happen if this setting is true.

This would allow one restart the videos easily on failure, without the need to rewind forward to time of failure. Normal quit is user wanted quit, invoked by command, so then save-on-quit feature is not needed. Explicit save-and-quit feature is as well always honored, when bound.

Alternative behavior of the wanted feature

No response

Log File

No response

Sample Files

No response

etosan avatar Jun 11 '25 18:06 etosan

Normal quit is user wanted quit, invoked by command, so then save-on-quit feature is not needed. Explicit save-and-quit feature is as well always honored, when bound.

Then disable this option and use command instead. You can also use profile together to implement it.

hooke007 avatar Jun 12 '25 02:06 hooke007

Then disable this option and use command instead.

The problem is I don't care about this, when I quit video explicitly, because there I either:

  • want to quit without saving, and I don't care about position then (what I already do wit Q)
  • want to save position for later, and I care about position then (and I already do that with Shift+Q)

So this is not a problem with normal use (ie with user intent).

Problem starts to appear when mpv quits itself due to stream layer error etc. This quit action not initiated by you, but by external circumstance, so you, as user have no say in it. mpv just quits here and does not save the position, by default.

Quitting without saving all the time, even because of errors, and not saving position by default, is probably the wrong course here, I believe.

It is actually during error, that you want the position to be saved, not when stream properly ends (get played in full) or you want it to end explicitly.

Should position be saved during error, you have chance to restart watching quickly, should the error be some intermittent failure or something. Also you can return to stream later. Now you need to take note of stream position from shell terminal (that is what I do) and rewind where it crashed. It would be great if it did on it's own.

Also for clarification: by stream I count anything coming over http/https and other seekable streaming protocols, even youtube video, for example.

You can also use profile together to implement it.

I tried to look into it but after some thinking about it realized, this should not be hacked in but an actual feature.

mpv itself is the only instance here, which knows that the stream layer had error and is ending, and can catch that and use save-on-quit infrastructure to save position into position file. In fact I believe this should be set to "on" by default.

Of course, if you know how to implement this save-pos-on-error by combination of profiles and invocations or with lua script, I am all ears. Still I would prefer this to be in core. I can not be the only one experiencing this issue, or am I?

etosan avatar Jun 12 '25 06:06 etosan