postprocess ¶
Functions:
-
decrease_size
–Forcibly reduce the required bitrate to encode a clip by blurring away noise and grain
decrease_size ¶
decrease_size(
clip: VideoNode,
sigmaS: float = 10.0,
sigmaR: float = 0.009,
min_in: int = 180,
max_in: int = 230,
gamma: float = 1.0,
mask: VideoNode | tuple[float, float] | tuple[float, float, EdgeDetectT] = (
0.0496,
0.125,
FDoGTCanny,
),
prefilter: bool | tuple[int, int] | float = True,
planes: PlanesT = None,
show_mask: bool = False,
**kwargs: Any
) -> VideoNode
Forcibly reduce the required bitrate to encode a clip by blurring away noise and grain in areas they won't be visible in.
Grain and noise in really bright areas can be incredibly hard to spot for even experienced encoders, and will eat up a lot of extra bitrate. As this grain is invisible, there's little reason to go out of your way to better preserve it, and aq-modes like aq-mode 3 already incentivize the encoder to spend more bits in darker areas anyway.
A gradient mask is used internally to prevent "hard edges" from forming on the boundaries of the mask. Additionally, an edgemask is used to prevent clearly-defined detail from being blurred away.
Parameters:
-
clip
¶VideoNode
) –Clip to process.
-
sigmaS
¶float
, default:10.0
) –Sigma of Gaussian function to calculate spatial weight. See the
vsrgtools.bilateral
documentation for more information. Default: 10.0. -
sigmaR
¶float
, default:0.009
) –Sigma of Gaussian function to calculate range weight. See the
vsrgtools.bilateral
documentation for more information. Default: 0.009. -
min_in
¶int
, default:180
) –Starting pixel value for the gradient mask. Must be a value between 0–255. Low values are not recommended, as this will start to blur a lot more detail. Default: 180.
-
max_in
¶int
, default:230
) –Ending pixel value for the gradient mask. Must be a value between 0–255. This value must be greater than
min_in
. Any pixel values above this will be fully masked. Default: 230. -
mask
¶VideoNode | tuple[float, float] | tuple[float, float, EdgeDetectT]
, default:(0.0496, 0.125, FDoGTCanny)
) –Mask node for masking out details from the blur.
-
prefilter
¶bool | tuple[int, int] | float
, default:True
) –Prefilter the clip prior to masked blurring. If you pass a float, a gauss blur will be used with the value determining its sigma. If you pass a tuple of floats, a box blur will be used. The first value is the radii, and the second is the number of passes. If you pass
True
, it defaults tobox_blur(2, 4)
. SetFalse
to disable. Default: True. -
planes
¶PlanesT
, default:None
) –Planes to process. If None, all planes. Default: None.
-
show_mask
¶bool
, default:False
) –Return the gradient mask clip. Default: False.
-
kwargs
¶Any
, default:{}
) –Additional keyword arguments to pass to bilateral.
Returns:
-
VideoNode
–Clip with the brightest areas, as defined by the gradient mask, heavily blurred.
Raises:
-
IndexError
–min_in
is greater thanmax_in
. -
InvalidColorFamilyError
–Input clip is not a YUV clip.
-
InvalidColorFamilyError
–A VideoNode is passed to
mask
and the clip is not a GRAY clip.
Source code
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 82 83 84 85 86 87 88 89 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 |
|