Skip to content

Add arbitrary formatting of time values in Property Expansion #4117

@Ud71p

Description

@Ud71p

This is a feature request to extend the Property Expansion mechanism to allow for arbitrary formatting of time values.

For instance:
osd-msg3='${time-remaining}'
results in:
00:45:21

I would like to be able to format the time-remaining in some other format than HH:MM:SS, to suit my needs better. For instance I don't care about seconds at all, and I rarely see anything longer than 99 minutes, so I would like the format MM. This way I can show time-remaining in 2 characters instead of 8. For instance I would like to write:
osd-msg3='${time-remaining%MM}'

mpv has already time-formatting, I found one in the documentation of --screenshot-template argument. So what is missing is just some kind of glue-code to allow for arbitrary formats in property expansion.

Even better, to make the formatting really arbitrary, mpv could allow piping the value to arbitrary command. Then I could write a simple shell script that formats the data the way I want, like so:
osd-msg3='${time-remaining|bash ~/.mpv/my_time_format.sh}'

For instance I always wanted to display current wall time during movie playback, plus the time-remaining in MM format if MM>1 otherwise SS format, plus the count of unread email messages in my inbox. That would be hard with just property expansion, but trivial if piping is added.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions