Alexis THOLIMET
da690cd515
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
129 lines
5.1 KiB
Lua
129 lines
5.1 KiB
Lua
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
|