ggerganov commited on
Commit
983b59f
·
unverified ·
2 Parent(s): 0ab5514 87fa366

Merge pull request #36 from Topping1/master

Browse files

Fix SRT timestamp format from mm:ss.sss to hh:mm:ss.sss

Files changed (1) hide show
  1. main.cpp +9 -6
main.cpp CHANGED
@@ -14,13 +14,16 @@
14
  // 500 -> 00:05.000
15
  // 6000 -> 01:00.000
16
  std::string to_timestamp(int64_t t) {
17
- int64_t sec = t/100;
18
- int64_t msec = t - sec*100;
19
- int64_t min = sec/60;
20
- sec = sec - min*60;
21
-
 
 
 
22
  char buf[32];
23
- snprintf(buf, sizeof(buf), "%02d:%02d.%03d", (int) min, (int) sec, (int) msec);
24
 
25
  return std::string(buf);
26
  }
 
14
  // 500 -> 00:05.000
15
  // 6000 -> 01:00.000
16
  std::string to_timestamp(int64_t t) {
17
+ int64_t msec = t * 10;
18
+ int64_t hr = msec / (1000 * 60 * 60);
19
+ msec = msec - hr * (1000 * 60 * 60);
20
+ int64_t min = msec / (1000 * 60);
21
+ msec = msec - min * (1000 * 60);
22
+ int64_t sec = msec / 1000;
23
+ msec = msec - sec * 1000;
24
+
25
  char buf[32];
26
+ snprintf(buf, sizeof(buf), "%02d:%02d:%02d.%03d", (int) hr, (int) min, (int) sec, (int) msec);
27
 
28
  return std::string(buf);
29
  }