ranges ¶
RangesCallback module-attribute
¶
RangesCallback = Union[
Callable[[int], bool],
Callable[[VideoFrame], bool],
Callable[[list[VideoFrame]], bool],
Callable[[VideoFrame | list[VideoFrame]], bool],
Callable[[int, VideoFrame], bool],
Callable[[int, list[VideoFrame]], bool],
Callable[[int, VideoFrame | list[VideoFrame]], bool],
]
remap_frames ¶
Source code
208 209 210 211 212 213 214 215 |
|
replace_every ¶
replace_every(
clipa: VideoNode,
clipb: VideoNode,
cycle: int,
offsets: Sequence[int],
modify_duration: bool = True,
) -> VideoNode
Source code
218 219 220 221 222 223 224 225 226 227 |
|
replace_ranges ¶
replace_ranges(
clip_a: VideoNode,
clip_b: VideoNode,
ranges: (
FrameRangeN
| FrameRangesN
| Callable[[VideoFrame], bool]
| Callable[[int, VideoFrame], bool]
| None
),
exclusive: bool = False,
mismatch: bool = False,
*,
prop_src: VideoNode
) -> VideoNode
replace_ranges(
clip_a: VideoNode,
clip_b: VideoNode,
ranges: (
FrameRangeN
| FrameRangesN
| Callable[[list[VideoFrame]], bool]
| Callable[[int, list[VideoFrame]], bool]
| None
),
exclusive: bool = False,
mismatch: bool = False,
*,
prop_src: list[VideoNode]
) -> VideoNode
replace_ranges(
clip_a: VideoNode,
clip_b: VideoNode,
ranges: (
FrameRangeN
| FrameRangesN
| Callable[[VideoFrame | list[VideoFrame]], bool]
| Callable[[int, VideoFrame | list[VideoFrame]], bool]
| None
),
exclusive: bool = False,
mismatch: bool = False,
*,
prop_src: VideoNode | list[VideoNode] | None = None
) -> VideoNode
replace_ranges(
clip_a: VideoNode,
clip_b: VideoNode,
ranges: FrameRangeN | FrameRangesN | Callable[[int], bool] | None,
exclusive: bool = False,
mismatch: bool = False,
*,
prop_src: None = None
) -> VideoNode
replace_ranges(
clip_a: VideoNode,
clip_b: VideoNode,
ranges: FrameRangeN | FrameRangesN | RangesCallback | None,
exclusive: bool = False,
mismatch: bool = False,
*,
prop_src: VideoNode | list[VideoNode] | None = None
) -> VideoNode
replace_ranges(
clip_a: VideoNode,
clip_b: VideoNode,
ranges: FrameRangeN | FrameRangesN | RangesCallback | None,
exclusive: bool = False,
mismatch: bool = False,
*,
prop_src: VideoNode | list[VideoNode] | None = None
) -> VideoNode
Replaces frames in a clip, either with pre-calculated indices or on-the-fly with a callback. Frame ranges are inclusive. This behaviour can be changed by setting exclusive=True
.
Examples with clips black
and white
of equal length: * replace_ranges(black, white, [(0, 1)])
: replace frames 0 and 1 with white
* replace_ranges(black, white, [(None, None)])
: replace the entire clip with white
* replace_ranges(black, white, [(0, None)])
: same as previous * replace_ranges(black, white, [(200, None)])
: replace 200 until the end with white
* replace_ranges(black, white, [(200, -1)])
: replace 200 until the end with white
, leaving 1 frame of black
A callback function can be used to replace frames based on frame properties. The function must return a boolean value.
Example of using a callback function: * replace_ranges(clip_a, clip_b, lambda f: get_prop(f, '_PictType', str) == 'P', prop_src=clip_a)
: Replace frames from clip_a
with clip_b
if the picture type of clip_a
is P.
Optional Dependencies: * vs-zip <https://github.com/dnjulek/vapoursynth-zip>
_ (highly recommended!)
Parameters:
-
clip_a
¶VideoNode
) –Original clip.
-
clip_b
¶VideoNode
) –Replacement clip.
-
ranges
¶FrameRangeN | FrameRangesN | RangesCallback | None
) –Ranges to replace clip_a (original clip) with clip_b (replacement clip). Integer values in the list indicate single frames, Tuple values indicate inclusive ranges. Callbacks must return true to replace a with b. Negative integer values will be wrapped around based on clip_b's length. None values are context dependent: * None provided as sole value to ranges: no-op * Single None value in list: Last frame in clip_b * None as first value of tuple: 0 * None as second value of tuple: Last frame in clip_b
-
exclusive
¶bool
, default:False
) –Use exclusive ranges (Default: False).
-
mismatch
¶bool
, default:False
) –Accept format or resolution mismatch between clips.
-
prop_src
¶VideoNode | list[VideoNode] | None
, default:None
) –Source clip(s) to use for frame properties in the callback. This is required if you're using a callback.
Returns:
-
VideoNode
–Clip with ranges from clip_a replaced with clip_b.
Source code
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 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 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 |
|