How to use the vapoursynth.core.std function in VapourSynth

To help you get started, we’ve selected a few VapourSynth examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Irrational-Encoding-Wizardry / kagefunc / tests.py View on Github external
def assert_same_frame(self, clip_a: vs.VideoNode, clip_b: vs.VideoNode):
        """
        Assert that two frames are identical. Only the first frame of the arguments is used.
        """
        diff = vs.core.std.PlaneStats(clip_a, clip_b)
        frame = diff.get_frame(0)
        self.assertEqual(frame.props.PlaneStatsDiff, 0)
github Irrational-Encoding-Wizardry / vsutil / tests / test_vsutil.py View on Github external
import unittest

import vapoursynth as vs

import vsutil


class VsUtilTests(unittest.TestCase):
    YUV420P8_CLIP = vs.core.std.BlankClip(format=vs.YUV420P8, width=160, height=120, color=[0, 128, 128], length=100)
    YUV420P10_CLIP = vs.core.std.BlankClip(format=vs.YUV420P10, width=160, height=120, color=[0, 128, 128], length=100)
    YUV444P8_CLIP = vs.core.std.BlankClip(format=vs.YUV444P8, width=160, height=120, color=[0, 128, 128], length=100)
    YUV422P8_CLIP = vs.core.std.BlankClip(format=vs.YUV422P8, width=160, height=120, color=[0, 128, 128], length=100)
    YUV410P8_CLIP = vs.core.std.BlankClip(format=vs.YUV410P8, width=160, height=120, color=[0, 128, 128], length=100)
    YUV411P8_CLIP = vs.core.std.BlankClip(format=vs.YUV411P8, width=160, height=120, color=[0, 128, 128], length=100)
    YUV440P8_CLIP = vs.core.std.BlankClip(format=vs.YUV440P8, width=160, height=120, color=[0, 128, 128], length=100)
    RGB24_CLIP = vs.core.std.BlankClip(format=vs.RGB24)

    SMALLER_SAMPLE_CLIP = vs.core.std.BlankClip(format=vs.YUV420P8, width=10, height=10)

    BLACK_SAMPLE_CLIP = vs.core.std.BlankClip(format=vs.YUV420P8, width=160, height=120, color=[0, 128, 128],
                                              length=100)
    WHITE_SAMPLE_CLIP = vs.core.std.BlankClip(format=vs.YUV420P8, width=160, height=120, color=[255, 128, 128],
                                              length=100)

    VARIABLE_FORMAT_CLIP = vs.core.std.Interleave([YUV420P8_CLIP, YUV444P8_CLIP], mismatch=True)
github Beatrice-Raws / VapourSynth-TCPClip / TCPClip.py View on Github external
for i in frame_props:
                fout.props[i] = frame_props[i]
            return fout
        server_version = self.version()
        assert server_version == Version.MAJOR, f'Version mismatch!\nServer: {server_version} | Client: {Version.MAJOR}'
        header_info = self.get_meta()
        assert len(header_info) > 0, 'Wrong header info.'
        assert 'format' in header_info, 'Missing "Format".'
        clip_format = header_info['format']
        source_format = core.register_format(
            clip_format['color_family'],
            clip_format['sample_type'],
            clip_format['bits_per_sample'],
            clip_format['subsampling_w'],
            clip_format['subsampling_h'])
        dummy = core.std.BlankClip(
            width=header_info['width'],
            height=header_info['height'],
            format=source_format,
            length=header_info['num_frames'],
            fpsnum=header_info['fps_numerator'],
            fpsden=header_info['fps_denominator'],
            keep=True)
        source = core.std.ModifyFrame(dummy, dummy, frame_copy)
        return source
github AlphaAtlas / VapourSynth-Super-Resolution-Helper / CustomScripts / HelperScripts / ImageFetcher.py View on Github external
clip, alphaclip =  core.imwri.Read(filelist[0], mismatch=False, alpha=True)
		if len(filelist) > 1:
			filelist = filelist[1:]
			for file in filelist:
				singleclip, singlealphaclip = core.imwri.Read(file, mismatch=False, alpha=True)
				clip = core.std.Splice([clip, singleclip], mismatch = mis)
				alphaclip = core.std.Splice([alphaclip, singlealphaclip], mismatch = mis)
		return clip, alphaclip
	else:
		clip =  core.imwri.Read(filelist[0], mismatch=False, alpha=False)
		if len(filelist) > 1:
			filelist = filelist[1:]
			for file in filelist:
				singleclip = core.imwri.Read(file, mismatch=False, alpha=False)
				clip = core.std.Splice([clip, singleclip], mismatch = mis)
		return clip, core.std.BlankClip(clip, length = clip.num_frames)
github rlaPHOENiX / VSGAN / vsgan / __init__.py View on Github external
)

        def replace_planes(n, f):
            frame = f.copy()
            for i, plane_num in enumerate(reversed(range(plane_count))):
                # todo ; any better way to do this without storing the np.array in a variable?
                # todo ; perhaps some way to directly copy it to s?
                d = np.array(frame.get_write_array(plane_num), copy=False)
                # copy the value of d, into s[frame_num, :, :, plane_num]
                np.copyto(d, image[n, :, :, i], casting="unsafe")
                # delete the d variable from memory
                del d
            return frame

        # take the blank clip and insert the new data into the planes and return it back to sender
        return core.std.ModifyFrame(clip=buffer, clips=buffer, selector=replace_planes)
github Beatrice-Raws / VapourSynth-TCPClip / TCPClip.py View on Github external
clip_format = header_info['format']
        source_format = core.register_format(
            clip_format['color_family'],
            clip_format['sample_type'],
            clip_format['bits_per_sample'],
            clip_format['subsampling_w'],
            clip_format['subsampling_h'])
        dummy = core.std.BlankClip(
            width=header_info['width'],
            height=header_info['height'],
            format=source_format,
            length=header_info['num_frames'],
            fpsnum=header_info['fps_numerator'],
            fpsden=header_info['fps_denominator'],
            keep=True)
        source = core.std.ModifyFrame(dummy, dummy, frame_copy)
        return source
github AlphaAtlas / VapourSynth-Super-Resolution-Helper / Scripts / Alpha_ImageHelper.py View on Github external
else:
		sample = vs.INTEGER
	dFormat = core.register_format(vs.YUV, sample, depth, 0, 0).id

	def Conv(clip,txt):
		if (ref.width % clip.width == 0) and (ref.height % clip.height == 0):
			clip = core.resize.Point(clip, ref.width, ref.height, matrix_s = matrix_s, format=dFormat, matrix_in=mvs.GetMatrix(clip, matrix, True, True), range_in=full, dither_type=dither, prefer_props=prefer_props)
		else:
			clip = core.resize.Bicubic(clip, ref.width, ref.height, matrix_s = matrix_s, format=dFormat, matrix_in=mvs.GetMatrix(clip, matrix, True, True), range_in=full, filter_param_a=0, filter_param_b=0.5, dither_type=dither, prefer_props=prefer_props)
		if txt is not None:
			clip = core.text.Text(clip, txt, alignment =  alignment)
		return clip

	for i in range(len(clips)):
		clips[i] = Conv(clips[i], writelist[i])
	clip = core.std.Interleave(clips, extend = False)
	return clip
github Endilll / vapoursynth-preview / vspreview / core / types.py View on Github external
def prepare_vs_output(self, vs_output: vs.VideoNode, alpha: bool = False) -> vs.VideoNode:
        resizer = self.main.VS_OUTPUT_RESIZER
        resizer_kwargs = {
            'format'        : vs.COMPATBGR32,
            'matrix_in_s'   : self.main.VS_OUTPUT_MATRIX,
            'transfer_in_s' : self.main.VS_OUTPUT_TRANSFER,
            'primaries_in_s': self.main.VS_OUTPUT_PRIMARIES,
            'range_in_s'    : self.main.VS_OUTPUT_RANGE,
            'chromaloc_in_s': self.main.VS_OUTPUT_CHROMALOC,
            'prefer_props'  : self.main.VS_OUTPUT_PREFER_PROPS,
        }

        if not alpha:
            vs_output = vs.core.std.FlipVertical(vs_output)

        if vs_output.format == vs.COMPATBGR32:  # type: ignore
            return vs_output

        is_subsampled = (vs_output.format.subsampling_w != 0
                         or vs_output.format.subsampling_h != 0)
        if not is_subsampled:
            resizer = self.Resizer.Point

        if vs_output.format.color_family == vs.RGB:
            del resizer_kwargs['matrix_in_s']

        if alpha:
            if vs_output.format == vs.GRAY8:  # type: ignore
                return vs_output
            resizer_kwargs['format'] = vs.GRAY8
github rlaPHOENiX / VSGAN / vsgan / __init__.py View on Github external
def chunk_clip(clip):
        # split the clip horizontally into 2 images
        crops = {
            "left": core.std.CropRel(clip, left=0, top=0, right=clip.width / 2, bottom=0),
            "right": core.std.CropRel(clip, left=clip.width / 2, top=0, right=0, bottom=0)
        }
        # split each of the 2 images from above, vertically, into a further 2 images (totalling 4 images per frame)
        # top left, bottom left, top right, bottom right
        return [
            core.std.CropRel(crops["left"], left=0, top=0, right=0, bottom=crops["left"].height / 2),
            core.std.CropRel(crops["left"], left=0, top=crops["left"].height / 2, right=0, bottom=0),
            core.std.CropRel(crops["right"], left=0, top=0, right=0, bottom=crops["right"].height / 2),
            core.std.CropRel(crops["right"], left=0, top=crops["right"].height / 2, right=0, bottom=0)
        ]