dayu_timecode
Timecode 的计算库。针对影视行业常见的各种timecode、frame 进行计算。有下面的特点:
支持SMPTE NDF、SMPTE DF、DLP、SRT、FFMPEG、FCPX 多种格式的timecode
目前支持到 fps=60 的高帧速率
支持hour loop 和 负数时间
timecode、frame 之间自由转换
支持和其他常用的数字类型进行运算,无需转换(int、float、Fraction)
如何安装
直接使用pip 即可安装
pip install -U dayu_timecode
DayuTimeCode 使用简介
from dayu_timecode import DayuTimeCode
# 针对各种输入,进行初始化
smpte_ndf_tc = DayuTimeCode('01:02:03:12', fps=24.0)
smpte_df_tc = DayuTimeCode('01:09:00;02', fps=29.97)
srt_tc = DayuTimeCode('00:00:03,245', fps=25.0)
dlp_tc = DayuTimeCode('01:12:22:136', fps=24.0)
ffmpeg_tc = DayuTimeCode('00:02:12.24', fps=24.0)
fcpx_tc = DayuTimeCode('1/24s', fps=24.0)
frame_int_tc = DayuTimeCode(100, fps=25.0)
frame_long_tc = DayuTimeCode(86400.2, fps=24.0)
time_tc = DayuTimeCode([24, 3], fps=24.0)
# 时码、帧数转换
assert smpte_ndf_tc.timecode() == '01:02:03:12'
assert smpte_ndf_tc.frame() == 89364.00
# 得到时码中 小时、分钟、秒、帧数的分量
assert smpte_ndf_tc.hour == 1
assert smpte_ndf_tc.minute == 2
assert smpte_ndf_tc.second == 3
assert smpte_ndf_tc.sub_frame == 12
a = DayuTimeCode('01:02:03:12', fps=24.0)
b = DayuTimeCode(86400.2, fps=24.0)
# 加法、减法、乘法、除法
print a + b # <DayuTimeCode>(02:02:03:12, 175764.20, 24.00)
print a - b # <DayuTimeCode>(00:02:03:12, 2963.80, 24.00)
print a * 3 # <DayuTimeCode>(03:06:10:12, 268092.00, 24.00)
print a / 2 # <DayuTimeCode>(00:31:01:18, 44682.00, 24.00)
# 各种比较方式
print a == b
print a > b
print a >= b
print a < b
print a <= b
print a != b
# 类型转换
print float(a)
print int(a)
# 变速(指定一个起点,以及变速的速度)
start_tc = DayuTimeCode(0)
print a.retime(start_tc, 2.0) # 表示从0 开始,两倍速播放后的timecode
DayuTimeRange 使用简介
DayuTimeRange 由两个DayuTimeCode 组成的一个时间区域。
# 初始化
start = DayuTimeCode(0)
end = DayuTimeCode(100)
time_range = DayuTimeRange(start, end)
# zero_length_range = DayuTimeRange(DayuTimeCode(10), DayuTimeCode(10)) # 会出错,因为start 和end 都是同一个时间
# 访问属性
print time_range.start # 起点
print time_range.end # 终点
print time_range.duration.frame() # 获得 frame 长度
print len(time_range) # 获得 frame 长度的另一种方法
# 加法、减法、乘法、除法
print time_range + 10 # 表示整个time_range 向右移动 10 frame
print time_range - 20 # 表示整个time_range 向左移动 20 frame
print time_range * 2 # 表示整个time_range 起点不动,长度变成原来的 2 倍
print time_range / 3 # 表示整个time_range 起点不动,长度变成原来的 三分之一
# 处理handle
time_range.handle(10, 10) # 表示time_range 的start 向左增加 10 frame,end 向右增加 10 frame
# 切镜头处理
cut_point = DayuTimeCode(20)
print time_range.cut(cut_point) # 得到两个区域 (0 - 20), (20 - 100)
# 判断timecode 或者一个time range 是否在当前timerange 的内部
sample_tc = DayuTimeCode(20)
sample_time_range = DayuTimeRange(DayuTimeCode(30), DayuTimeCode(70))
assert sample_tc in time_range
assert sample_time_range in time_range
# 两个DayuTimeRange 之间的交集、并集、差异 运算
a = DayuTimeRange(DayuTimeCode(0), DayuTimeCode(100))
b = DayuTimeRange(DayuTimeCode(50), DayuTimeCode(150))
print a & b # 二者之间交叠的部分 (50 - 100)
print a | b # 二者的并集运算 (0 - 150)
print a ^ b # 二者的差异运算 (0 - 50), (100 - 150)
# 遍历time range 内的所有时码
for tc in time_range:
print tc # 会逐一打印 从 DayuTimeCode(0) ~ DayuTimeCode(99)
Metadata
Release files for dayu-timecode 0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| dayu_timecode-0.2.tar.gz | 12.4 kB | Without provenance | Details for dayu_timecode-0.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| dayu_timecode-0.2-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details for dayu_timecode-0.2-py2.py3-none-any.whl |
Total release size: 25.5 kB
Release files / dayu_timecode-0.2.tar.gz
| Download URL | dayu_timecode-0.2.tar.gz |
|---|---|
| Size | 12.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ec98f2df075407f02bda12469e7ae577d52c477451d7588e3dd9e25e02d493cf
|
|
BLAKE2b-256 checksum How to use checksums |
489acdb5e46a12bdcdbe38e01564509769336ce826931eb5414ce4eaa6a84255
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/39.2.0 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/2.7.15
|
Release files / dayu_timecode-0.2-py2.py3-none-any.whl
| Download URL | dayu_timecode-0.2-py2.py3-none-any.whl |
|---|---|
| Size | 13.1 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
f850258872f77771589786e109725b0479c1d08914f82db54f667227a72cdda0
|
|
BLAKE2b-256 checksum How to use checksums |
ff0103afa8b84833efca6ecaab16d50b5bb83115fe20409d9e76c4057ace8a61
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/39.2.0 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/2.7.15
|
Security for dayu-timecode 0.2
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.