Utility Functions
Index sources in batch, provide a list of files to index. |
|
Copy credits from source to the nc using a mask. |
|
Simple wrapper to turn a video frame into an numpy array |
|
Simple function that checks if chroma is top-left aligned or not. |
|
Function for splicing in video from a different source. |
Easy livin’ functions, utilities that don’t match a category.
The functions in this module are mostly things that don’t fit in with the
other categories but aren’t really worth making a new module over.
This module will end up mostly containing things like batch utilities and
project setup stuff. This should spawn some ease of use functions that I think
are missing from the well known collections like vsutil
.
- rvsfunc.utils.batch_index(paths, source_filter, show_list=False, **src_args)
Index sources in batch, provide a list of files to index.
Simple lazy function. Takes a path or a list of paths, indexes them and then frees the memory before returning on success. If you happen to get any errors or exceptions, this will just raise the same thing again.
- Parameters
paths (
Union
[List
[str
],str
]) – A single path as a string or a List of paths.source_filter (
Callable
[...
,VideoNode
]) – The source filter or indexer method to call. If it doesn’t write, make sure to get the list of indexes using show_list.show_list (
bool
) – If this is set to True, this function returns the results ofsource_filter(path)
for every path in paths. Might be useful for batches as well as it would just return everyvs.VideoNode
returned by the calls to source_filter.src_args (
Dict
[str
,Any
]) – Any additional keyword args will be forwarded to to the source filter as provided.
- Return type
List
[VideoNode
]
- rvsfunc.utils.copy_credits(source, nc, mask=None)
Copy credits from source to the nc using a mask.
This function internally calls
masking.detail_mask()
which is meant for descales. As such, it assumes the NC doesn’t have major differences with the source as they are provided. Assumes both inputs have the same length.- Parameters
source (
VideoNode
) – The clip to take the credits from.nc (
VideoNode
) – The NC to copy the credits into.mask (
Optional
[VideoNode
]) – Optional, an external mask to use.
- Return type
VideoNode
- rvsfunc.utils.frame_to_array(f)
Simple wrapper to turn a video frame into an numpy array
- Return type
ndarray
- rvsfunc.utils.is_topleft(clip)
Simple function that checks if chroma is top-left aligned or not.
In any other case it’s fairly safe to assume the chroma is aligned to the center-left as was the default before 4K UHD BDs and Bt.2020 were a thing. This is basically a more complex check for BT.2020 material.
- Return type
bool
- rvsfunc.utils.nc_splice(source, nc, startframe, endframe, nc_filterfunc=None, use_internal=False, ext_mask=None, **kwargs)
Function for splicing in video from a different source.
The intended purpose is to splice NCs into an episode when they look better or when they’re easier to filter. Allows for copying over the credits.
- Parameters
source (
VideoNode
) – The source clip that needs something replacednc (
VideoNode
) – The clip that needs to be spliced into sourcestartframe (
int
) – The frame to start splicing at. This is an inclusive selection value. The selected range issource[:startframe]
.endframe (
int
) – The first frame that needs to be kept. This is an inclusive selection value. Selected assource[endframe+1:]
.nc_filterfunc (
Optional
[Callable
[[VideoNode
,Any
],VideoNode
]]) – Optional function to call on the input video for filtering before splicing it in.use_internal (
bool
) – Whether or not to usecopy_credits
from this Module. Mutually exclusive withnc_filterfunc
.ext_mask (
Optional
[VideoNode
]) – For when the internal merging is good enough but the mask it generates isn’t. This is only used ifuse_internal
applies.kwargs (
Dict
[str
,Any
]) – Additional keyword args are only expanded when using an externalfilterfunc
. These are the keyword arguments to pass to it, not required if the filterfunc is apartial
.
- Return type
VideoNode