Skip to content

Commit

Permalink
Merge pull request #16 from WheheoHu/WheheoHu/issue9
Browse files Browse the repository at this point in the history
Fixes #9 and More
  • Loading branch information
OwenYou authored Oct 19, 2024
2 parents 3f2c771 + bfe4586 commit 79f0e5d
Show file tree
Hide file tree
Showing 9 changed files with 186 additions and 196 deletions.
Binary file removed .DS_Store
Binary file not shown.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ __pycache__
dftt_timecode.egg-info
.pytest_cache
.DS_Store
playground.ipynb
20 changes: 20 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,23 @@ First Public Release.
This bug will cause error when using strings like `'00:00:27:183'` to initilize a dlp timecode object.


V0.0.13 changelog
## V0.0.13
重构 Refactor:
- 使用`f-string`处理字符串格式输出

Handling string format output using `f-string`

- 重构时间码输出函数,减少代码重复

Refactor the time code output function to reduce code duplication

添加 Add:
- 添加`get_audio_sample_count` 方法用于正确输出TC时间戳下的音频采样数, 解决issue [#9](https://github.com/OwenYou/dftt_timecode/issues/9)

Add `get_audio_sample_count` method for correctly outputting the count of audio samples at TC timestamps,solve issue [#9](https://github.com/OwenYou/dftt_timecode/issues/9)

弃用 Deprecate:
- 使用`functools.singledispatchmethod` 代替 `dispatch.InstanceMethodDispatch`

Use`functools.singledispatchmethod` instead of `dispatch.InstanceMethodDispatch`
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -591,3 +591,4 @@ int(tc_a)
#864000
```

#TODO TimeRange readme
4 changes: 2 additions & 2 deletions dftt_timecode/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name = 'dftt_timecode'
__author__ = 'You Ziyuan'
__version__ = '0.0.12'
__version__ = '0.0.13'

from dftt_timecode.core import DfttTimecode
from dftt_timecode.core.dftt_timecode import DfttTimecode
316 changes: 141 additions & 175 deletions dftt_timecode/core.py → dftt_timecode/core/dftt_timecode.py

Large diffs are not rendered by default.

12 changes: 0 additions & 12 deletions dftt_timecode/error.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,4 @@ class DFTTTimecodeTypeError(DFTTError):
class DFTTTimecodeOperatorError(DFTTError):
pass

class DFTTTimeRangeMethodError(DFTTError):
pass

class DFTTTimeRangeValueError(DFTTError):
pass

class DFTTTimeRangeTypeError(DFTTError):
pass

class DFTTTimeRangeFPSError(DFTTError):
pass


6 changes: 3 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import setuptools

import dftt_timecode as package
with open("README.md", "r",encoding='UTF-8') as fh:
long_description = fh.read()

setuptools.setup(
name="dftt_timecode",
version="0.0.12",
name=package.name,
version=package.__version__,
author="You Ziyuan",
author_email="[email protected]",
description="Timecode library for film and TV industry, supports HFR and a bunch of cool features",
Expand Down
22 changes: 18 additions & 4 deletions test/test_dftt_timecode.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,8 @@ def test_auto_type(timecode_value, timecode_type, fps, drop_frame, strict, resul
"timecode_value, timecode_type, fps, drop_frame, strict",
[
('01:00:00:23', 'smpte', 20, False, True),
('00:01:00;00', 'smpte', 23.97, False, True),
],
ids=['smpte', 'smpte_df']
ids=['smpte']
)
def test_invalid_timecode(timecode_value, timecode_type, fps, drop_frame, strict):
from dftt_timecode.error import DFTTTimecodeValueError
Expand Down Expand Up @@ -182,8 +181,11 @@ def test_set_strict(set_strict_data):

@pytest.mark.parametrize(argnames="timecode_value, timecode_type, fps, drop_frame, strict,output_smpte,output_frame,output_time,output_srt,output_fcpx,output_ffmpeg",
argvalues=[('00:00:01:00', 'auto', 24, False, True, '00:00:01:00',
'24', '1.0', '00:00:01,000', '1s', '00:00:01.00'), ],
ids=['smpte'])
'24', '1.0', '00:00:01,000', '1s', '00:00:01.00'),
('00:10:00;00', 'auto', 29.97, True, True, '00:10:00;00',
'17982', '600.0', '00:10:00,000', '600s', '00:10:00.00'),
],
ids=['NDF','DF'])
def test_timecode_output(timecode_value, timecode_type, fps, drop_frame, strict, output_smpte, output_frame, output_time, output_srt, output_fcpx, output_ffmpeg):
tc = TC(timecode_value, timecode_type, fps, drop_frame, strict)
assert tc.timecode_output() == timecode_value
Expand Down Expand Up @@ -554,3 +556,15 @@ def test_int(tc_value,xvalue):
tc=TC(*tc_value)
assert int(tc) == xvalue


@pytest.mark.parametrize(
argnames="tc_value,sample_rate,xvalue",
argvalues=[(('00:00:01:00', 'auto', 24, False, True),48000,48000),
(('00:00:01:01', 'auto', 24, False, True),48000,50000),
(('00:00:01:01', 'auto', 24, False, True),44100,45937),
],
ids=['ideal','single_frame','24fps_44100']
)
def test_audio_sample_count(tc_value,sample_rate,xvalue):
tc=TC(*tc_value)
assert tc.get_audio_sample_count(sample_rate) == xvalue

0 comments on commit 79f0e5d

Please sign in to comment.