Skip to content

v0.2.0 — iTT parser + writer

Choose a tag to compare

@SteliyanH SteliyanH released this 30 Apr 06:52
· 21 commits to main since this release

Adds the third common caption format. Parses and authors iTunes Timed Text (.itt) — Apple's flavor of TTML 1.0, used by Final Cut, iTunes / Apple TV submission, and broadcast deliverables.

What's new

import Kadr
import KadrCaptions

let cues = try await Caption.load(ittURL)  // auto-detect now handles .srt / .vtt / .itt
let video = Video {
    VideoClip(url: footage)
}
.captions(cues)

try await CaptionAuthor.writeITT(cues, to: outputITT)
  • `Caption.load(itt:)` + `CaptionParser.parseITT(_:)` — Foundation `XMLParser`-based; no third-party deps.
  • `CaptionAuthor.writeITT(_:to:)` + `renderITT(_:)` — minimal valid TTML 1.0 with Apple-compatible header (`xmlns` + `ttp:frameRate=30` + `ttp:tickRate=1000`).
  • `Caption.load(_:)` auto-detect now recognizes `.itt` alongside `.srt` / `.vtt`.
  • `CaptionParser.parseITTTime(_:frameRate:)` — handles `HH:MM:SS.mmm`, `HH:MM:SS:FF` (frame-count, approximated at the document's declared `ttp:frameRate` or 30 fps fallback), `1.5s`, `1500ms`, plain seconds.
  • New error case `CaptionParseError.malformedXML(localizedDescription:)` for XML structural failures.

Cue mapping

  • Each `

    ` inside `

    ` → one `Caption`
  • `
    ` → `\n`
  • Inline `` styling flattened to plain text (the v0.3 `TextOverlay` bridge handles styled output)
  • Multiple `
    ` blocks concatenate
  • `tt:` prefix on `begin` / `end` attributes tolerated

Compatibility

  • Requires kadr ≥ 0.9.2 (unchanged).
  • iOS 16+ / macOS 13+ / tvOS 16+ / visionOS 1+, Swift 6.0.
  • No third-party dependencies. Pure Swift + Foundation + CoreMedia.
  • Pure additive — every v0.1 composition compiles unchanged.

Tests

Suite: 63 → 98 (+35).

What's next

  • v0.3.0 — Styled captions → `TextOverlay` + `textAnimation` bridge
  • v0.4.0 — ASS / SSA support

Full notes in CHANGELOG.md.