SRT timestamps are written 1 ms early about half the time

Open Beginner friendly
#79 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
76/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
swift
Domain
backend

Research direction

Read TimeInterval.srtTimestamp and formatTime in MKVHelpers.swift, then check the callers that write SRT and generated idx timestamps. Confirm the rounding issue with timestamps such as 1001 ms, and run the relevant timestamp tests if present. Done means both paths derive their components from rounded whole milliseconds and no longer write affected timestamps 1 ms early.

Written by the indexing model from the issue text.

Description

bug

TimeInterval.srtTimestamp computes milliseconds with Int((self - TimeInterval(Int(self))) * 1000), which truncates. For every exact millisecond from 0 to 99,999 ms (as derived from 90 kHz PTS), 48,132 are written 1 ms short, e.g. 1001 ms becomes 00:00:01,000.

formatTime in MKVHelpers.swift (used for generated idx timestamps) has the same problem.

Fix: round to whole milliseconds once (Int((self * 1000).rounded())) and derive h/m/s/ms with integer division.

Dominant language
Swift
Stars
42
Forks
9
Avg merge
9h 30m
Merged PRs (30d)
4

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from ecdye/macSubtitleOCR

All issues in ecdye/macSubtitleOCR

Similar issues

More Swift issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.