Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
eoyilmaz committed Jan 1, 2024
2 parents e10f20f + ad6a6d9 commit 88797fa
Show file tree
Hide file tree
Showing 4 changed files with 382 additions and 144 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [2.7, 3.7, 3.8, 3.9, "3.10"]
python-version: [2.7, 3.7, 3.8, 3.9, "3.10", "3.11"]

steps:
- uses: actions/checkout@v2
Expand Down
42 changes: 20 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
About
-----

Python Module for manipulating SMPTE timecode. Supports 23.976, 23.98, 24, 25,
29.97, 30, 50, 59.94, 60 frame rates and milliseconds (1000 fps).
Python module for manipulating SMPTE timecode. Supports 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 "30001/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).
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](http://www.davidheidelberger.com/blog/?p=29).

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:
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:

```py
from timecode import Timecode

tc1 = Timecode('29.97', '00:00:00;00')
tc2 = Timecode('24', '00:00:00:10')
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:
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:

```py
tc4 = Timecode('24', '00:00:00:00')
Expand All @@ -40,10 +40,10 @@ Use the `frame_number` attribute if you want to get a 0 based frame number:
assert tc4.frame_number == 0
```

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

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

```py
tc5 = Timecode('30000/1001', '00:00:00;00')
Expand All @@ -60,8 +60,8 @@ 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:
Timecode also supports passing start timecodes formatted like HH:MM:SS.sss where SS.sss
is seconds and fractions of seconds:

```py
tc8 = Timecode(25, '00:00:00.040')
Expand All @@ -80,12 +80,10 @@ 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.

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](https://github.com/eoyilmaz/timecode)
page.
Please report any bugs to the [GitHub](https://github.com/eoyilmaz/timecode) page.

Copyright 2014 Joshua Banton and PyTimeCode developers.
6 changes: 5 additions & 1 deletion tests/test_timecode.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

@pytest.mark.parametrize(
"args,kwargs", [
[["12", "00:00:00:00"], {}],
[["23.976", "00:00:00:00"], {}],
[["23.98", "00:00:00:00"], {}],
[["24", "00:00:00:00"], {}],
Expand Down Expand Up @@ -49,6 +50,7 @@
[[(30000, 1001), "00:00:00;00"], {}],
[[(60000, 1000), "00:00:00:00"], {}],
[[(60000, 1001), "00:00:00;00"], {}],
[[12], {"frames": 12000}],
[[24], {"frames": 12000}],
[[23.976, "00:00:00:00"], {}],
[[23.98, "00:00:00:00"], {}],
Expand Down Expand Up @@ -416,7 +418,9 @@ def test_add_with_non_suitable_class_instance(args, kwargs, func, tc2):
with pytest.raises(TimecodeError) as cm:
_ = func(tc1, tc2)

assert "Type {} not supported for arithmetic.".format(tc2.__class__.__name__) == str(cm.value)
assert str(cm.value) == "Type {} not supported for arithmetic.".format(
tc2.__class__.__name__
)


def test_div_method_working_properly_1():
Expand Down
Loading

0 comments on commit 88797fa

Please sign in to comment.