Commit f3c1206d authored by conrad's avatar conrad

oggzinfo: make the Content-Duration a readable time, rather than a number of ms


git-svn-id: http://svn.annodex.net/liboggz/trunk@1079 8158c8cd-e7e1-0310-9fa4-c5954c97daef
parent cc4f3cac
...@@ -178,3 +178,26 @@ ot_page_identify (const ogg_page * og, char ** info) ...@@ -178,3 +178,26 @@ ot_page_identify (const ogg_page * og, char ** info)
return ret; return ret;
} }
int
ot_print_time (double seconds)
{
int hrs, min;
double sec;
char * sign;
sign = (seconds < 0.0) ? "-" : "";
if (seconds < 0.0) seconds = -seconds;
hrs = (int) (seconds/3600.0);
min = (int) ((seconds - ((double)hrs * 3600.0)) / 60.0);
sec = seconds - ((double)hrs * 3600.0)- ((double)min * 60.0);
/* XXX: %02.3f workaround */
if (sec < 10.0) {
return printf ("%s%02d:%02d:0%2.3f", sign, hrs, min, sec);
} else {
return printf ("%s%02d:%02d:%02.3f", sign, hrs, min, sec);
}
}
...@@ -38,4 +38,6 @@ ...@@ -38,4 +38,6 @@
const char * const char *
ot_page_identify (const ogg_page * og, char ** info); ot_page_identify (const ogg_page * og, char ** info);
int ot_print_time (double seconds);
#endif /* __OGGZ_TOOLS_H__ */ #endif /* __OGGZ_TOOLS_H__ */
...@@ -346,7 +346,9 @@ main (int argc, char ** argv) ...@@ -346,7 +346,9 @@ main (int argc, char ** argv)
oggz_close (oggz); oggz_close (oggz);
/* Print summary information */ /* Print summary information */
printf ("Content-Duration: %lld ms\n", info.duration); fputs ("Content-Duration: ", stdout);
ot_print_time ((double)info.duration / 1000.0);
putchar ('\n');
printf ("Content-Length: %ld bytes\n", info.length_total); printf ("Content-Length: %ld bytes\n", info.length_total);
printf ("Content-Bitrate-Average: %ld bps\n", printf ("Content-Bitrate-Average: %ld bps\n",
oi_bitrate (info.length_total, info.duration)); oi_bitrate (info.length_total, info.duration));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment