mirror of
https://github.com/mpv-player/mpv
synced 2025-01-11 17:39:38 +00:00
OSD: support displaying fractional part of current position
Add option -osd-fractions which enables display of fractional seconds when showing the current playback time on OSD. Based on a patch from Christian <herr.mitterlehner@gsmpaaiml.com> but with several modifications.
This commit is contained in:
parent
511498818f
commit
7fe2856fd9
@ -2408,6 +2408,24 @@ Deaktiviert das automatische Laden von Untertiteln.
|
||||
Setzt die Anzeigedauer der OSD-Meldungen in ms (Standard: 1000).
|
||||
.
|
||||
.TP
|
||||
.B \-osd\-fractions <0\-2>
|
||||
Setzt die Art der Anzeige von Nachkommastellen des aktuellen Zeitstempels im
|
||||
OSD:
|
||||
.PD 0
|
||||
.RSs
|
||||
.IPs 0
|
||||
Keine Anzeige der Nachkommastellen (Standard).
|
||||
.IPs 1
|
||||
Zeige die ersten beiden Nachkommastellen.
|
||||
.IPs 2
|
||||
Zeige genäherte Framezahl an.
|
||||
Die angezeigte Framezahl ist nicht exakt, sondern nur genähert.
|
||||
Für variable FPS ist die Näherung weit von der tatsächlichen Framezahl
|
||||
entfernt.
|
||||
.RE
|
||||
.PD 1
|
||||
.
|
||||
.TP
|
||||
.B \-osdlevel <0\-3> (nur bei MPlayer)
|
||||
Gibt den Modus an, in dem das OSD startet:
|
||||
.PD 0
|
||||
|
@ -2298,6 +2298,23 @@ Turns off automatic subtitle file loading.
|
||||
Set the duration of the OSD messages in ms (default: 1000).
|
||||
.
|
||||
.TP
|
||||
.B \-osd\-fractions <0\-2>
|
||||
Set how fractions of seconds of the current timestamp are printed on the OSD:
|
||||
.PD 0
|
||||
.RSs
|
||||
.IPs 0
|
||||
Do not display fractions (default).
|
||||
.IPs 1
|
||||
Show the first two decimals.
|
||||
.IPs 2
|
||||
Show approximate frame count within current second.
|
||||
This frame count is not accurate but only an approximation.
|
||||
For variable fps, the approximation is known to be far off the correct frame
|
||||
count.
|
||||
.RE
|
||||
.PD 1
|
||||
.
|
||||
.TP
|
||||
.B \-osdlevel <0\-3>
|
||||
Specifies which mode the OSD should start in.
|
||||
.PD 0
|
||||
|
@ -216,6 +216,7 @@ const m_option_t mplayer_opts[]={
|
||||
#endif
|
||||
OPT_INTRANGE("osdlevel", osd_level, 0, 0, 3),
|
||||
OPT_INTRANGE("osd-duration", osd_duration, 0, 0, 3600000),
|
||||
OPT_INTRANGE("osd-fractions", osd_fractions, 0, 0, 2),
|
||||
#ifdef CONFIG_MENU
|
||||
{"menu", &use_menu, CONF_TYPE_FLAG, CONF_GLOBAL, 0, 1, NULL},
|
||||
{"nomenu", &use_menu, CONF_TYPE_FLAG, CONF_GLOBAL, 1, 0, NULL},
|
||||
|
38
mplayer.c
38
mplayer.c
@ -1639,7 +1639,9 @@ static void update_osd_msg(struct MPContext *mpctx)
|
||||
int len = get_time_length(mpctx);
|
||||
int percentage = -1;
|
||||
char percentage_text[10];
|
||||
int pts = get_current_time(mpctx);
|
||||
char fractions_text[4];
|
||||
double fpts = get_current_time(mpctx);
|
||||
int pts = fpts;
|
||||
|
||||
if (mpctx->osd_show_percentage_until)
|
||||
percentage = get_percent_pos(mpctx);
|
||||
@ -1649,15 +1651,41 @@ static void update_osd_msg(struct MPContext *mpctx)
|
||||
else
|
||||
percentage_text[0] = 0;
|
||||
|
||||
if (opts->osd_fractions == 1) {
|
||||
//print fractions as sub-second timestamp
|
||||
snprintf(fractions_text, sizeof(fractions_text), ".%02d",
|
||||
(int)((fpts - pts) * 100));
|
||||
} else if (opts->osd_fractions == 2) {
|
||||
/* Print fractions by estimating the frame count within the
|
||||
* second.
|
||||
*
|
||||
* Rounding or cutting off numbers after the decimal point
|
||||
* causes problems because of float's precision and movies
|
||||
* whose first frame is not exactly at timestamp 0. Therefore,
|
||||
* we add 0.2 and cut off at the decimal point, which proved
|
||||
* to be good heuristic.
|
||||
*/
|
||||
double fps = mpctx->sh_video->fps;
|
||||
if (fps <= 1 || fps > 99)
|
||||
strcpy(fractions_text, ".??");
|
||||
else
|
||||
snprintf(fractions_text, sizeof(fractions_text), ".%02d",
|
||||
(int) ( (fpts - pts) * fps + 0.2 ) );
|
||||
} else {
|
||||
//do not print fractions
|
||||
fractions_text[0] = 0;
|
||||
}
|
||||
|
||||
if (opts->osd_level == 3)
|
||||
snprintf(osd_text_timer, 63,
|
||||
"%c %02d:%02d:%02d / %02d:%02d:%02d%s",
|
||||
"%c %02d:%02d:%02d%s / %02d:%02d:%02d%s",
|
||||
mpctx->osd_function,pts/3600,(pts/60)%60,pts%60,
|
||||
len/3600,(len/60)%60,len%60,percentage_text);
|
||||
fractions_text, len/3600, (len/60)%60, len%60,
|
||||
percentage_text);
|
||||
else
|
||||
snprintf(osd_text_timer, 63, "%c %02d:%02d:%02d%s",
|
||||
snprintf(osd_text_timer, 63, "%c %02d:%02d:%02d%s%s",
|
||||
mpctx->osd_function,pts/3600,(pts/60)%60,
|
||||
pts%60,percentage_text);
|
||||
pts%60, fractions_text, percentage_text);
|
||||
} else
|
||||
osd_text_timer[0]=0;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user