How to use the vapoursynth.core.register_format 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 AlphaAtlas / VapourSynth-Super-Resolution-Helper / Scripts / Alpha_ImageHelper.py View on Github external
tlist.append(c)
		clips = tlist
		ref = clips[0]	
	else:
		raise TypeError(funcName + ': \"clips\" must be a list of clips!')
    
    # Get properties of output clip
	if depth is None:
		depth = 10
	elif not isinstance(depth, int):
		raise TypeError(funcName + ': \"depth\" must be an int!')
	if depth >= 32:
		sample = vs.FLOAT
	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 / toolbars / pipette.py View on Github external
def non_subsampled_format(fmt: vs.Format) -> vs.Format:
            if fmt.id == vs.COMPATBGR32.value:
                return vs.RGB24  # type: ignore
            elif fmt.id == vs.COMPATYUY2.value:
                return vs.YUV444P8  # type: ignore
            else:
                return vs.core.register_format(
                    color_family=fmt.color_family,
                    sample_type=fmt.sample_type,
                    bits_per_sample=fmt.bits_per_sample,
                    subsampling_w=0,
                    subsampling_h=0
                )
github Beatrice-Raws / VapourSynth-TCPClip / TCPClip.py View on Github external
""" Expose Client as source filter for Vapoursynth. """
        def frame_copy(n: int, f: VideoFrame) -> VideoFrame:
            fout = f.copy()
            frame_data, frame_props = self.get_frame(n, pipe=False)
            for p in range(fout.format.num_planes):
                np.asarray(fout.get_write_array(p))[:] = frame_data[p]
            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