lvsfunc.dehardsub
Dehardsubbing functions and wrappers.
|
Apply a list of |
|
Get a clip of |
|
Zastin's spatially-aware hardsub mask. |
- class lvsfunc.dehardsub.HardsubMask(ranges=None, bound=None, *, blur=False, refframes=None)
Bases:
DeferredMask
,ABC
Dehardsub masking interface.
Provides extra functions potentially useful for dehardsubbing.
- Parameters
range – A single range or list of ranges to replace, compatible with
lvsfunc.misc.replace_ranges
bound (BoundingBox | tuple[tuple[int, int], tuple[int, int]] | None) – A
lvsfunc.mask.BoundingBox
or a tuple that will be converted. (Default:None
, no bounding)blur (bool) – Blur the bounding mask (Default: True).
refframe – A single frame number to use to generate the mask. or a list of frame numbers with the same length as
vstools.FrameRange()
- get_progressive_dehardsub(hrdsb, ref, partials)
Dehardsub using multiple superior hardsubbed sources and one inferior non-subbed source.
- Parameters
hrdsb (
VideoNode
) – Hardsub master source (eg Wakanim RU dub).ref (
VideoNode
) – Non-subbed reference source (eg CR, Funi, Amazon).partials (
list
[VideoNode
]) – Sources to use for partial dehardsubbing (eg Waka DE, FR, SC).
- Return type
tuple
[list
[VideoNode
],list
[VideoNode
]]- Returns
Dehardsub stages and masks used for progressive dehardsub.
- apply_dehardsub(hrdsb, ref, partials)
Apply dehardsubbing to a clip.
- Parameters
hrdsb (
VideoNode
) – Hardsubbed source.ref (
VideoNode
) – Non-hardsubbed source.partials (
Optional
[list
[VideoNode
]]) – Other hardsubbed sources.
- Return type
VideoNode
- Returns
Dehardsubbed clip.
- class lvsfunc.dehardsub.HardsubSign(*args, thresh=0.06, minimum=1, expand=8, inflate=7, **kwargs)
Bases:
HardsubMask
Hardsub scenefiltering helper using Zastin’s hardsub mask.
- Parameters
thresh (
float
) – Binarization threshold, [0, 1] (Default: 0.06).expand (
int
) – std.Maximum iterations (Default: 8).inflate (
int
) – std.Inflate iterations (Default: 7).
- thresh: float
- minimum: int
- expand: int
- inflate: int
- class lvsfunc.dehardsub.HardsubSignKgf(*args, highpass=5000, expand=8, **kwargs)
Bases:
HardsubMask
Hardsub scenefiltering helper using
kgf.hardsubmask_fades()
.Dependencies:
- Parameters
highpass (
int
) – Highpass filter for hardsub detection (16-bit, Default: 5000).expand (
int
) –kgf.hardsubmask_fades()
expand parameter (Default: 8).
- Raises
DependencyNotFoundError – Dependencies are missing.
- highpass: int
- expand: int
- class lvsfunc.dehardsub.HardsubLine(*args, expand=None, **kwargs)
Bases:
HardsubMask
Hardsub scenefiltering helper using
kgf.hardsubmask()
.Dependencies:
- Parameters
expand (
Optional
[int
]) –kgf.hardsubmask()
expand parameter (Default: clip.width // 200).- Raises
DependencyNotFoundError – Dependencies are missing.
- expand: int | None
- class lvsfunc.dehardsub.HardsubLineFade(ranges, *args, refframe=0.5, **kwargs)
Bases:
HardsubLine
Hardsub scenefiltering helper using
kgf.hardsubmask()
.Similar to
lvsfunc.dehardsub.HardsubLine
but automatically sets the reference frame to the range’s midpoint.- Parameters
refframe (float) – Desired reference point as a percent of the frame range. 0 = first frame, 1 = last frame, 0.5 = midpoint (Default)
- Raises
ValueError – refframe is not between 0–1.
- ref_float: float
- get_mask(clip, ref)
Get the mask.
- Return type
VideoNode
- class lvsfunc.dehardsub.HardsubASS(filename, *args, fontdir=None, shift=None, **kwargs)
Bases:
HardsubMask
Generate a mask using an ass script, such as for dehardubbing AoD with CR DE.
- Parameters
filename (
str
) – Path to ASS script.fontdir (
Optional
[str
]) – Extra fonts path.shift (
Optional
[int
]) – Offset to apply to the script, in frames. May misbehave due to timestamp rounding.
- filename: str
- fontdir: str | None
- shift: int | None
- class lvsfunc.dehardsub.HardsubSignFade(ranges, *args, refframe=0.5, **kwargs)
Bases:
HardsubSign
Hardsub scenefiltering helper using Zastin’s sign mask.
Similar to
lvsfunc.dehardsub.HardsubSign
but automatically sets the reference frame to the range’s midpoint.- Parameters
refframe (float) – Desired reference point as a percent of the frame range. 0 = first frame, 1 = last frame, 0.5 = midpoint (Default)
- Raises
ValueError – refframe is not between 0–1.
- get_mask(clip, ref)
Get the mask.
- Return type
VideoNode
- ref_float: float
- lvsfunc.dehardsub.bounded_dehardsub(hrdsb, ref, signs, partials=None)
Apply a list of
lvsfunc.dehardsub.HardsubSign
.- Parameters
hrdsb (
VideoNode
) – Hardsubbed source.ref (
VideoNode
) – Reference clip.signs (
list
[HardsubMask
]) – List oflvsfunc.dehardsub.HardsubSign
to apply.
- Return type
VideoNode
- Returns
Dehardsubbed clip.
- lvsfunc.dehardsub.get_all_masks(hrdsb, ref, signs)
Get a clip of
lvsfunc.dehardsub.HardsubSign
masks.- Parameters
hrdsb (
VideoNode
) – Hardsubbed source.ref (
VideoNode
) – Reference clip.signs (
list
[HardsubMask
]) – List oflvsfunc.dehardsub.HardsubSign
to generate masks for.
- Return type
VideoNode
- Returns
Clip of all hardsub masks.
- lvsfunc.dehardsub.hardsub_mask(hrdsb, ref, thresh=0.06, minimum=1, expand=8, inflate=7)
Zastin’s spatially-aware hardsub mask.
- Parameters
hrdsb (
VideoNode
) – Hardsubbed source.ref (
VideoNode
) – Reference clip.thresh (
float
) – Binarization threshold, [0, 1] (Default: 0.06).minimum (
int
) – Times to minimize the max (Default: 1).expand (
int
) – Times to maximize the mask (Default: 8).inflate (
int
) – Times to inflate the mask (Default: 7).
- Return type
VideoNode
- Returns
Hardsub mask.