Skip to content

Commit

Permalink
Merge pull request ggerganov#36 from Topping1/master
Browse files Browse the repository at this point in the history
Fix SRT timestamp format from mm:ss.sss to hh:mm:ss.sss
  • Loading branch information
ggerganov authored Oct 10, 2022
2 parents bd487ab + cf6b653 commit 582c096
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,16 @@
// 500 -> 00:05.000
// 6000 -> 01:00.000
std::string to_timestamp(int64_t t) {
int64_t sec = t/100;
int64_t msec = t - sec*100;
int64_t min = sec/60;
sec = sec - min*60;

int64_t msec = t * 10;
int64_t hr = msec / (1000 * 60 * 60);
msec = msec - hr * (1000 * 60 * 60);
int64_t min = msec / (1000 * 60);
msec = msec - min * (1000 * 60);
int64_t sec = msec / 1000;
msec = msec - sec * 1000;

char buf[32];
snprintf(buf, sizeof(buf), "%02d:%02d.%03d", (int) min, (int) sec, (int) msec);
snprintf(buf, sizeof(buf), "%02d:%02d:%02d.%03d", (int) hr, (int) min, (int) sec, (int) msec);

return std::string(buf);
}
Expand Down

0 comments on commit 582c096

Please sign in to comment.