Exemple #1
0
def create_colorcorrection_filter(source_name, filter_name):
    source = obs.obs_get_source_by_name(source_name)
    if source is not None:
        filter_ = obs.obs_source_get_filter_by_name(source, filter_name)
        if filter_ is None:
            new_filter = obs.obs_source_create("color_filter", filter_name, None, None)
            obs.obs_source_filter_add(source, new_filter)
            obs.obs_source_release(new_filter)
        obs.obs_source_release(filter_)
    obs.obs_source_release(source)
    def add_filter_to_source(self):
        source = S.obs_get_source_by_name("1test_py")
        settings = S.obs_data_create()

        S.obs_data_set_int(settings, "opacity", 50)
        source_color = S.obs_source_create_private("color_filter",
                                                   "opacity to 50", settings)
        S.obs_source_filter_add(source, source_color)

        S.obs_source_release(source)
        S.obs_data_release(settings)
        S.obs_source_release(source_color)
Exemple #3
0
    def hue_effect(self):
        "apply random hue,add second color to see the effect"
        self.update_text(self._scripted_text)
        with source_ar(self.source_name) as source, filter_ar(source, "py_hue") as hue:
            if hue is None:
                with data_ar() as settings:
                    with p_source_ar("color_filter", "py_hue", settings) as _source:
                        obs.obs_source_filter_add(source, _source)

            with data_ar(hue) as filter_settings:
                seed()
                n = randrange(-180, 180)
                obs.obs_data_set_int(filter_settings, "hue_shift", n)
                obs.obs_source_update(hue, filter_settings)
                if self.duration // self.refresh_rate <= 3:
                    obs.obs_source_filter_remove(source, hue)
                    self.duration = 0
Exemple #4
0
    def sanic_effect(self):
        "really fast speed text scrolling(filter)"
        # add filter scroll to source if not present,
        self.update_text(self._scripted_text)
        with source_ar(self.source_name) as source, filter_ar(
            source, "py_scroll"
        ) as scroll:
            if scroll is None:
                with data_ar() as settings:
                    obs.obs_data_set_int(settings, "speed_x", 5000)
                    with p_source_ar("scroll_filter", "py_scroll", settings) as _source:
                        obs.obs_source_filter_add(source, _source)

            with data_ar(scroll) as filter_settings:
                obs.obs_data_set_int(filter_settings, "speed_x", 5000)
                obs.obs_source_update(scroll, filter_settings)
                if self.duration // self.refresh_rate <= 3:
                    obs.obs_source_filter_remove(source, scroll)
                    self.duration = 0
    def sanic_effect(self):
        # add filter scroll to source if not present,
        self.update_text(self.scripted_text)
        with source_ar(self.source_name) as source, filter_ar(
                source, "py_scroll") as scroll:
            if scroll is None:
                with data_ar() as settings:
                    obs.obs_data_set_int(settings, "speed_x", 5000)

                    source_scroll = obs.obs_source_create_private(
                        "scroll_filter", "py_scroll", settings)
                    obs.obs_source_filter_add(source, source_scroll)
                    obs.obs_source_release(source_scroll)

            with data_ar(scroll) as filter_settings:
                obs.obs_data_set_int(filter_settings, "speed_x", 5000)
                obs.obs_source_update(scroll, filter_settings)
                if self.duration // self.refresh_rate <= 3:
                    obs.obs_source_filter_remove(source, scroll)
                    self.duration = 0
Exemple #6
0
    def fade_effect(self):
        "fade text via opacity filter"
        self.update_text(self._scripted_text)
        with source_ar(self.source_name) as source, filter_ar(
            source, "py_fade"
        ) as fade:

            if fade is None:
                with data_ar() as settings:
                    with p_source_ar("color_filter", "py_fade", settings) as _source:
                        obs.obs_source_filter_add(source, _source)

            with data_ar(fade) as filter_settings:
                try:
                    coefficient = self.effect_duration / self.duration
                    percent = 100 / coefficient
                except ZeroDivisionError:
                    percent = 0
                obs.obs_data_set_int(filter_settings, "opacity", int(percent))
                obs.obs_source_update(fade, filter_settings)
                if self.duration // self.refresh_rate <= 3:
                    obs.obs_source_filter_remove(source, fade)
                    self.duration = 0
    def set_crop(self, inOut):
        # Set crop filter dimensions
        totalFrames = int(self.zoom_d / self.refresh_rate)

        source = obs.obs_get_source_by_name(self.source_name)
        crop = obs.obs_source_get_filter_by_name(source, "ZoomCrop")

        if crop is None:  # create filter
            _s = obs.obs_data_create()
            obs.obs_data_set_bool(_s, "relative", False)
            f = obs.obs_source_create_private("crop_filter", "ZoomCrop", _s)
            obs.obs_source_filter_add(source, f)
            obs.obs_source_release(f)
            obs.obs_data_release(_s)

        s = obs.obs_source_get_settings(crop)
        i = obs.obs_data_set_int

        if inOut == 0:
            self.zi_timer = 0
            if self.zo_timer < totalFrames:
                self.zo_timer += 1
                time = self.cubic_in_out(self.zo_timer / totalFrames)
                i(s, "left", int(((1 - time) * self.z_x)))
                i(s, "top", int(((1 - time) * self.z_y)))
                i(
                    s,
                    "cx",
                    self.zoom_w + int(time * (self.d_w - self.zoom_w)),
                )
                i(
                    s,
                    "cy",
                    self.zoom_h + int(time * (self.d_h - self.zoom_h)),
                )
            else:
                i(s, "left", 0)
                i(s, "top", 0)
                i(s, "cx", self.d_w)
                i(s, "cy", self.d_h)
        else:
            self.zo_timer = 0
            if self.zi_timer < totalFrames:
                self.zi_timer += 1
                time = self.cubic_in_out(self.zi_timer / totalFrames)
                i(s, "left", int(time * self.z_x))
                i(s, "top", int(time * self.z_y))
                i(
                    s,
                    "cx",
                    self.d_w - int(time * (self.d_w - self.zoom_w)),
                )
                i(
                    s,
                    "cy",
                    self.d_h - int(time * (self.d_h - self.zoom_h)),
                )
            else:
                i(s, "left", self.z_x)
                i(s, "top", self.z_y)
                i(s, "cx", self.zoom_w)
                i(s, "cy", self.zoom_h)

        obs.obs_source_update(crop, s)

        obs.obs_data_release(s)
        obs.obs_source_release(source)
        obs.obs_source_release(crop)

        if (inOut == 0) and (self.zo_timer >= totalFrames):
            obs.remove_current_callback()