From da690cd5159692a25a490ce26b48681872c21526 Mon Sep 17 00:00:00 2001 From: tholimet Date: Wed, 12 Jun 2024 16:46:52 +0200 Subject: [PATCH] =?UTF-8?q?T=C3=A9l=C3=A9verser=20les=20fichiers=20vers=20?= =?UTF-8?q?"methode2"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Pour le scriptboth, c'est le script pour envoyer deux flux en même temps, Pour le switchprofil, c'est le script pour changer de profil pour lancer plusieurs flux en utilisant des informations différentes --- methode2/scriptboth.lua | 128 ++++++++++++++++++++++++++++++++ methode2/switchprofilstream.lua | 60 +++++++++++++++ 2 files changed, 188 insertions(+) create mode 100644 methode2/scriptboth.lua create mode 100644 methode2/switchprofilstream.lua diff --git a/methode2/scriptboth.lua b/methode2/scriptboth.lua new file mode 100644 index 0000000..29cdb1b --- /dev/null +++ b/methode2/scriptboth.lua @@ -0,0 +1,128 @@ +obs = obslua + +youtube_output = nil +twitch_output = nil + +function script_description() + return "Multi RTMP Output - Diffusez sur plusieurs serveurs RTMP simultanément. Configurer les serveurs RTMP pour YouTube et Twitch." +end + +function script_properties() + local props = obs.obs_properties_create() + + -- Paramètres YouTube + obs.obs_properties_add_text(props, "youtube_server", "YouTube RTMP Server", obs.OBS_TEXT_DEFAULT) + obs.obs_properties_add_text(props, "youtube_key", "YouTube Stream Key", obs.OBS_TEXT_PASSWORD) + + -- Paramètres Twitch + obs.obs_properties_add_text(props, "twitch_server", "Twitch RTMP Server", obs.OBS_TEXT_DEFAULT) + obs.obs_properties_add_text(props, "twitch_key", "Twitch Stream Key", obs.OBS_TEXT_PASSWORD) + + obs.obs_properties_add_button(props, "start_youtube", "Commencer YouTube Streaming", start_youtube_streaming) + obs.obs_properties_add_button(props, "stop_youtube", "Arrêter YouTube Streaming", stop_youtube_streaming) + obs.obs_properties_add_button(props, "start_twitch", "Commencer Twitch Streaming", start_twitch_streaming) + obs.obs_properties_add_button(props, "stop_twitch", "Arrêter Twitch Streaming", stop_twitch_streaming) + obs.obs_properties_add_button(props, "start_both", "Commencer les deux Streaming", start_both_streaming) + obs.obs_properties_add_button(props, "stop_both", "Arrêter les deux Streaming", stop_both_streaming) + + return props +end + +function script_update(settings) + local youtube_server = obs.obs_data_get_string(settings, "youtube_server") + local youtube_key = obs.obs_data_get_string(settings, "youtube_key") + local twitch_server = obs.obs_data_get_string(settings, "twitch_server") + local twitch_key = obs.obs_data_get_string(settings, "twitch_key") + + if youtube_server ~= "" and youtube_key ~= "" then + local youtube_settings = obs.obs_data_create() + obs.obs_data_set_string(youtube_settings, "server", youtube_server) + obs.obs_data_set_string(youtube_settings, "key", youtube_key) + + local youtube_service = obs.obs_service_create("rtmp_custom", "YouTube RTMP Service", youtube_settings, nil) + youtube_output = obs.obs_output_create("rtmp_output", "YouTube RTMP Output", nil, nil) + + obs.obs_output_set_service(youtube_output, youtube_service) + obs.obs_data_release(youtube_settings) + + obs.script_log(obs.LOG_INFO, "YouTube RTMP output configured") + end + + if twitch_server ~= "" and twitch_key ~= "" then + local twitch_settings = obs.obs_data_create() + obs.obs_data_set_string(twitch_settings, "server", twitch_server) + obs.obs_data_set_string(twitch_settings, "key", twitch_key) + + local twitch_service = obs.obs_service_create("rtmp_custom", "Twitch RTMP Service", twitch_settings, nil) + twitch_output = obs.obs_output_create("rtmp_output", "Twitch RTMP Output", nil, nil) + + obs.obs_output_set_service(twitch_output, twitch_service) + obs.obs_data_release(twitch_settings) + + obs.script_log(obs.LOG_INFO, "Twitch RTMP output configured") + end +end + +function start_youtube_streaming(props, prop) + if youtube_output then + if not obs.obs_output_active(youtube_output) then + local success = obs.obs_output_start(youtube_output) + if success then + obs.script_log(obs.LOG_INFO, "Started YouTube RTMP output") + else + obs.script_log(obs.LOG_ERROR, "Failed to start YouTube RTMP output") + end + end + end +end + +function stop_youtube_streaming(props, prop) + if youtube_output then + if obs.obs_output_active(youtube_output) then + obs.obs_output_stop(youtube_output) + obs.script_log(obs.LOG_INFO, "Stopped YouTube RTMP output") + end + end +end + +function start_twitch_streaming(props, prop) + if twitch_output then + if not obs.obs_output_active(twitch_output) then + local success = obs.obs_output_start(twitch_output) + if success then + obs.script_log(obs.LOG_INFO, "Started Twitch RTMP output") + else + obs.script_log(obs.LOG_ERROR, "Failed to start Twitch RTMP output") + end + end + end +end + +function stop_twitch_streaming(props, prop) + if twitch_output then + if obs.obs_output_active(twitch_output) then + obs.obs_output_stop(twitch_output) + obs.script_log(obs.LOG_INFO, "Stopped Twitch RTMP output") + end + end +end + +function start_both_streaming(props, prop) + start_youtube_streaming(props, prop) + start_twitch_streaming(props, prop) +end + +function stop_both_streaming(props, prop) + stop_youtube_streaming(props, prop) + stop_twitch_streaming(props, prop) +end + +function script_load(settings) + obs.obs_frontend_add_event_callback(function(event) + if event == obs.OBS_FRONTEND_EVENT_STREAMING_STARTING then + start_both_streaming(nil, nil) + elseif event == obs.OBS_FRONTEND_EVENT_STREAMING_STOPPING then + stop_both_streaming(nil, nil) + end + end) +end diff --git a/methode2/switchprofilstream.lua b/methode2/switchprofilstream.lua new file mode 100644 index 0000000..e07b897 --- /dev/null +++ b/methode2/switchprofilstream.lua @@ -0,0 +1,60 @@ +obs = obslua + +youtube_server = "rtmp://a.rtmp.youtube.com/live2" +youtube_key = "VOTRE_CLE_YOUTUBE" +twitch_server = "rtmp://live.twitch.tv/app" +twitch_key = "VOTRE_CLE_TWITCH" + +youtube_output = nil +twitch_output = nil + +function script_description() + return "Script pour lancer des streams simultanés sur YouTube et Twitch." +end + +function script_properties() + local props = obs.obs_properties_create() + + obs.obs_properties_add_button(props, "start_both", "Lancer YouTube et Twitch", start_both_streams) + obs.obs_properties_add_button(props, "stop_both", "Arrêter YouTube et Twitch", stop_both_streams) + + return props +end + +function start_both_streams(props, p) + start_stream(youtube_server, youtube_key, "YouTube") + start_stream(twitch_server, twitch_key, "Twitch") +end + +function stop_both_streams(props, p) + stop_stream(youtube_output) + stop_stream(twitch_output) +end + +function start_stream(server, key, name) + local settings = obs.obs_data_create() + obs.obs_data_set_string(settings, "server", server) + obs.obs_data_set_string(settings, "key", key) + + local service = obs.obs_service_create("rtmp_common", "service", settings, nil) + local output = obs.obs_output_create("rtmp_output", name, nil, nil) + obs.obs_output_set_service(output, service) + + obs.obs_output_start(output) + + if name == "YouTube" then + youtube_output = output + elseif name == "Twitch" then + twitch_output = output + end + + obs.obs_data_release(settings) + obs.obs_service_release(service) +end + +function stop_stream(output) + if output and obs.obs_output_active(output) then + obs.obs_output_stop(output) + obs.obs_output_release(output) + end +end