props ¶
Functions:
-
get_clip_filepath–Helper function to get the file path from a clip.
-
get_prop–Get FrameProp
propfrom frameframewith expected typet. -
get_props–Get multiple frame properties from a clip.
-
merge_clip_props–Merge frame properties from all provided clips.
get_clip_filepath ¶
get_clip_filepath(
clip: VideoNode,
fallback: SPathLike | None = None,
func: FuncExcept | None = None,
) -> SPath
Helper function to get the file path from a clip.
This functions checks for the IdxFilePath frame property. It also checks to ensure the file exists, and throws an error if it doesn't.
Parameters:
-
(clip¶VideoNode) –The clip to get the file path from.
-
(fallback¶SPathLike | None, default:None) –Fallback file path to use if the
propis not found. -
(func¶FuncExcept | None, default:None) –Function returned for error handling. This should only be set by VS package developers.
Raises:
-
FileWasNotFoundError–The file path was not found.
-
FramePropError–The property was not found in the clip.
Source code in vstools/utils/props.py
270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 | |
get_prop ¶
get_prop(
obj: HoldsPropValue,
key: str | type[PropEnum],
t: type[_PropValueT],
*,
default: DT = ...,
func: FuncExcept | None = None
) -> _PropValueT | DT
get_prop(
obj: HoldsPropValue,
key: str | type[PropEnum],
t: tuple[type[_PropValueT], type[_PropValueT0]],
*,
default: DT = ...,
func: FuncExcept | None = None
) -> _PropValueT | _PropValueT0 | DT
get_prop(
obj: HoldsPropValue,
key: str | type[PropEnum],
t: tuple[type[_PropValueT], type[_PropValueT0], type[_PropValueT1]],
*,
default: DT = ...,
func: FuncExcept | None = None
) -> _PropValueT | _PropValueT0 | _PropValueT1 | DT
get_prop(
obj: HoldsPropValue,
key: str | type[PropEnum],
t: tuple[type[_PropValueT], ...],
*,
default: DT = ...,
func: FuncExcept | None = None
) -> Any | DT
get_prop(
obj: HoldsPropValue,
key: str | type[PropEnum],
t: type[_PropValueT] | tuple[type[_PropValue], ...],
cast: Callable[[_PropValueT], CT],
default: DT = ...,
func: FuncExcept | None = None,
) -> CT | DT
get_prop(
obj: HoldsPropValue,
key: str | type[PropEnum],
t: type[Any] | tuple[type[Any], ...] | Literal["Callable"],
cast: Callable[[Any], CT] | MissingT = MISSING,
default: DT | MissingT = MISSING,
func: FuncExcept | None = None,
) -> Any | CT | DT
Get FrameProp prop from frame frame with expected type t.
If the property is stored as bytes and t is str, the value will be decoded as UTF-8.
Example
assert get_prop(clip.get_frame(0), "_PictType", str) == "I"
Parameters:
-
(obj¶HoldsPropValue) –Clip or frame containing props.
-
(key¶str | type[PropEnum]) –Prop to get.
-
(t¶type[Any] | tuple[type[Any], ...] | Literal['Callable']) –Expected type of the prop (or tuple of types). Use "Callable" if expecting a callable.
-
(cast¶Callable[[Any], CT] | MissingT, default:MISSING) –Optional cast to apply to the value.
-
(default¶DT | MissingT, default:MISSING) –Fallback value if missing.
-
(func¶FuncExcept | None, default:None) –Function returned for custom error handling. This should only be set by VS package developers.
Returns:
Raises:
-
FramePropError–If the property is missing or has the wrong type and no default value is given.
Source code in vstools/utils/props.py
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 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 | |
get_props ¶
get_props(
obj: HoldsPropValue,
keys: Iterable[str | type[PropEnum]],
t: type[Any] | tuple[type[Any], ...],
cast: Callable[[Any], CT] | MissingT = MISSING,
default: Any | MissingT = MISSING,
func: FuncExcept | None = None,
) -> dict[str, Any]
Get multiple frame properties from a clip.
Parameters:
-
(obj¶HoldsPropValue) –Clip or frame containing props.
-
(keys¶Iterable[str | type[PropEnum]]) –List of props to get.
-
(t¶type[Any] | tuple[type[Any], ...]) –Expected type of the prop.
-
(cast¶Callable[[Any], CT] | MissingT, default:MISSING) –Optional cast to apply to the value.
-
(default¶Any | MissingT, default:MISSING) –Fallback value if missing or invalid.
-
(func¶FuncExcept | None, default:None) –Function returned for custom error handling. This should only be set by VS package developers.
Returns:
-
dict[str, Any]–Dictionary mapping property names to their values. Values will be of type specified by cast if provided,
-
dict[str, Any]–otherwise of the type(s) specified in
tor a default value if provided.
Source code in vstools/utils/props.py
320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 | |
merge_clip_props ¶
Merge frame properties from all provided clips.
The props of the main clip (defined by main_idx) will be overwritten, and all other props will be added to it.
Parameters:
-
(*clips¶VideoNode, default:()) –Clips which will be merged.
-
(main_idx¶int, default:0) –Index of the main clip to which all other clips props will be merged.
Returns:
-
VideoNode–First clip with all the frameprops of every other given clip merged into it.
Source code in vstools/utils/props.py
238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 | |