How to use the vapoursynth.RGB24 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 / 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)

    def assert_same_dimensions(self, clip_a: vs.VideoNode, clip_b: vs.VideoNode):
        """
        Assert that two clips have the same width and height.
        """
        self.assertEqual(clip_a.height, clip_b.height, f'Same height expected, was {clip_a.height} and {clip_b.height}.')
        self.assertEqual(clip_a.width, clip_b.width, f'Same width expected, was {clip_a.width} and {clip_b.width}.')
github Irrational-Encoding-Wizardry / vsutil / tests / test_vsutil.py View on Github external
def test_depth(self):
        with self.assertRaisesRegex(ValueError, 'sample_type must be in'):
            vsutil.depth(self.RGB24_CLIP, 8, sample_type=2)
        with self.assertRaisesRegex(ValueError, 'range must be in'):
            vsutil.depth(self.RGB24_CLIP, 8, range=2)
        with self.assertRaisesRegex(ValueError, 'range_in must be in'):
            vsutil.depth(self.RGB24_CLIP, 8, range_in=2)
        with self.assertRaisesRegex(ValueError, 'dither_type must be in'):
            vsutil.depth(self.RGB24_CLIP, 8, dither_type='test')

        full_clip = vs.core.std.BlankClip(format=vs.RGB24)
        int_10_clip = full_clip.resize.Point(format=full_clip.format.replace(bits_per_sample=10))
        int_16_clip = full_clip.resize.Point(format=full_clip.format.replace(bits_per_sample=16))
        float_16_clip = full_clip.resize.Point(format=full_clip.format.replace(bits_per_sample=16, sample_type=vs.FLOAT))
        float_32_clip = full_clip.resize.Point(format=full_clip.format.replace(bits_per_sample=32, sample_type=vs.FLOAT))

        limited_clip = vs.core.std.BlankClip(format=vs.YUV420P8)
        l_int_10_clip = limited_clip.resize.Point(format=limited_clip.format.replace(bits_per_sample=10))
        l_int_16_clip = limited_clip.resize.Point(format=limited_clip.format.replace(bits_per_sample=16))
        l_float_16_clip = limited_clip.resize.Point(format=limited_clip.format.replace(bits_per_sample=16, sample_type=vs.FLOAT))
        l_float_32_clip = limited_clip.resize.Point(format=limited_clip.format.replace(bits_per_sample=32, sample_type=vs.FLOAT))

        self.assertEqual(vsutil.depth(full_clip, 8), full_clip)
        self.assert_same_format(vsutil.depth(full_clip, 10), int_10_clip)
        self.assert_same_format(vsutil.depth(full_clip, 16), int_16_clip)
        self.assert_same_format(vsutil.depth(full_clip, 16, sample_type=vs.FLOAT), float_16_clip)
        self.assert_same_format(vsutil.depth(full_clip, 32), float_32_clip)
github Irrational-Encoding-Wizardry / yuuno / yuuno / vs / clip.py View on Github external
def _to_compat_rgb32(self, clip: VideoNode):
        if clip.format.color_family == vs.YUV:
            clip = self.extension.resize_filter(clip, format=vs.RGB24, matrix_in_s=self.extension.yuv_matrix)

        if clip.format.color_family != vs.RGB or clip.format.bits_per_sample != 8:
            clip = self.extension.resize_filter(clip, format=vs.RGB24)

        return self.extension.resize_filter(clip, format=vs.COMPATBGR32)
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 Irrational-Encoding-Wizardry / yuuno / yuuno / core / converter / vs_conv.py View on Github external
:param matrix:  The matrix to use when converting from YUV to RGB
        :return: An RGB24-Clip
        """

        if matrix is None:
            matrix = settings.yuv_matrix

        if clip.format.color_family == vs.YUV:           # Matrix on YUV
            clip = clip.resize.Spline36(
                format=vs.RGB24,
                matrix_in_s=matrix
            )
            
        if clip.format.color_family != vs.RGB or clip.format.bits_per_sample != 8:
            clip = clip.resize.Spline36(
                format=vs.RGB24
            )
            
        if compat:
            clip = clip.resize.Spline36(
                format=vs.COMPATBGR32
            )

        return clip
github alucryd / pyhenkan / pyhenkan / script.py View on Github external
def set_frame(self, frame):
        filters = self.mediafile.filters
        bilinear = Bilinear()
        bilinear.args['format'] = vs.RGB24
        imhdriw = ImageMagickHDRIWrite()
        imw = imhdriw if imhdriw.is_avail() else ImageMagickWrite()
        imw.args['imgformat'] = 'PNG'
        imw.args['filename'] = self.png

        # Add the necessary filters
        filters += [bilinear, imw]

        clip = self.vs.get_clip()[frame]
        clip.set_output()
        with open(os.devnull, 'wb') as f:
            clip.output(f)

        # Remove the filters
        filters.pop()
        filters.pop()