player: add --term-remaining-playtime option

The OSC reports the speed-adjusted remaining time, but the terminal does
not. This is a weird mismatch and the OSC's default behavior makes
sense, so let's just do some division and add an option to disable it.
Also named "remaining-playtime" after the OSC option. Fixes #10445.
This commit is contained in:
Dudemanguy 2023-08-10 18:53:45 -05:00
parent 6ea08be59a
commit c62b45ec2a
5 changed files with 11 additions and 1 deletions

View File

@ -36,6 +36,8 @@ Interface changes
- change `--audiotrack-pcm-float` default from `no` to `yes`
- add video-params/aspect-name
- change type of `--sub-pos` to float
- The remaining time printed in the terminal is now adjusted for speed by default.
You can disable this with `--no-term-remaining-playtime`.
--- mpv 0.36.0 ---
- add `--target-contrast`
- Target luminance value is now also applied when ICC profile is used.

View File

@ -4787,6 +4787,10 @@ Terminal
See `Property Expansion`_.
``--term-remaining-playtime``, ``--no-term-remaining-playtime``
When printing out the time on the terminal, show the remaining time adjusted by
playback speed. Default: ``yes``
``--term-status-msg=<string>``
Print out a custom string during playback instead of the standard status
line. Expands properties. See `Property Expansion`_.

View File

@ -752,6 +752,7 @@ static const m_option_t mp_opts[] = {
{"term-osd-bar", OPT_BOOL(term_osd_bar), .flags = UPDATE_OSD},
{"term-osd-bar-chars", OPT_STRING(term_osd_bar_chars), .flags = UPDATE_OSD},
{"term-remaining-playtime", OPT_BOOL(term_remaining_playtime), .flags = UPDATE_OSD},
{"term-title", OPT_STRING(term_title), .flags = UPDATE_OSD},
{"term-playing-msg", OPT_STRING(playing_msg)},
@ -1024,6 +1025,7 @@ static const struct MPOpts mp_default_opts = {
.frame_dropping = 1,
.term_osd = 2,
.term_osd_bar_chars = "[-+-]",
.term_remaining_playtime = true,
.consolecontrols = true,
.playlist_pos = -1,
.play_frames = -1,

View File

@ -231,6 +231,7 @@ typedef struct MPOpts {
int term_osd;
bool term_osd_bar;
char *term_osd_bar_chars;
bool term_remaining_playtime;
char *term_title;
char *playing_msg;
char *osd_playing_msg;

View File

@ -195,9 +195,10 @@ static char *get_term_status_msg(struct MPContext *mpctx)
saddf(&line, ": ");
// Playback position
double speed = opts->term_remaining_playtime ? mpctx->video_speed : 1;
sadd_hhmmssff(&line, get_playback_time(mpctx), opts->osd_fractions);
saddf(&line, " / ");
sadd_hhmmssff(&line, get_time_length(mpctx), opts->osd_fractions);
sadd_hhmmssff(&line, get_time_length(mpctx) / speed, opts->osd_fractions);
sadd_percentage(&line, get_percent_pos(mpctx));