
SwiftTimecode
The most robust, precise and complete multi-platform Swift library for working with SMPTE/EBU timecode.
Supports 23 industry-standard timecode frame rates with a suite of conversions, calculations and integrations with Apple AV frameworks.
Timecode is a broadcast and post-production standard for addressing video frames. It is often used for video burn-in timecode (BITC), and display in a DAW (Digital Audio Workstation) or video playback/editing applications.
Supported Timecode Frame Rates
The following timecode rates and formats are supported:
| Film / ATSC / HD |
PAL / SECAM / DVB / ATSC |
NTSC / ATSC / PAL-M |
NTSC Non-Standard |
ATSC / HD |
| 23.976 |
25 |
29.97 |
30 DF |
30 |
| 24 |
50 |
29.97 DF |
60 DF |
60 |
| 24.98 |
100 |
59.94 |
120 DF |
90 |
| 47.952 |
|
59.94 DF |
|
120 |
| 48 |
|
119.88 |
|
|
| 95.904 |
|
119.88 DF |
|
|
| 96 |
|
|
|
|
Supported Video Frame Rates
The following video frame rates are supported:
| Film / HD |
PAL |
NTSC |
| 23.98p |
25p / 25i |
29.97p / 29.97i |
| 24p |
50p / 50i |
30p |
| 47.95p |
100p |
59.94p / 59.94i |
| 48p |
|
60p / 60i |
| 95.9p |
|
90p |
| 96p |
|
119.88p |
|
|
120p |
Core Features
- Convert timecode to/from:
- timecode display string
- total elapsed frame count
- real wall-clock time
- elapsed audio samples at any audio sample rate
- rational time notation (such as
CMTime or Final Cut Pro XML and AAF encoding)
- feet + frames
- Support for Days as a timecode component (some DAWs including Cubase support > 24 hour timecode)
- Support for Subframes
- Math operations: add, subtract, multiply, divide
- Granular timecode validation
- Form a
Range or Stride between two timecode instances
- Conforms to
Codable
- Formatters
- A
Formatter object that can format timecode
- An
AttributedString showing invalid timecode components using alternate attributes (such as red text color)
- SwiftUI Views
- A timecode entry text field
- A timecode string
Text view emphasizing invalid timecode components using alternate attributes (such as red text color)
AVAsset video file utilities to easily read/write timecode tracks and locate AVPlayer to timecode locations
- Exhaustive unit tests ensuring accuracy
Compatibility
The Core package target is supported on the following platforms:
| macOS |
iOS |
tvOS |
visionOS |
watchOS |
Linux |
Android |
WASM |
Windows |
| 🟢 |
🟢 |
🟢 |
🟢 |
🟢 |
🟢 |
🟢 |
🟢[^1] |
🚧[^2] |
A/V and UI package targets are supported on the following platforms:
| macOS |
iOS |
tvOS |
visionOS |
watchOS |
Linux |
Android |
WASM |
Windows |
| 🟢 |
🟢 |
🟢 |
🟢 |
🟢 |
- |
- |
- |
- |
[^1]: Cross-compiling using the WASM SDK on macOS requires using a standard Swift toolchain due to a compiler bug in the Swift toolchain that comes bundled in Xcode 26.
[^2]: Support for indicated platforms is either planned or WIP.
Getting Started
This extension is available as a Swift Package Manager (SPM) package.
Add the swift-timecode repo as a dependency.
.package(url: "https://github.com/orchetect/swift-timecode", from: "3.1.4")
Add SwiftTimecode to your target.
.product(name: "SwiftTimecode", package: "swift-timecode")
Import the entire library:
// on Apple platforms, imports Core/AV/UI.
// on Linux, Android and WASM, imports Core.
import SwiftTimecode
Or import individual targets as-needed:
import SwiftTimecodeCore // core value types
import SwiftTimecodeAV // AVFoundation extensions (Apple platforms only)
import SwiftTimecodeUI // UI components (Apple platforms only)
Documentation
See the online documentation for library usage and getting started info.
Also check out the Examples folder for sample code to see SwiftTimecode in action.
References
Author
Coded by a bunch of 🐹 hamsters in a trenchcoat that calls itself @orchetect.
License
Licensed under the MIT license. See LICENSE for details.
Sponsoring
If you enjoy using SwiftTimecode and want to contribute to open-source financially, GitHub sponsorship is much appreciated. Feedback and code contributions are also welcome.
Community & Support
Please do not email maintainers for technical support. Several options are available for issues and questions:
- Questions and feature ideas can be posted to Discussions.
- If an issue is a verifiable bug with reproducible steps it may be posted in Issues.
Contributions
Contributions are welcome. Posting in Discussions first prior to new submitting PRs for features or modifications is encouraged.
Code Quality & AI Contribution Policy
In an effort to maintain a consistent level of code quality and safety, this repository was built by hand and is maintained without the use of AI code generation.
AI-assisted contributions are welcome, but must remain modest in scope, maintain the same degree of quality and care, and be thoroughly vetted before acceptance.
Legacy
This repository was formerly known as TimecodeKit.