mpv icon indicating copy to clipboard operation
mpv copied to clipboard

Possible to edit playback-time format to hide hour field from OSD if the file is shorter than 1 hour?

Open KonoVitoDa opened this issue 1 year ago • 4 comments

For the aforementioned purpose I would use an auto profile like this, but with the playback-time property edited to not showing (00:) hours:

[not-hour]
profile-cond=duration < 3600
osd-msg3="${osd-sym-cc} ${playback-time/full} / ${duration/full} (${percent-pos}%) | Frame: ${estimated-frame-number} / ${estimated-frame-count}"

KonoVitoDa avatar Feb 07 '24 00:02 KonoVitoDa

You can use --term-status-msg=foo to apply a custom term status message. ${=playback-time} property can be used to expand playback-time as a number rather than as a human-readable format. You may also want to check out status-message.lua and possibly use it as a model to do it yourself if you wish.

Traneptora avatar Feb 07 '24 00:02 Traneptora

You can use --term-status-msg=foo to apply a custom term status message.

I'm a beginner and with no programming experience, so I'm not sure I'll know how to do this, but I'll try.

You may also want to check out status-message.lua

Is this a script? I couldn't find it through Google. Do you have a link?

KonoVitoDa avatar Feb 07 '24 02:02 KonoVitoDa

mp.observe_property('playback-time', 'native', function ()
    mp.set_property('user-data/playback-time-short', mp.get_property_osd('playback-time/full'):sub(4))
end)

osd-msg3=${osd-sym-cc} ${user-data/playback-time-short} / ${duration/full} (${percent-pos}%) | Frame: ${estimated-frame-number} / ${estimated-frame-count}

guidocella avatar Feb 07 '24 08:02 guidocella

@guidocella It worked percetly, thank you so much!!! For any other newbie like me seeing this on the future, the step-by-step to achieve what I wanted is:

  • Create a .lua file in your /scripts folder and add this:
mp.observe_property('playback-time', 'native', function ()
    mp.set_property('user-data/playback-time-short', mp.get_property_osd('playback-time/full'):sub(4))
end)

mp.observe_property('duration', 'native', function ()
    mp.set_property('user-data/duration-short', mp.get_property_osd('duration/full'):sub(4))
end)
  • In mpv.conf set the default osd-msg3 value to:
osd-msg3="${osd-sym-cc} ${user-data/playback-time-short} / ${user-data/duration-short} (${percent-pos}%) | Frame: ${estimated-frame-number} / ${estimated-frame-count}"
  • Create a conditional profile for files longer than 1 hour and place the old osd-msg3 there:
[1-hour]
profile-cond=duration >= 3600
profile-restore=copy-equal
osd-msg3="${osd-sym-cc} ${playback-time/full} / ${duration/full} (${percent-pos}%) | Frame: ${estimated-frame-number} / ${estimated-frame-count}"

KonoVitoDa avatar Feb 07 '24 09:02 KonoVitoDa

Just a quick note. Latest uosc does this with chapter time remaining. 02:03:34 then say less than 1 hour only shows 59:22 and when less than 1 min shows 43. I

mrfragger avatar Feb 26 '24 19:02 mrfragger