Utility Functions

ptsl Utilities - Utility functions for working with types

Working With Timecode and Footage

ptsl.util.timecode_info(session_rate: <google.protobuf.internal.enum_type_wrapper.EnumTypeWrapper object at 0x7af6f9959b50>) Tuple[Fraction, bool]

For the given SessionTimeCodeRate enumeration value, returns a library-agnostic description that can be used for time arithmetic.

The first element in the return tuple is the duration of a frame in the given session_rate as a fractional number of seconds. The second element is a bool which is True if the session_rate is drop-frame.

Parameters:

session_rate – The session rate value.

Returns:

a Tuple of (frame duration, is drop frame)

ptsl.util.feet_frames_info(feet_frames_rate: <google.protobuf.internal.enum_type_wrapper.EnumTypeWrapper object at 0x7af6f995a290>) Fraction

For the given SessionFeetFramesRate enumeration value, returns a library-agnostic description that can be used for time arithmetic.

Parameters:

feet_frames_rate – The session feet+frames rate value.

Returns:

The duration of a frame in the given rate, as a fractional number

of seconds.

Working With Sample Rates and Pull Rates

ptsl.util.sample_rate_info(sample_rate: <google.protobuf.internal.enum_type_wrapper.EnumTypeWrapper object at 0x7af6f9913bd0>) int | None

Get the sample rate for a SampleRate as an integer.

Note

The SR_None value will be returned as a None

ptsl.util.sample_rate_enum(sample_rate: int | None) <google.protobuf.internal.enum_type_wrapper.EnumTypeWrapper object at 0x7af6f9913bd0>

Get the symbolic sample rate from the SampleRate enum from an integer.

Note

A sample_rate not in the enumeration will be returned as SR_None

ptsl.util.pull_rate_info(rate_pull: <google.protobuf.internal.enum_type_wrapper.EnumTypeWrapper object at 0x7af6f995a4d0>) Tuple[int, int]

For the given SessionRatePull enumeration value, returns a library-agnostic description that can be used for time arithmetic.

Returns a Tuple where retval[0] can be multiplied by 4% to give the 4% pull value (as when converting 24fps and 25fps playback), and retval[1] can be multiplied by 0.1% to give the 0.1% pull value (as when converting NTSC to integral frame rates).

Parameters:

rate_pull – The rate pull.

Returns:

A Tuple of (int, int)