convert
format_timedelta(time, precision=3)
Formats a timedelta to hh:mm:ss.s[*precision] and pads with 0 if there aren't more numbers to work with. Mostly to be used for ogm/xml files.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
time
|
timedelta
|
The timedelta |
required |
precision
|
int
|
3 = milliseconds, 6 = microseconds, 9 = nanoseconds |
3
|
Returns:
Type | Description |
---|---|
str
|
The formatted string |
Source code in muxtools/utils/convert.py
get_timemeta_from_video(video_file, out_file=None, caller=None)
Parse timestamps from an existing video file using ffprobe.
They're saved as a custom meta file in the current workdir and named based on the input.
Also automatically reused (with a debug log) if already exists.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
video_file
|
PathLike
|
Input video. Path or String. |
required |
out_file
|
PathLike | None
|
Output file. If None given, the above behavior applies. |
None
|
caller
|
Any | None
|
Caller used for the logging |
None
|
Returns:
Type | Description |
---|---|
VideoMeta
|
Videometa object |
Source code in muxtools/utils/convert.py
resolve_timesource_and_scale(timesource=None, timescale=None, rounding_method=RoundingMethod.ROUND, allow_warn=True, fetch_from_setup=False, caller=None)
Instantiates a timestamps class from various inputs.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
timesource
|
PathLike | Fraction | float | list[int] | VideoMeta | ABCTimestamps | None
|
The source of timestamps/timecodes. For actual timestamps, this can be a timestamps (v1/v2/v4) file, a muxtools VideoMeta json file, a video file or a list of integers. For FPS based timestamps, this can be a Fraction object, a float or even a string representing a fraction. Like |
None
|
timescale
|
TimeScale | Fraction | int | None
|
Unit of time (in seconds) in terms of which frame timestamps are represented. While you can pass an int, the needed type is always a Fraction and will be converted via |
None
|
rounding_method
|
RoundingMethod
|
The rounding method used to round/floor the PTS (Presentation Time Stamp). |
ROUND
|
allow_warn
|
bool
|
Allow this function to print warnings. If you know what you're doing feel free to disable this for your own use. |
True
|
fetch_from_setup
|
bool
|
Whether or not this function should fallback to the sub defaults from the current Setup. |
False
|
caller
|
Any | None
|
Caller used for the logging |
None
|
Returns:
Type | Description |
---|---|
ABCTimestamps
|
Instantiated timestamps object from the videotimestamps library |
Source code in muxtools/utils/convert.py
timedelta_from_formatted(formatted)
Parses a string with the format of hh:mm:ss.sss Mostly to be used for ogm/xml files.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
formatted
|
str
|
The timestamp string |
required |
Returns:
Type | Description |
---|---|
timedelta
|
The parsed timedelta |