[MPlayer-dev-eng] Fractional part of time stamp in OSD

Christian herr.mitterlehner at gsmpaaiml.com
Fri Jan 28 14:05:25 CET 2011


Hi,

currently, the OSD shows only the integral part of the time stamp.
Attached patch allows to optionally also show the fractional part of the time stamp in the OSD.

Kind regards,
Christian

P.S.: This is useful for example when trying to create EDLs. There, when trying to place a cut-mark just before a scene change, it typically occurs that one notices the
scene change just after it had occurred (i.e.: one frame too late). Hence, one has to rewind the stream and go to the frame just before the scene-change. Doing so requires
to constantly have an eye on the terminal (for the subsecond time stamp) and one on the movie itself (to assert the scene change did not yet occur). Allowing to show the
fractional part of the time stamp in the OSD solves this issue.

P.P.S.: The proposed changes of the same approach in 2007 [1] have been included in the attached patch. Another previous attempt in this direction has been ignored in 2008
[2].

[1] http://lists.mplayerhq.hu/pipermail/mplayer-dev-eng/2007-April/051032.html
[2] http://lists.mplayerhq.hu/pipermail/mplayer-dev-eng/2008-April/056972.html
-------------- next part --------------
Index: DOCS/man/en/mplayer.1
===================================================================
--- DOCS/man/en/mplayer.1	(revision 32825)
+++ DOCS/man/en/mplayer.1	(working copy)
@@ -2426,6 +2426,22 @@
 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 approximated 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> (MPlayer only)
 Specifies which mode the OSD should start in.
 .PD 0
Index: DOCS/man/de/mplayer.1
===================================================================
--- DOCS/man/de/mplayer.1	(revision 32825)
+++ DOCS/man/de/mplayer.1	(working copy)
@@ -2416,6 +2416,23 @@
 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?rte Framezahl an. Die angezeigte Framezahl ist nicht exakt,
+sondern nur gen?rt. F?iable FPS ist die N?rung weit von der 
+tats?lichen Framezahl entfernt.
+.RE
+.PD 1
+.
+.TP
 .B \-osdlevel <0\-3> (nur bei MPlayer)
 Gibt den Modus an, in dem das OSD startet:
 .PD 0
Index: mplayer.c
===================================================================
--- mplayer.c	(revision 32825)
+++ mplayer.c	(working copy)
@@ -212,6 +212,7 @@
 // if nonzero, hide current OSD contents when GetTimerMS() reaches this
 unsigned int osd_visible;
 int osd_duration = 1000;
+int osd_fractions = 0; // determines how fractions of seconds are displayed on OSD
 
 int term_osd = 1;
 static char* term_osd_esc = "\x1b[A\r\x1b[K";
@@ -1569,6 +1570,8 @@
             int len = demuxer_get_time_length(mpctx->demuxer);
             int percentage = -1;
             char percentage_text[10];
+            char fractions_text[5];
+            char* fractions_text_start = fractions_text;
             int pts = demuxer_get_current_time(mpctx->demuxer);
 
             if (mpctx->osd_show_percentage)
@@ -1579,15 +1582,30 @@
             else
                 percentage_text[0] = 0;
 
+            if (osd_fractions==1) {
+                //print fractions as sub-second timestamp
+                snprintf(fractions_text, 5, "%4.2f", mpctx->sh_video->pts - pts);
+                fractions_text_start++; //This is to skip beyond the leading 0 in eg 0.12
+            } else if (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 as good heuristic
+                snprintf(fractions_text, 4, ".%02d", (int) ( ( mpctx->sh_video->pts - pts ) * mpctx->sh_video->fps + 0.2 ) );
+            else
+                //do not print fractions
+                fractions_text[0] = 0;
+
             if (osd_level == 3)
                 snprintf(osd_text_timer, 63,
-                         "%c %02d:%02d:%02d / %02d:%02d:%02d%s",
-                         mpctx->osd_function,pts/3600,(pts/60)%60,pts%60,
+                         "%c %02d:%02d:%02d%s / %02d:%02d:%02d%s",
+                         mpctx->osd_function,pts/3600,(pts/60)%60,pts%60,fractions_text_start,
                          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_start,percentage_text);
         } else
             osd_text_timer[0]=0;
 
Index: cfg-mplayer.h
===================================================================
--- cfg-mplayer.h	(revision 32825)
+++ cfg-mplayer.h	(working copy)
@@ -235,6 +235,7 @@
 #endif
     {"osdlevel", &osd_level, CONF_TYPE_INT, CONF_RANGE, 0, 3, NULL},
     {"osd-duration", &osd_duration, CONF_TYPE_INT, CONF_MIN, 0, 0, NULL},
+    {"osd-fractions", &osd_fractions, CONF_TYPE_INT, CONF_RANGE, 0, 2, NULL},
 #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},


More information about the MPlayer-dev-eng mailing list