Timestamp¶
- class pymkv.Timestamp(timestamp: str | int | Timestamp | None = None, hh: int | None = None, mm: int | None = None, ss: int | None = None, nn: int | None = None, form: str = 'MM:SS')¶
- extract(timestamp: str | int) None ¶
Extracts time info from a timestamp.
- timestamp (str, int):
A str of a timestamp acceptable to mkvmerge or an int representing seconds. The timing info will be extracted from this parameter.
- property form: str¶
Get the format string for the timestamp.
- Returns:
The format string.
- Return type:
str
- property hh: int¶
Get the hours component of the timestamp.
- Returns:
The hours value.
- Return type:
int
- property mm: int¶
Get the minutes component of the timestamp.
- Returns:
The minutes value.
- Return type:
int
- property nn: int¶
Get the nanoseconds component of the timestamp.
- Returns:
The nanoseconds value.
- Return type:
int
- splitting_timestamp(timestamp: str) None ¶
This method splits the given timestamp string into hours, minutes, seconds, and nanoseconds. The timestamp string should be in the format “HH:MM:SS.NNNNNNNNN”, where HH represents hours, MM represents minutes, SS represents seconds, and NNNNNNNNN represents nanoseconds.
- Parameters:
timestamp (str) – The timestamp string to be split.
- Return type:
None
Example
>>> obj = Timestamp("12:34:56.789012345") >>> print(obj) 12:34:56.789012345 >>> assert obj.hh == 12 >>> assert obj.mm == 34 >>> assert obj.ss == 56 >>> assert obj.nn == 789012345
# Assuming self._hh, self._mm, self._ss, and self._nn are all None initially The hours (self.hh) will be set to 12. The minutes (self.mm) will be set to 34. The seconds (self.ss) will be set to 56. The nanoseconds (self.nn) will be set to 789012345.
- property ss: int¶
Get the seconds component of the timestamp.
- Returns:
The seconds value.
- Return type:
int
- property ts: str¶
Generates and returns the timestamp string specified by the object.
- Returns:
A formatted timestamp string based on the object’s properties and format.
- Return type:
str
The timestamp format is determined by the ‘form’ attribute and includes hours (HH), minutes (MM), seconds (SS), and nanoseconds (NN) as applicable. The method constructs the timestamp string according to the specified format, including or omitting parts based on the format and the presence of non-zero values.
- static verify(timestamp: str) bool ¶
Verify a timestamp has the proper form to be used in mkvmerge.
- timestamp (str):
The timestamp to be verified.