Skip to main content

license pyversion pypiversion wheel

About

Python module for manipulating SMPTE timecode. Supports all formats in the ST12 standard, as well as any arbitrary integer frame rates and some default str values of 23.976, 23.98, 24, 25, 29.97, 30, 50, 59.94, 60 frame rates and milliseconds (1000 fps) and fractional frame rates like "30000/1001".

This library is a fork of the original PyTimeCode python library. You should not use the two library together (PyTimeCode is not maintained and has known bugs).

The math behind the drop frame calculation is based on the blog post of David Heidelberger.

Simple math operations like, addition, subtraction, multiplication or division with an integer value or with a timecode is possible. Math operations between timecodes with different frame rates are supported. So:

from timecode import Timecode

tc1 = Timecode('29.97', '00:00:00;00')
tc2 = Timecode(24, '00:00:00:10')
tc3 = tc1 + tc2
assert tc3.framerate == '29.97'
assert tc3.frames == 12
assert tc3 == '00:00:00:11'

Creating a Timecode instance with a start timecode of '00:00:00:00' will result a timecode object where the total number of frames is 1. So:

tc4 = Timecode('24', '00:00:00:00')
assert tc4.frames == 1

Use the frame_number attribute if you want to get a 0 based frame number:

assert tc4.frame_number == 0

Frame rates 29.97, 59.94 and 119.88 are always drop frame, and all the others are non drop frame.

The timecode library supports fractional frame rates passed as a string:

tc5 = Timecode('30000/1001', '00:00:00;00')
assert tc5.framerate == '29.97'

You may also pass a big "Binary Coded Decimal" integer as start timecode:

tc6 = Timecode('24', 421729315)
assert repr(tc6) == '19:23:14:23'

This is useful for parsing timecodes stored in OpenEXR's and extracted through OpenImageIO for instance.

Timecode also supports passing start timecodes formatted like HH:MM:SS.sss where SS.sss is seconds and fractions of seconds:

tc8 = Timecode(25, '00:00:00.040')
assert tc8.frame_number == 1

You may set any timecode to be represented as fractions of seconds:

tc9 = Timecode(24, '19:23:14:23')
assert repr(tc9) == '19:23:14:23'

tc9.set_fractional(True)
assert repr(tc9) == '19:23:14.958'

Fraction of seconds is useful when working with tools like FFmpeg.

The SMPTE standard limits the timecode with 24 hours. Even though, Timecode instance will show the current timecode inline with the SMPTE standard, it will keep counting the total frames without clipping it.

Please report any bugs to the GitHub page.

Copyright 2014 Joshua Banton and PyTimeCode developers.

Metadata

Release files for timecode 1.5.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for timecode 1.5.1
File Size Uploaded Provenance Actions
timecode-1.5.1.tar.gz 25.7 kB Without provenance Details for timecode-1.5.1.tar.gz

Release files / timecode-1.5.1.tar.gz

Download URL timecode-1.5.1.tar.gz
Size 25.7 kB
Tags Source
SHA-256 checksum
How to use checksums
1455d085c1a1bb00fcea2d282867e25f4c8fce11432ed607cb5a16234eb4fa3c
BLAKE2b-256 checksum
How to use checksums
c6c975cd6c30198fade489d35bd628222714543bd646fea7215539f8c392080c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.5

Security for timecode 1.5.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page