def remove_output_rec_callbacks(output_name): output = obs.obs_get_output_by_name(output_name) signal_handler = obs.obs_output_get_signal_handler(output) obs.signal_handler_disconnect(signal_handler, "start", load_start_url_reccb) obs.signal_handler_disconnect(signal_handler, "stop", load_stop_url_reccb) obs.obs_output_release(output)
def register_output_stream_callbacks(output_name): output = obs.obs_get_output_by_name(output_name) signal_handler = obs.obs_output_get_signal_handler(output) obs.signal_handler_connect(signal_handler, "start", load_start_url_streamcb) obs.signal_handler_connect(signal_handler, "stop", load_stop_url_streamcb) obs.obs_output_release(output)
def update_recording_callback(reconnect=True): if opencastplug.recording_signal_handler is not None: obs.signal_handler_disconnect(opencastplug.recording_signal_handler, "stop", cb_recording_finished) if reconnect: opencastplug.recording_signal_handler = obs.obs_output_get_signal_handler( obs.obs_frontend_get_recording_output()) obs.signal_handler_connect(opencastplug.recording_signal_handler, "stop", cb_recording_finished)
def script_update(settings): logger.debug('script_update') cached_settings["use_default_fps"] = obs.obs_data_get_bool(settings, "use_default_fps") cached_settings["custom_fps"] = obs.obs_data_get_int(settings, "custom_fps") cached_settings["enabled"] = obs.obs_data_get_bool(settings, "enabled") if cached_settings["enabled"]: logger.info('Registering start and stop handlers.') signal_handler = obs.obs_output_get_signal_handler(output) try: obs.signal_handler_connect(signal_handler, 'start', recording_start_handler) obs.signal_handler_connect(signal_handler, 'stop', recording_stopped_handler) except RuntimeError as e: logger.critical(f'Disregarding error when connecting start and stop handlers: {e}') else: logger.info('Disconnecting start and stop handlers.') signal_handler = obs.obs_output_get_signal_handler(output) obs.signal_handler_disconnect(signal_handler, 'start', recording_start_handler) if not is_being_recorded: obs.signal_handler_disconnect(signal_handler, 'stop', recording_stopped_handler) logger.debug(f'cached_settings: {cached_settings}')
def script_load(settings): # Check for wrong DPI scaling or resolution # This warning doen't really work if DPI scaling is off if not (win32api.GetSystemMetrics(0) == 1920 and win32api.GetSystemMetrics(1) == 1080): raise Exception( 'Ошибка! Программа поддерживает запись только в разрешении 1920х1080 с настройкой DPI scaling в Windows на 100%.' ) recording_signal_handler = obs.obs_output_get_signal_handler( obs.obs_frontend_get_recording_output()) obs.signal_handler_connect(recording_signal_handler, "starting", cb_recording_starting) obs.signal_handler_connect(recording_signal_handler, "stop", cb_recording_stop) print('Script loaded')
def script_load(settings): """ * Sets up triggers on obs events (such as start recording and stop recording) * Creates pipe. Pipe is immutable handle, which never changes after initialization * Calls init_client_seeker() to find a client """ log_threadsafe(obs.LOG_DEBUG, 'Plugin loaded') recording_signal_handler = obs.obs_output_get_signal_handler(obs.obs_frontend_get_recording_output()) obs.signal_handler_connect(recording_signal_handler, "start", trigger_recording_started) obs.signal_handler_connect(recording_signal_handler, "stop", trigger_recording_stopped) global pipe pipe = win32pipe.CreateNamedPipe( r'\\.\pipe\%s' % pipe_name(), win32pipe.PIPE_ACCESS_DUPLEX, win32pipe.PIPE_TYPE_MESSAGE | win32pipe.PIPE_READMODE_MESSAGE | win32pipe.PIPE_WAIT, 1, 65536, 65536, 0, None) #have_client_to_speak_with = False #It is the default value, but it must be intact init_client_seeker()
def script_load(settings): handler = obs.obs_output_get_signal_handler( obs.obs_frontend_get_recording_output()) obs.signal_handler_connect(handler, "start", cb_recording("start")) obs.signal_handler_connect(handler, "stop", cb_recording("stop"))
def create_match_video_output(): global output, output_video_encoder, output_audio_encoder print(f'Creating match video OBS output') if output: print(f'WARNING: Match video OBS output already exists') print() return # create output for match video files output_settings = obs.obs_data_create() obs.obs_data_set_bool(output_settings, 'allow_overwrite', True) output = obs.obs_output_create('ffmpeg_muxer', 'match_file_output', output_settings, None) obs.obs_data_release(output_settings) if not output: print(f'ERROR: Could not create match video output') print() return # create output video encoder for match video files output_video_settings = obs.obs_data_create() obs.obs_data_set_string(output_video_settings, 'rate_control', 'CBR') obs.obs_data_set_int(output_video_settings, 'bitrate', obs.obs_data_get_int(settings, 'video_bitrate')) output_video_encoder = obs.obs_video_encoder_create( obs.obs_data_get_string(settings, 'video_encoder'), 'match_video_encoder', output_video_settings, None) obs.obs_data_release(output_video_settings) if not output_video_encoder: print(f'ERROR: Could not create match video encoder') destroy_match_video_output() return if not obs.obs_encoder_get_codec(output_video_encoder): print(f'ERROR: Invalid codec for match video encoder') destroy_match_video_output() return obs.obs_encoder_set_video(output_video_encoder, obs.obs_get_video()) if not obs.obs_encoder_video(output_video_encoder): print(f'ERROR: Could not set video handler') destroy_match_video_output() return obs.obs_output_set_video_encoder(output, output_video_encoder) if not obs.obs_output_get_video_encoder(output): print(f'ERROR: Could not set video encoder to output') destroy_match_video_output() return # create output audio encoder for match video files output_audio_settings = obs.obs_data_create() obs.obs_data_set_string(output_audio_settings, 'rate_control', 'CBR') obs.obs_data_set_int(output_audio_settings, 'bitrate', obs.obs_data_get_int(settings, 'audio_bitrate')) output_audio_encoder = obs.obs_audio_encoder_create( obs.obs_data_get_string(settings, 'audio_encoder'), 'match_audio_encoder', output_audio_settings, 0, None) obs.obs_data_release(output_audio_settings) if not output_audio_encoder: print(f'ERROR: Could not create match audio encoder') destroy_match_video_output() return if not obs.obs_encoder_get_codec(output_audio_encoder): print(f'ERROR: Invalid codec for match audio encoder') destroy_match_video_output() return obs.obs_encoder_set_audio(output_audio_encoder, obs.obs_get_audio()) if not obs.obs_encoder_audio(output_audio_encoder): print(f'ERROR: Could not set audio handler') destroy_match_video_output() return obs.obs_output_set_audio_encoder(output, output_audio_encoder, 0) if not obs.obs_output_get_audio_encoder(output, 0): print(f'ERROR: Could not set audio encoder to output') destroy_match_video_output() return # set handler for output signals handler = obs.obs_output_get_signal_handler(output) obs.signal_handler_connect(handler, 'stop', stop_recording_action) print()