[MPlayer-dev-eng] [PATCH] time printing in hh:mm:ss.f

Robert M. Riches Jr rm.riches at verizon.net
Wed May 7 23:24:42 CEST 2003


The attachment (if attaching it worked) contains a patch to
mplayer.c that converts the non-GUI audio-only time display
to hh:mm:ss.f format rather than straight seconds.  Among
other purposes, I am using MPlayer to find breaks between
sections of recorded audio, and I find the hh:mm:ss.f format
much more user-friendly than straight seconds.  If there are
others who prefer straight seconds, perhaps the format
should be selectable with a command-line option.

I have no employer, so this patch is not subject to risk of
a corporation attempting to claim copyright ownership.

(The first time I tried to send this, my mailer (mutt)
failed to encode with base64.  I couldn't find a way to
force base64 encoding.  If this is mandatory, I would
appreciate a suggestion for how to force a base64-encoded
attachment.)

Thanks.

Robert Riches
rm.riches at verizon.net
rmriches at ieee.org
-------------- next part --------------
Index: mplayer.c
===================================================================
RCS file: /cvsroot/mplayer/main/mplayer.c,v
retrieving revision 1.692
diff -u -r1.692 mplayer.c
--- mplayer.c	19 Apr 2003 18:46:15 -0000	1.692
+++ mplayer.c	2 May 2003 00:40:27 -0000
@@ -1917,11 +1917,46 @@
 
 if(!sh_video) {
   // handle audio-only case:
-  if(!quiet) mp_msg(MSGT_AVSYNC,MSGL_STATUS,"A:%6.1f %4.1f%% %d%%   \r"
-		    ,sh_audio->delay-audio_out->get_delay()
+  if(!quiet) {
+      //
+      // convert time to HH:MM:SS.F format
+      //
+      long tenths = 10 * sh_audio->delay-audio_out->get_delay();
+      int hh = (tenths / 36000) % 100;
+      int mm = (tenths / 600) % 60;
+      int ss = (tenths /  10) % 60;
+      int f1 = tenths % 10;
+      char hhmmssf[16]; // only really need 11, but just in case...
+      sprintf( hhmmssf, "%2d:%2d:%2d.%1d", hh, mm, ss, f1);
+      if (0 == hh) {
+        hhmmssf[1] = ' ';
+        hhmmssf[2] = ' ';
+      }
+      // uncomment the next three lines to show leading zero ten-hours
+      // else if (' ' == hhmmssf[0]) {
+      //   hhmmssf[0] = '0';
+      // }
+      if ((0 == hh) && (0 == mm)) {
+        hhmmssf[4] = ' ';
+        hhmmssf[5] = ' ';
+      }
+      else if ((' ' == hhmmssf[3]) && (' ' != hhmmssf[2])) {
+        hhmmssf[3] = '0';
+      }
+      if ((' ' == hhmmssf[6]) && (' ' != hhmmssf[5])) {
+        hhmmssf[6] = '0';
+      }
+      //
+      // Instructions for sending patches say to not
+      // change indentation or whitespace, so the following
+      // statement is indented as the original.
+      //
+             mp_msg(MSGT_AVSYNC,MSGL_STATUS,"A:  %s %4.1f%% %d%%   \r"
+		    ,hhmmssf
 		    ,(sh_audio->delay>0.5)?100.0*audio_time_usage/(double)sh_audio->delay:0
 		    ,cache_fill_status
 		    );
+  }
   if(d_audio->eof) eof = PT_NEXT_ENTRY;
 
 } else {


More information about the MPlayer-dev-eng mailing list