helpers ¶
Classes:
-
CropAbs
– -
CropRel
– -
ScalingArgs
–
Functions:
-
scale_var_clip
–Scale a variable clip to constant or variable resolution.
CropAbs ¶
CropRel ¶
Bases: NamedTuple
Attributes:
ScalingArgs dataclass
¶
ScalingArgs(
width: int,
height: int,
src_width: float,
src_height: float,
src_top: float,
src_left: float,
mode: str = "hw",
)
Methods:
Attributes:
-
height
(int
) – -
mode
(str
) – -
src_height
(float
) – -
src_left
(float
) – -
src_top
(float
) – -
src_width
(float
) – -
width
(int
) –
from_args classmethod
¶
from_args(
base_clip: VideoNode,
height: int | float,
width: int | float | None = None,
base_height: int | None = None,
base_width: int | None = None,
src_top: float = 0,
src_left: float = 0,
crop: (
tuple[LeftCrop, RightCrop, TopCrop, BottomCrop]
| CropRel
| CropAbs
| None
) = None,
mode: str = "hw",
) -> Self
Get (de)scaling arguments for integer scaling.
Parameters:
-
base_clip
¶VideoNode
) –Source clip.
-
height
¶int | float
) –Target (de)scaling height. Casting to float will ensure fractional calculations.
-
width
¶int | float | None
, default:None
) –Target (de)scaling width. Casting to float will ensure fractional calculations. If None, it will be calculated from the height and the aspect ratio of the base_clip.
-
base_height
¶int | None
, default:None
) –The height from which to contain the clip. If None, it will be calculated from the height.
-
base_width
¶int | None
, default:None
) –The width from which to contain the clip. If None, it will be calculated from the width.
-
src_top
¶float
, default:0
) –Vertical offset.
-
src_left
¶float
, default:0
) –Horizontal offset.
-
crop
¶tuple[LeftCrop, RightCrop, TopCrop, BottomCrop] | CropRel | CropAbs | None
, default:None
) –Tuple of cropping values, or relative/absolute crop specification.
-
mode
¶str
, default:'hw'
) –Scaling mode:
- "w" means only the width is calculated.
- "h" means only the height is calculated.
- "hw or "wh" mean both width and height are calculated.
Returns:
-
Self
–ScalingArgs object suitable for scaling functions.
Source code
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 236 237 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 268 269 270 271 272 273 274 275 |
|
kwargs ¶
kwargs(clip_or_rate: VideoNode | float | None = None) -> KwargsT
Source code
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 |
|
scale_var_clip ¶
scale_var_clip(
clip: VideoNode,
scaler: (
Scaler
| Callable[[Resolution], Scaler]
| Callable[[tuple[int, int]], Scaler]
),
width: (
int
| Callable[[Resolution], int]
| Callable[[tuple[int, int]], int]
| None
),
height: (
int | Callable[[Resolution], int] | Callable[[tuple[int, int]], int]
),
shift: (
tuple[float, float] | Callable[[tuple[int, int]], tuple[float, float]]
) = (0, 0),
debug: bool = False,
) -> VideoNode
Scale a variable clip to constant or variable resolution.
Parameters:
-
clip
¶VideoNode
) –Source clip.
-
scaler
¶Scaler | Callable[[Resolution], Scaler] | Callable[[tuple[int, int]], Scaler]
) –A scaler instance or a callable that returns a scaler instance.
-
width
¶int | Callable[[Resolution], int] | Callable[[tuple[int, int]], int] | None
) –A width integer or a callable that returns the width. If None, it will be calculated from the height and the aspect ratio of the clip.
-
height
¶int | Callable[[Resolution], int] | Callable[[tuple[int, int]], int]
) –A height integer or a callable that returns the height.
-
shift
¶tuple[float, float] | Callable[[tuple[int, int]], tuple[float, float]]
, default:(0, 0)
) –Optional top shift, left shift tuple or a callable that returns the shifts. Defaults to no shift.
-
debug
¶bool
, default:False
) –If True, the
var_width
andvar_height
props will be added to the clip.
Returns:
-
VideoNode
–Scaled clip.
Source code
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
|