Skip to content

vsmuxtools.video.testing

SettingsTester

SettingsTester(settings: str | list[str], encoder: VideoEncoder | None = None, qp_clip: SRC_FILE | VideoNode | None = None)

A utility class for making test encodes. This can automatically parse strings like

--preset veryfast --crf [14/15/0.5] and will then run encodes with CRF 14, 14.5 and 15.

The same works with non stepping options like

--preset [fast,veryfast,slow,slower] or --sao [true,false] (can also use yes/no and y/n for these)

Keep in mind that this will create an encode for EVERY combination and not some order.

--preset [fast,veryfast,ultrafast] --crf [14/15/0.5] For example will end up with 9 encodes.

Source code in vsmuxtools/video/testing.py
def __init__(self, settings: str | list[str], encoder: VideoEncoder | None = None, qp_clip: SRC_FILE | vs.VideoNode | None = None) -> None:
    if not encoder:
        self.encoder = x265("--kek")
    else:
        self.encoder = encoder

    if isinstance(self.encoder, SupportsQP) and qp_clip:
        self.encoder.qp_clip = qp_clip
        self.qp_file = self.encoder._get_qpfile()

    if isinstance(settings, str):
        self.encodes = generate_settings(settings)  # type: ignore
    else:
        self.encodes = [(None, s) for s in settings]

run

run(clip: VideoNode, output_clips: bool = True) -> None

Runs all encodes with the settings specified/generated.

Parameters:

Name Type Description Default
output_clips bool

Will index and output clips with proper naming if vspreview is installed. This might obviously end up using quite a lot of ram.

True
Source code in vsmuxtools/video/testing.py
def run(self, clip: vs.VideoNode, output_clips: bool = True) -> None:
    """
    Runs all encodes with the settings specified/generated.

    :param output_clips:        Will index and output clips with proper naming if vspreview is installed.
                                This might obviously end up using quite a lot of ram.
    """
    for encode in self.encodes:
        encoder = self.encoder.__class__(settings=encode[1])  # type: ignore
        setattr(encoder, "resumable", False)
        if isinstance(self.encoder, SupportsQP) and self.qp_file:
            encoder.qp_file = self.qp_file  # type: ignore

        safe_filename = "" if not encode[0] else re.sub(r"[\<\>\*\\\:\|\?\"]", "_", encode[0])
        out = make_output("encode", "test", suffix=safe_filename)

        f = encoder.encode(clip, out)
        if output_clips:
            done = src(f.file)
            try:
                from vspreview import set_output  # type: ignore

                set_output(done, name=encode[0], cache=False)
            except:
                done.set_output(len(vs.get_outputs()))