Timecode library for film and TV industry, supports HFR and a bunch of cool features
Project description
1. 简介 Introduction
为影视行业设计的Python时码库,支持HFR高帧率以及其他丰富的功能。
Python timecode library for film and TV industry, supports HFR and a bunch of cool features.
1.1 主要功能 Main Features
-
支持多种时码格式输入,如SMPTE、SRT、DLP(Cine Canvas)、FFMPEG、FCPX、帧号、现实时间等。
Multiple timecode format support, including SMPTE, SRT, DLP(Cine Canvas), FFMPEG, FCPX, frame count, time, etc.
-
支持高帧率,目前支持0.01-999.99fps范围内的帧率。
High frame rate support, currently support frame range from 0.01 to 999.99fps.
-
支持严格的丢帧/非丢帧SMPTE格式。
Strictly support SMPTE DF/NDF format.
-
目前支持-99到99小时时间范围。
Currently support time range from -99 to 99 hours.
-
支持严格模式,在该模式下时码会在0-24小时范围内循环,任意超出该范围的时码会自动转换至范围内。
Strict Mode support, timecode will circulate from 0 to 24 hours, any timecode outside this range will be automaticly converted to a timecode inside it.
-
内部以高精度时间戳进行存储和计算,各类FPS转换、时码格式转换输出都能保持最高精度。
Uses high precision time stamp inside for storage and calculation, any FPS conversion or format conversion output can maintain their highest precision.
-
常用运算符支持,包括时码与时码、时码与数字的各类加减乘除、比较运算。
Common operator support, including addtion, subtraction, multiplication, division and comparison operator between two timecode object or a timecode object and a number.
2. 如何安装 How to install
python pip install dftt_timecode
2.1 包依赖 Package dependency
- fractions
- logging
- math
- functools
- re
3. 使用方法说明 How to use
3.1 导入 Import
from dftt_timecode import DfttTimecode
3.2 新建时码类对象 Create timecode objects
a = DfttTimecode('01:00:00:00', 'auto', fps=24, drop_frame=False, strict=True)
#以SMPTE非丢帧时码新建对象 Create object using SMPTE NDF
a = DfttTimecode('1000f', 'auto', fps=119.88, drop_frame=True, strict=True)
#以帧数新建对象 Create object using frame count
a = DfttTimecode('3600.0s', 'auto', fps=Fraction(60000,1001), drop_frame=True, strict=True)
#以时间秒新建对象 Create object using time
a = DfttTimecode(-1200, 'auto', fps=23.976, drop_frame=False, strict=False)
#以int帧数新建对象 Create object using int frame count
对DfttTimecode()相关参数的详细说明,请查阅4.1 DfttTimecode()参数说明
。
For detailed parameters descriptions of DfttTimecode(), please refer to chapter 4.1 Parameters Descriptions of DfttTimecode()
.
3.3 操作时码类对象 Operate DfttTimecode objects
a = DfttTimecode('01:00:00:00', 'auto', fps=24, drop_frame=False, strict=True)
assert a.type == 'smpte'
assert a.fps == 24
assert a.framecount == 86400
assert a.is_drop_frame == False
assert a.is_strict == True
assert a.timecode_output('smpte',output_part=0) == '01:00:00:00'
assert a.timecode_output('srt',output_part=1) == '01'
a = DfttTimecode('25:00:01:103', 'auto', fps=120, drop_frame=False, strict=False)
a.set_fps(24)
assert a.fps == 24
assert a.timecode_output('smpte') == '25:00:01:21'
a.set_strict(strict=True)
assert a.timecode_output('smpte') == '01:00:01:21'
a.set_strict(strict=False)
assert a.is_strict == False
对时码类对象操作的详细说明,请查阅4.2 时码类对象操作说明
。
For detailed descriptions of DfttTimecode objects' operations, please refer to chapter 4.2 Descriptions of DfttTimecode class operations
.
3.4 时码类运算符 Operators of DfttTimecode class
对时码类运算符的详细说明,请查阅4.3 时码类运算符说明
For detailed descriptions of DfttTimecode's operators, please refer to chapter 4.3 Descriptions of DfttTimecode class operators
.
4 参数详细说明 Detailed Parameters Descriptions
4.1 DfttTimecode()参数说明 Parameters Descriptions of DfttTimecode()
4.1.1 参数一览 General Descriptions
a = DfttTimecode(timecode_value, timecode_type, fps, drop_frame, strict)
-
**
timecode_value
**是时码对象的时码值,可以是str
、int
、float
、tuple
、list
、Fraction
类型。timecode_value
is the value of a timecode, it can be astr
,int
,float
,tuple
,list
or aFraction
. -
**
timecode_type
**是时码对象的类型,是str
类型,目前支持的时码类型包括auto
、smpte
、srt
、ffmpeg
、fcpx
、frame
、time
。timecode_type
must be astr
, currently supported timecode types includeauto
,smpte
,srt
,ffmpeg
,fcpx
,frame
,time
. -
**
fps
**是时码对象的帧率,可以是int
、float
、Fraction
类型。fps
is the frame rate of the timecode object, can be aint
,float
or aFraction
. -
**
drop_frame
是时码对象的丢帧设置,是bool
类型,只有当帧率存在丢帧格式时,这一设置才会生效,否则会强制将丢帧设为False
。drop_frame
**的默认值是False
。drop_frame
must be abool
, a timecode object can only be drop-frameable under spcific frame rate settings, if not so,drop_frame
will be forced toFalse
. The default value ofdrop_frame
isFalse
. -
**
strict
**为时码对象设置严格模式,是bool
类型。设为True
后,负值和超过24小时的时码都将被转换为0-24小时范围内的值,例如25:00:00:00
将被转换为01:00:00:00
,-01:00:00:00
将被转换为23:00:00:00
。strict
will set strict mode for a timecode object, it must be abool
. When set toTrue
, negative timecode value and timecode value over 24 hours will be converted to a value inside range 0 to 24 hours. For example, 25:00:00:00 will be converted to 01:00:00:00, -01:00:00:00 will be converted to 23:00:00:00.
4.1.2 timecode_value
4.1.3 timecode_type
4.1.4 fps
4.1.5 drop_frame
4.1.6 strict
4.1.7 补充说明 Additional info
4.2 时码类对象操作说明 Descriptions of DfttTimecode class operations
4.2.1 self.type
4.2.2 self.fps
4.2.3 self.framecount
4.2.4 self.is_drop_frame
4.2.5 self.is_strict
4.2.6 self.set_fps()
4.2.7 self.set_type()
4.2.8 self.set_strict()
4.3 时码类运算符说明 Descriptions of DfttTimecode class operators
4.3.1 __repr__()
4.3.2 +
4.3.3 -
4.3.4 *
4.3.5 /
4.3.6 =
4.3.7 !=
4.3.8 >
4.3.9 >=
4.3.10 <
4.3.11 <=
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file dftt_timecode-0.0.8.tar.gz
.
File metadata
- Download URL: dftt_timecode-0.0.8.tar.gz
- Upload date:
- Size: 23.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 749baa4db0c1a3a5341b188c79ed3c67f29c8cb739553da101f3e13eb5b4000c |
|
MD5 | b7f97c6c1d3c626ce47b9140478e99e5 |
|
BLAKE2b-256 | 0e7cecf9351d4a678807e3ffb2941bebc14043ba5cf3081b6d404ef614f053e8 |
Provenance
File details
Details for the file dftt_timecode-0.0.8-py3-none-any.whl
.
File metadata
- Download URL: dftt_timecode-0.0.8-py3-none-any.whl
- Upload date:
- Size: 21.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c2c0f5a2c9b4311ed15e661fff1dfdcb59fd654abdbd7b7df89cb54d6e6b5bf2 |
|
MD5 | 226e643114d92ba2f94c8fac224525df |
|
BLAKE2b-256 | 0d74a563002b15edb2f7ca728e810a79133e9625e61d5bbed506113748612539 |