convert
ExtrapolatingVideoTimestamps
Bases: VideoTimestamps
Simple class extending VideoTimestamps to add back extrapolation for frames past the video.
This works by getting the average framerate from the existing timestamps and assuming CFR from then on.
Source code in
muxtools/utils/convert.py
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
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 | |
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 |