Skip to content

Commit

Permalink
ExportFrames: Resample to RGB24
Browse files Browse the repository at this point in the history
  • Loading branch information
LightArrowsEXE committed Oct 8, 2024
1 parent b8d0a2d commit 8364a79
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions lvsfunc/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

from typing import Any

from vskernels import KernelT, Lanczos
from vskernels import Bilinear, Kernel, KernelT, Lanczos
from vstools import (CustomStrEnum, CustomTypeError, CustomValueError,
FuncExceptT, FunctionUtil, MatrixT, SPath, SPathLike,
clip_async_render, core, fallback, vs)
FuncExceptT, FunctionUtil, Matrix, MatrixT, SPath,
SPathLike, clip_async_render, core, fallback, vs)

from .random import get_random_frames

Expand Down Expand Up @@ -34,6 +34,7 @@ class ExportFrames(CustomStrEnum):
def __call__(
self, clip: vs.VideoNode,
filename: SPathLike = "bin/%d.png",
kernel: KernelT = Bilinear,
matrix: MatrixT | None = None,
func_except: FuncExceptT | None = None,
**kwargs: Any
Expand All @@ -50,6 +51,7 @@ def __call__(
:param clip: The input clip to process.
:param filename: Output filename pattern. Must include "%d" for frame number substitution.
:param kernel: Kernel for resampling, if necessary. Default: Bilinear.
:param matrix: Color matrix of the input clip. Attempts to detect if None.
:param func_except: Function returned for custom error handling.
This should only be set by VS package developers.
Expand All @@ -58,9 +60,14 @@ def __call__(
:return: List of SPath objects pointing to exported images.
"""

func = FunctionUtil(clip, fallback(func_except, self), None, vs.RGB, 8, matrix=matrix)
func = func_except or self.__class__

sfile = self._check_sfile(filename, func.func)
kernel = Kernel.ensure_obj(kernel, func)
matrix = Matrix.from_param_or_video(matrix, clip, False, func)

clip = kernel.resample(clip, vs.RGB24, matrix_in=matrix)

sfile = self._check_sfile(filename, func)

return self._render_frames(clip, sfile, **kwargs)

Expand Down

0 comments on commit 8364a79

Please sign in to comment.