MKV block timestamps are read as unsigned and ignore TimestampScale

Open
#84 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
48/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
swift
Domain
backend

Research direction

Start by locating readFixedLengthNumber, calculateAbsolutePTS, and encodePTSForPGS, then trace where Segment Info is parsed and how timestamps flow from MKV blocks into PGS encoding. Check the existing timestamp parsing tests, if present. Done means negative relative timestamps, the Segment Info TimestampScale, and timestamps beyond about 13.25 hours are handled without trapping.

Written by the indexing model from the issue text.

Description

bug
  • The block's relative timestamp is a signed 16-bit integer, but readFixedLengthNumber reads it unsigned, so negative relative timestamps become ~+65 s, and calculateAbsolutePTS's UInt64(...) traps on a negative sum.
  • Segment Info TimestampScale is ignored; 1 ms is hard-coded (* 90).
  • encodePTSForPGS does UInt32(timestamp), which traps past about 13.25 h.

Fix: sign-extend the block timestamp, read TimestampScale from Segment Info, and handle wraparound instead of trapping.

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.