Skip to content

Commit

Permalink
restrict milliseconds field in SRT time codes to 3 digits
Browse files Browse the repository at this point in the history
  • Loading branch information
warren-bank committed Dec 26, 2024
1 parent 8d964c6 commit 57ebbcd
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,12 @@ private static long parseTimecode(Matcher matcher, int groupOffset) {
timestampMs += Long.parseLong(Assertions.checkNotNull(matcher.group(groupOffset + 3))) * 1000;
@Nullable String millis = matcher.group(groupOffset + 4);
if (millis != null) {
if (millis.length() > 3) {
try {
millis = millis.substring(0, 3);
}
catch(IndexOutOfBoundsException e) {}
}
timestampMs += Long.parseLong(millis);
}
return timestampMs * 1000;
Expand Down

0 comments on commit 57ebbcd

Please sign in to comment.