utils ¶
Functions:
-
freeze_replace_squaremask
– -
max_planes
– -
normalize_mask
– -
region_abs_mask
–Generates a mask that defines a rectangular region within the clip, replacing pixels inside or outside the region,
-
region_rel_mask
–Generates a mask that defines a rectangular region within the clip, replacing pixels inside or outside the region,
-
rekt_partial
–Creates a rectangular mask to apply fixes only within the masked area,
-
replace_squaremask
–Replace an area of the frame with another clip using a simple square mask.
-
squaremask
–Create a square used for simple masking.
RegionMask ¶
RegionMask(func: Callable[P, R])
Bases: Generic[P, R]
Class decorator that wraps region_rel_mask and region_abs_mask function and extends their functionality.
It is not meant to be used directly.
Methods:
-
__call__
–
Attributes:
Source code
73 74 |
|
RektPartial ¶
RektPartial(rekt_partial: Callable[P, R])
Bases: Generic[P, R]
Class decorator that wraps the rekt_partial function and extends its functionality.
It is not meant to be used directly.
Methods:
Source code
387 388 |
|
__call__ ¶
__call__(*args: args, **kwargs: kwargs) -> R
Source code
390 391 |
|
abs ¶
abs(
clip: VideoNode,
func: Callable[Concatenate[VideoNode, P0], VideoNode],
width: int,
height: int,
offset_x: int = 0,
offset_y: int = 0,
*args: args,
**kwargs: kwargs
) -> ConstantFormatVideoNode
Creates a rectangular mask to apply fixes only within the masked area, significantly speeding up filters like anti-aliasing and scaling.
Parameters:
-
clip
¶VideoNode
) –The source video clip to which the mask will be applied.
-
func
¶Callable[Concatenate[VideoNode, P0], VideoNode]
) –The function to be applied within the masked area.
-
width
¶int
) –The width of the rectangular mask.
-
height
¶int
) –The height of the rectangular mask.
-
offset_x
¶int
, default:0
) –The horizontal offset of the mask from the top-left corner, defaults to 0.
-
offset_y
¶int
, default:0
) –The vertical offset of the mask from the top-left corner, defaults to 0.
Returns:
-
ConstantFormatVideoNode
–A new clip with the applied mask.
Source code
396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 |
|
rel ¶
rel(*args: args, **kwargs: kwargs) -> R
Source code
393 394 |
|
freeze_replace_squaremask ¶
freeze_replace_squaremask(
mask: VideoNode,
insert: VideoNode,
mask_params: tuple[int, int, int, int],
frame: int,
frame_range: tuple[int, int],
) -> ConstantFormatVideoNode
Source code
315 316 317 318 319 320 321 322 323 324 325 326 |
|
max_planes ¶
max_planes(
*_clips: VideoNode | Iterable[VideoNode], resizer: KernelLike = Bilinear
) -> ConstantFormatVideoNode
Source code
51 52 53 54 55 56 57 58 59 60 61 62 |
|
normalize_mask ¶
normalize_mask(mask: VideoNode, clip: VideoNode) -> ConstantFormatVideoNode
normalize_mask(
mask: Callable[[VideoNode, VideoNode], VideoNode],
clip: VideoNode,
ref: VideoNode,
) -> ConstantFormatVideoNode
normalize_mask(
mask: EdgeDetectT | RidgeDetectT,
clip: VideoNode,
*,
ridge: bool = ...,
**kwargs: Any
) -> ConstantFormatVideoNode
normalize_mask(
mask: GeneralMask, clip: VideoNode, ref: VideoNode
) -> ConstantFormatVideoNode
normalize_mask(
mask: GenericMaskT,
clip: VideoNode,
ref: VideoNode | None = ...,
*,
ridge: bool = ...,
**kwargs: Any
) -> ConstantFormatVideoNode
normalize_mask(
mask: GenericMaskT,
clip: VideoNode,
ref: VideoNode | None = None,
*,
ridge: bool = False,
**kwargs: Any
) -> ConstantFormatVideoNode
Source code
355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 |
|
region_abs_mask ¶
region_abs_mask(
clip: VideoNode,
width: int,
height: int,
left: int = 0,
top: int = 0,
replace_in: SupportsString | None = None,
replace_out: SupportsString | None = None,
planes: PlanesT = None,
func: FuncExceptT | None = None,
) -> ConstantFormatVideoNode
Generates a mask that defines a rectangular region within the clip, replacing pixels inside or outside the region, using absolute coordinates.
Parameters:
-
clip
¶VideoNode
) –Input clip.
-
width
¶int
) –The width of the region.
-
height
¶int
) –The height of the region.
-
left
¶int
, default:0
) –Specifies how many pixels to crop from the left side. Defaults to 0.
-
top
¶int
, default:0
) –Specifies how many pixels to crop from the top side. Defaults to 0.
-
replace_in
¶SupportsString | None
, default:None
) –Pixel value or expression to fill inside the region. Defaults to using the original pixel values.
-
replace_out
¶SupportsString | None
, default:None
) –Pixel value or expression to fill outside the region. Defaults to the lowest possible values per plane.
-
planes
¶PlanesT
, default:None
) –Which planes to process. Defaults to all.
-
func
¶FuncExceptT | None
, default:None
) –Function returned for custom error handling. This should only be set by VS package developers.
Returns:
-
ConstantFormatVideoNode
–A new clip with the specified rectangular region masked in or out.
Source code
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 |
|
region_rel_mask ¶
region_rel_mask(
clip: VideoNode,
left: int = 0,
right: int = 0,
top: int = 0,
bottom: int = 0,
replace_in: SupportsString | None = None,
replace_out: SupportsString | None = None,
planes: PlanesT = None,
func: FuncExceptT | None = None,
) -> ConstantFormatVideoNode
Generates a mask that defines a rectangular region within the clip, replacing pixels inside or outside the region, using relative coordinates.
Parameters:
-
clip
¶VideoNode
) –Input clip.
-
left
¶int
, default:0
) –Specifies how many pixels to crop from the left side. Defaults to 0.
-
right
¶int
, default:0
) –Specifies how many pixels to crop from the right side. Defaults to 0.
-
top
¶int
, default:0
) –Specifies how many pixels to crop from the top side. Defaults to 0.
-
bottom
¶int
, default:0
) –Specifies how many pixels to crop from the bottom side. Defaults to 0.
-
replace_in
¶SupportsString | None
, default:None
) –Pixel value or expression to fill inside the region. Defaults to using the original pixel values.
-
replace_out
¶SupportsString | None
, default:None
) –Pixel value or expression to fill outside the region. Defaults to the lowest possible values per plane.
-
planes
¶PlanesT
, default:None
) –Which planes to process. Defaults to all.
-
func
¶FuncExceptT | None
, default:None
) –Function returned for custom error handling. This should only be set by VS package developers.
Returns:
-
ConstantFormatVideoNode
–A new clip with the specified rectangular region masked in or out.
Source code
90 91 92 93 94 95 96 97 98 99 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 |
|
rekt_partial ¶
rekt_partial(
clip: VideoNode,
func: Callable[Concatenate[VideoNode, P0], VideoNode],
left: int = 0,
right: int = 0,
top: int = 0,
bottom: int = 0,
*args: args,
**kwargs: kwargs
) -> ConstantFormatVideoNode
Creates a rectangular mask to apply fixes only within the masked area, significantly speeding up filters like anti-aliasing and scaling.
Parameters:
-
clip
¶VideoNode
) –The source video clip to which the mask will be applied.
-
func
¶Callable[Concatenate[VideoNode, P0], VideoNode]
) –The function to be applied within the masked area.
-
left
¶int
, default:0
) –The left boundary of the mask, defaults to 0.
-
right
¶int
, default:0
) –The right boundary of the mask, defaults to 0.
-
top
¶int
, default:0
) –The top boundary of the mask, defaults to 0.
-
bottom
¶int
, default:0
) –The bottom boundary of the mask, defaults to 0.
Returns:
-
ConstantFormatVideoNode
–A new clip with the applied mask.
Source code
426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 |
|
replace_squaremask ¶
replace_squaremask(
clipa: VideoNode,
clipb: VideoNode,
mask_params: tuple[int, int, int, int],
ranges: FrameRangeN | FrameRangesN | None = None,
blur_sigma: int | float | None = None,
invert: bool = False,
func: FuncExceptT | None = None,
show_mask: bool = False,
) -> ConstantFormatVideoNode
Replace an area of the frame with another clip using a simple square mask.
This is a convenience wrapper merging square masking and framerange replacing functionalities into one function, along with additional utilities such as blurring.
Parameters:
-
clipa
¶VideoNode
) –Base clip to process.
-
clipb
¶VideoNode
) –Clip to mask on top of
clipa
. -
mask_params
¶tuple[int, int, int, int]
) –Parameters passed to
squaremask
. Expects a tuple of (width, height, offset_x, offset_y). -
ranges
¶FrameRangeN | FrameRangesN | None
, default:None
) –Frameranges to replace with the masked clip. If
None
, replaces the entire clip. Default: None. -
blur_sigma
¶int | float | None
, default:None
) –Post-blurring of the mask to help hide hard edges. If you pass an int, a box_blur will be used. Passing a float will use a gauss_blur instead. Default: None.
-
invert
¶bool
, default:False
) –Invert the mask. This means everything but the defined square will be masked. Default: False.
-
func
¶FuncExceptT | None
, default:None
) –Function returned for custom error handling. This should only be set by VS package developers. Default: squaremask.
-
show_mask
¶bool
, default:False
) –Return the mask instead of the masked clip.
Returns:
-
ConstantFormatVideoNode
–Clip with a squaremask applied, and optionally set to specific frameranges.
Source code
256 257 258 259 260 261 262 263 264 265 266 267 268 269 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 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 |
|
squaremask ¶
squaremask(
clip: VideoNode,
width: int,
height: int,
offset_x: int,
offset_y: int,
invert: bool = False,
force_gray: bool = True,
planes: PlanesT = None,
func: FuncExceptT | None = None,
) -> ConstantFormatVideoNode
Create a square used for simple masking.
This is a fast and simple mask that's useful for very rough and simple masking.
Parameters:
-
clip
¶VideoNode
) –The clip to process.
-
width
¶int
) –The width of the square. This must be less than clip.width - offset_x.
-
height
¶int
) –The height of the square. This must be less than clip.height - offset_y.
-
offset_x
¶int
) –The location of the square, offset from the left side of the frame.
-
offset_y
¶int
) –The location of the square, offset from the top of the frame.
-
invert
¶bool
, default:False
) –Invert the mask. This means everything but the defined square will be masked. Default: False.
-
force_gray
¶bool
, default:True
) –Whether to force using GRAY format or clip format.
-
planes
¶PlanesT
, default:None
) –Which planes to process.
-
func
¶FuncExceptT | None
, default:None
) –Function returned for custom error handling. This should only be set by VS package developers.
Returns:
-
ConstantFormatVideoNode
–A mask in the shape of a square.
Source code
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 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 |
|