New upstream version 21.0.2+dfsg1
This commit is contained in:
parent
1f1bbb3518
commit
baafb6325b
706 changed files with 49633 additions and 5044 deletions
119
UI/frontend-plugins/frontend-tools/data/scripts/clock-source.lua
Normal file
119
UI/frontend-plugins/frontend-tools/data/scripts/clock-source.lua
Normal file
|
|
@ -0,0 +1,119 @@
|
|||
obs = obslua
|
||||
bit = require("bit")
|
||||
|
||||
source_def = {}
|
||||
source_def.id = "lua_clock_source"
|
||||
source_def.output_flags = bit.bor(obs.OBS_SOURCE_VIDEO, obs.OBS_SOURCE_CUSTOM_DRAW)
|
||||
|
||||
function image_source_load(image, file)
|
||||
obs.obs_enter_graphics();
|
||||
obs.gs_image_file_free(image);
|
||||
obs.obs_leave_graphics();
|
||||
|
||||
obs.gs_image_file_init(image, file);
|
||||
|
||||
obs.obs_enter_graphics();
|
||||
obs.gs_image_file_init_texture(image);
|
||||
obs.obs_leave_graphics();
|
||||
|
||||
if not image.loaded then
|
||||
print("failed to load texture " .. file);
|
||||
end
|
||||
end
|
||||
|
||||
source_def.get_name = function()
|
||||
return "Lua Clock"
|
||||
end
|
||||
|
||||
source_def.create = function(source, settings)
|
||||
local data = {}
|
||||
data.image = obs.gs_image_file()
|
||||
data.hour_image = obs.gs_image_file()
|
||||
data.minute_image = obs.gs_image_file()
|
||||
data.second_image = obs.gs_image_file()
|
||||
|
||||
image_source_load(data.image, script_path() .. "clock-source/dial.png")
|
||||
image_source_load(data.hour_image, script_path() .. "clock-source/hour.png")
|
||||
image_source_load(data.minute_image, script_path() .. "clock-source/minute.png")
|
||||
image_source_load(data.second_image, script_path() .. "clock-source/second.png")
|
||||
|
||||
return data
|
||||
end
|
||||
|
||||
source_def.destroy = function(data)
|
||||
obs.obs_enter_graphics();
|
||||
obs.gs_image_file_free(data.image);
|
||||
obs.gs_image_file_free(data.hour_image);
|
||||
obs.gs_image_file_free(data.minute_image);
|
||||
obs.gs_image_file_free(data.second_image);
|
||||
obs.obs_leave_graphics();
|
||||
end
|
||||
|
||||
source_def.video_render = function(data, effect)
|
||||
if not data.image.texture then
|
||||
return;
|
||||
end
|
||||
|
||||
local time = os.date("*t")
|
||||
local seconds = time.sec
|
||||
local mins = time.min + seconds / 60.0;
|
||||
local hours = time.hour + (mins * 60.0) / 3600.0;
|
||||
|
||||
effect = obs.obs_get_base_effect(obs.OBS_EFFECT_DEFAULT)
|
||||
|
||||
obs.gs_blend_state_push()
|
||||
obs.gs_reset_blend_state()
|
||||
|
||||
while obs.gs_effect_loop(effect, "Draw") do
|
||||
obs.obs_source_draw(data.image.texture, 0, 0, data.image.cx, data.image.cy, false);
|
||||
end
|
||||
|
||||
obs.gs_matrix_push()
|
||||
obs.gs_matrix_translate3f(250, 250, 0)
|
||||
obs.gs_matrix_rotaa4f(0.0, 0.0, 1.0, 2 * math.pi / 60 * mins);
|
||||
obs.gs_matrix_translate3f(-250, -250, 0)
|
||||
|
||||
while obs.gs_effect_loop(effect, "Draw") do
|
||||
obs.obs_source_draw(data.minute_image.texture, 0, 0, data.image.cx, data.image.cy, false);
|
||||
end
|
||||
|
||||
obs.gs_matrix_pop()
|
||||
|
||||
obs.gs_matrix_push()
|
||||
obs.gs_matrix_translate3f(250, 250, 0)
|
||||
obs.gs_matrix_rotaa4f(0.0, 0.0, 1.0, 2.0 * math.pi / 12 * hours);
|
||||
obs.gs_matrix_translate3f(-250, -250, 0)
|
||||
|
||||
while obs.gs_effect_loop(effect, "Draw") do
|
||||
obs.obs_source_draw(data.hour_image.texture, 0, 0, data.image.cx, data.image.cy, false);
|
||||
end
|
||||
|
||||
obs.gs_matrix_pop()
|
||||
|
||||
obs.gs_matrix_push()
|
||||
obs.gs_matrix_translate3f(250, 250, 0)
|
||||
obs.gs_matrix_rotaa4f(0.0, 0.0, 1.0, 2 * math.pi / 60 * seconds);
|
||||
obs.gs_matrix_translate3f(-250, -250, 0)
|
||||
|
||||
while obs.gs_effect_loop(effect, "Draw") do
|
||||
obs.obs_source_draw(data.second_image.texture, 0, 0, data.image.cx, data.image.cy, false);
|
||||
end
|
||||
|
||||
obs.gs_matrix_pop()
|
||||
|
||||
obs.gs_blend_state_pop()
|
||||
end
|
||||
|
||||
source_def.get_width = function(data)
|
||||
return 500
|
||||
end
|
||||
|
||||
source_def.get_height = function(data)
|
||||
return 500
|
||||
end
|
||||
|
||||
function script_description()
|
||||
return "Adds a \"Lua Clock\" source which draws an animated analog clock."
|
||||
end
|
||||
|
||||
obs.obs_register_source(source_def)
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 26 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 1.6 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 1.7 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 2 KiB |
180
UI/frontend-plugins/frontend-tools/data/scripts/countdown.lua
Normal file
180
UI/frontend-plugins/frontend-tools/data/scripts/countdown.lua
Normal file
|
|
@ -0,0 +1,180 @@
|
|||
obs = obslua
|
||||
source_name = ""
|
||||
total_seconds = 0
|
||||
|
||||
cur_seconds = 0
|
||||
last_text = ""
|
||||
stop_text = ""
|
||||
activated = false
|
||||
|
||||
hotkey_id = obs.OBS_INVALID_HOTKEY_ID
|
||||
|
||||
-- Function to set the time text
|
||||
function set_time_text()
|
||||
local seconds = math.floor(cur_seconds % 60)
|
||||
local total_minutes = math.floor(cur_seconds / 60)
|
||||
local minutes = math.floor(total_minutes % 60)
|
||||
local hours = math.floor(total_minutes / 60)
|
||||
local text = string.format("%02d:%02d:%02d", hours, minutes, seconds)
|
||||
|
||||
if cur_seconds < 1 then
|
||||
text = stop_text
|
||||
end
|
||||
|
||||
if text ~= last_text then
|
||||
local source = obs.obs_get_source_by_name(source_name)
|
||||
if source ~= nil then
|
||||
local settings = obs.obs_data_create()
|
||||
obs.obs_data_set_string(settings, "text", text)
|
||||
obs.obs_source_update(source, settings)
|
||||
obs.obs_data_release(settings)
|
||||
obs.obs_source_release(source)
|
||||
end
|
||||
end
|
||||
|
||||
last_text = text
|
||||
end
|
||||
|
||||
function timer_callback()
|
||||
cur_seconds = cur_seconds - 1
|
||||
if cur_seconds < 0 then
|
||||
obs.remove_current_callback()
|
||||
cur_seconds = 0
|
||||
end
|
||||
|
||||
set_time_text()
|
||||
end
|
||||
|
||||
function activate(activating)
|
||||
if activated == activating then
|
||||
return
|
||||
end
|
||||
|
||||
activated = activating
|
||||
|
||||
if activating then
|
||||
cur_seconds = total_seconds
|
||||
set_time_text()
|
||||
obs.timer_add(timer_callback, 1000)
|
||||
else
|
||||
obs.timer_remove(timer_callback)
|
||||
end
|
||||
end
|
||||
|
||||
-- Called when a source is activated/deactivated
|
||||
function activate_signal(cd, activating)
|
||||
local source = obs.calldata_source(cd, "source")
|
||||
if source ~= nil then
|
||||
local name = obs.obs_source_get_name(source)
|
||||
if (name == source_name) then
|
||||
activate(activating)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function source_activated(cd)
|
||||
activate_signal(cd, true)
|
||||
end
|
||||
|
||||
function source_deactivated(cd)
|
||||
activate_signal(cd, false)
|
||||
end
|
||||
|
||||
function reset(pressed)
|
||||
if not pressed then
|
||||
return
|
||||
end
|
||||
|
||||
activate(false)
|
||||
local source = obs.obs_get_source_by_name(source_name)
|
||||
if source ~= nil then
|
||||
local active = obs.obs_source_active(source)
|
||||
obs.obs_source_release(source)
|
||||
activate(active)
|
||||
end
|
||||
end
|
||||
|
||||
function reset_button_clicked(props, p)
|
||||
reset(true)
|
||||
return false
|
||||
end
|
||||
|
||||
----------------------------------------------------------
|
||||
|
||||
-- A function named script_properties defines the properties that the user
|
||||
-- can change for the entire script module itself
|
||||
function script_properties()
|
||||
local props = obs.obs_properties_create()
|
||||
obs.obs_properties_add_int(props, "duration", "Duration (minutes)", 1, 100000, 1)
|
||||
|
||||
local p = obs.obs_properties_add_list(props, "source", "Text Source", obs.OBS_COMBO_TYPE_EDITABLE, obs.OBS_COMBO_FORMAT_STRING)
|
||||
local sources = obs.obs_enum_sources()
|
||||
if sources ~= nil then
|
||||
for _, source in ipairs(sources) do
|
||||
source_id = obs.obs_source_get_id(source)
|
||||
if source_id == "text_gdiplus" or source_id == "text_ft2_source" then
|
||||
local name = obs.obs_source_get_name(source)
|
||||
obs.obs_property_list_add_string(p, name, name)
|
||||
end
|
||||
end
|
||||
end
|
||||
obs.source_list_release(sources)
|
||||
|
||||
obs.obs_properties_add_text(props, "stop_text", "Final Text", obs.OBS_TEXT_DEFAULT)
|
||||
obs.obs_properties_add_button(props, "reset_button", "Reset Timer", reset_button_clicked)
|
||||
|
||||
return props
|
||||
end
|
||||
|
||||
-- A function named script_description returns the description shown to
|
||||
-- the user
|
||||
function script_description()
|
||||
return "Sets a text source to act as a countdown timer when the source is active.\n\nMade by Jim"
|
||||
end
|
||||
|
||||
-- A function named script_update will be called when settings are changed
|
||||
function script_update(settings)
|
||||
activate(false)
|
||||
|
||||
total_seconds = obs.obs_data_get_int(settings, "duration") * 60
|
||||
source_name = obs.obs_data_get_string(settings, "source")
|
||||
stop_text = obs.obs_data_get_string(settings, "stop_text")
|
||||
|
||||
reset(true)
|
||||
end
|
||||
|
||||
-- A function named script_defaults will be called to set the default settings
|
||||
function script_defaults(settings)
|
||||
obs.obs_data_set_default_int(settings, "duration", 5)
|
||||
obs.obs_data_set_default_string(settings, "stop_text", "Starting soon (tm)")
|
||||
end
|
||||
|
||||
-- A function named script_save will be called when the script is saved
|
||||
--
|
||||
-- NOTE: This function is usually used for saving extra data (such as in this
|
||||
-- case, a hotkey's save data). Settings set via the properties are saved
|
||||
-- automatically.
|
||||
function script_save(settings)
|
||||
local hotkey_save_array = obs.obs_hotkey_save(hotkey_id)
|
||||
obs.obs_data_set_array(settings, "reset_hotkey", hotkey_save_array)
|
||||
obs.obs_data_array_release(hotkey_save_array)
|
||||
end
|
||||
|
||||
-- a function named script_load will be called on startup
|
||||
function script_load(settings)
|
||||
-- Connect hotkey and activation/deactivation signal callbacks
|
||||
--
|
||||
-- NOTE: These particular script callbacks do not necessarily have to
|
||||
-- be disconnected, as callbacks will automatically destroy themselves
|
||||
-- if the script is unloaded. So there's no real need to manually
|
||||
-- disconnect callbacks that are intended to last until the script is
|
||||
-- unloaded.
|
||||
local sh = obs.obs_get_signal_handler()
|
||||
obs.signal_handler_connect(sh, "source_activate", source_activated)
|
||||
obs.signal_handler_connect(sh, "source_deactivate", source_deactivated)
|
||||
|
||||
hotkey_id = obs.obs_hotkey_register_frontend("reset_timer_thingy", "Reset Timer", reset)
|
||||
local hotkey_save_array = obs.obs_data_get_array(settings, "reset_hotkey")
|
||||
obs.obs_hotkey_load(hotkey_id, hotkey_save_array)
|
||||
obs.obs_data_array_release(hotkey_save_array)
|
||||
end
|
||||
|
|
@ -0,0 +1,134 @@
|
|||
obs = obslua
|
||||
source_name = ""
|
||||
hotkey_id = obs.OBS_INVALID_HOTKEY_ID
|
||||
attempts = 0
|
||||
|
||||
----------------------------------------------------------
|
||||
|
||||
function try_play()
|
||||
local replay_buffer = obs.obs_frontend_get_replay_buffer_output()
|
||||
if replay_buffer == nil then
|
||||
obs.remove_current_callback()
|
||||
return
|
||||
end
|
||||
|
||||
-- Call the procedure of the replay buffer named "get_last_replay" to
|
||||
-- get the last replay created by the replay buffer
|
||||
local cd = obs.calldata_create()
|
||||
local ph = obs.obs_output_get_proc_handler(replay_buffer)
|
||||
obs.proc_handler_call(ph, "get_last_replay", cd)
|
||||
local path = obs.calldata_string(cd, "path")
|
||||
obs.calldata_destroy(cd)
|
||||
|
||||
obs.obs_output_release(replay_buffer)
|
||||
|
||||
-- If the path is valid and the source exists, update it with the
|
||||
-- replay file to play back the replay. Otherwise, stop attempting to
|
||||
-- replay after 10 seconds
|
||||
if path == nil then
|
||||
attempts = attempts + 1
|
||||
if attempts >= 10 then
|
||||
obs.remove_current_callback()
|
||||
end
|
||||
else
|
||||
local source = obs.obs_get_source_by_name(source_name)
|
||||
if source ~= nil then
|
||||
local settings = obs.obs_data_create()
|
||||
obs.obs_data_set_string(settings, "local_file", path)
|
||||
obs.obs_data_set_bool(settings, "is_local_file", true)
|
||||
obs.obs_data_set_bool(settings, "close_when_inactive", true)
|
||||
obs.obs_data_set_bool(settings, "restart_on_activate", true)
|
||||
|
||||
-- updating will automatically cause the source to
|
||||
-- refresh if the source is currently active, otherwise
|
||||
-- the source will play whenever its scene is activated
|
||||
obs.obs_source_update(source, settings)
|
||||
|
||||
obs.obs_data_release(settings)
|
||||
obs.obs_source_release(source)
|
||||
end
|
||||
|
||||
obs.remove_current_callback()
|
||||
end
|
||||
end
|
||||
|
||||
-- The "Instant Replay" hotkey callback
|
||||
function instant_replay(pressed)
|
||||
if not pressed then
|
||||
return
|
||||
end
|
||||
|
||||
local replay_buffer = obs.obs_frontend_get_replay_buffer_output()
|
||||
if replay_buffer ~= nil then
|
||||
-- Call the procedure of the replay buffer named "get_last_replay" to
|
||||
-- get the last replay created by the replay buffer
|
||||
local ph = obs.obs_output_get_proc_handler(replay_buffer)
|
||||
obs.proc_handler_call(ph, "save", nil)
|
||||
|
||||
-- Set a 1-second timer to attempt playback every 1 second
|
||||
-- until the replay is available
|
||||
if obs.obs_output_active(replay_buffer) then
|
||||
attempts = 0
|
||||
obs.timer_add(try_play, 1000)
|
||||
else
|
||||
obs.script_log(obs.LOG_WARNING, "Tried to save an instant replay, but the replay buffer is not active!")
|
||||
end
|
||||
|
||||
obs.obs_output_release(replay_buffer)
|
||||
else
|
||||
obs.script_log(obs.LOG_WARNING, "Tried to save an instant replay, but found no active replay buffer!")
|
||||
end
|
||||
end
|
||||
|
||||
----------------------------------------------------------
|
||||
|
||||
-- A function named script_update will be called when settings are changed
|
||||
function script_update(settings)
|
||||
source_name = obs.obs_data_get_string(settings, "source")
|
||||
end
|
||||
|
||||
-- A function named script_description returns the description shown to
|
||||
-- the user
|
||||
function script_description()
|
||||
return "When the \"Instant Replay\" hotkey is triggered, saves a replay with the replay buffer, and then plays it in a media source as soon as the replay is ready. Requires an active replay buffer.\n\nMade by Jim"
|
||||
end
|
||||
|
||||
-- A function named script_properties defines the properties that the user
|
||||
-- can change for the entire script module itself
|
||||
function script_properties()
|
||||
props = obs.obs_properties_create()
|
||||
|
||||
local p = obs.obs_properties_add_list(props, "source", "Media Source", obs.OBS_COMBO_TYPE_EDITABLE, obs.OBS_COMBO_FORMAT_STRING)
|
||||
local sources = obs.obs_enum_sources()
|
||||
if sources ~= nil then
|
||||
for _, source in ipairs(sources) do
|
||||
source_id = obs.obs_source_get_id(source)
|
||||
if source_id == "ffmpeg_source" then
|
||||
local name = obs.obs_source_get_name(source)
|
||||
obs.obs_property_list_add_string(p, name, name)
|
||||
end
|
||||
end
|
||||
end
|
||||
obs.source_list_release(sources)
|
||||
|
||||
return props
|
||||
end
|
||||
|
||||
-- A function named script_load will be called on startup
|
||||
function script_load(settings)
|
||||
hotkey_id = obs.obs_hotkey_register_frontend("instant_replay.trigger", "Instant Replay", instant_replay)
|
||||
local hotkey_save_array = obs.obs_data_get_array(settings, "instant_replay.trigger")
|
||||
obs.obs_hotkey_load(hotkey_id, hotkey_save_array)
|
||||
obs.obs_data_array_release(hotkey_save_array)
|
||||
end
|
||||
|
||||
-- A function named script_save will be called when the script is saved
|
||||
--
|
||||
-- NOTE: This function is usually used for saving extra data (such as in this
|
||||
-- case, a hotkey's save data). Settings set via the properties are saved
|
||||
-- automatically.
|
||||
function script_save(settings)
|
||||
local hotkey_save_array = obs.obs_hotkey_save(hotkey_id)
|
||||
obs.obs_data_set_array(settings, "instant_replay.trigger", hotkey_save_array)
|
||||
obs.obs_data_array_release(hotkey_save_array)
|
||||
end
|
||||
77
UI/frontend-plugins/frontend-tools/data/scripts/url-text.py
Normal file
77
UI/frontend-plugins/frontend-tools/data/scripts/url-text.py
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
import obspython as obs
|
||||
import urllib.request
|
||||
import urllib.error
|
||||
|
||||
url = ""
|
||||
interval = 30
|
||||
source_name = ""
|
||||
|
||||
# ------------------------------------------------------------
|
||||
|
||||
def update_text():
|
||||
global url
|
||||
global interval
|
||||
global source_name
|
||||
|
||||
source = obs.obs_get_source_by_name(source_name)
|
||||
if source is not None:
|
||||
try:
|
||||
with urllib.request.urlopen(url) as response:
|
||||
data = response.read()
|
||||
text = data.decode('utf-8')
|
||||
|
||||
settings = obs.obs_data_create()
|
||||
obs.obs_data_set_string(settings, "text", text)
|
||||
obs.obs_source_update(source, settings)
|
||||
obs.obs_data_release(settings)
|
||||
|
||||
except urllib.error.URLError as err:
|
||||
obs.script_log(obs.LOG_WARNING, "Error opening URL '" + url + "': " + err.reason)
|
||||
obs.remove_current_callback()
|
||||
|
||||
obs.obs_source_release(source)
|
||||
|
||||
def refresh_pressed(props, prop):
|
||||
update_text()
|
||||
|
||||
# ------------------------------------------------------------
|
||||
|
||||
def script_description():
|
||||
return "Updates a text source to the text retrieved from a URL at every specified interval.\n\nBy Jim"
|
||||
|
||||
def script_update(settings):
|
||||
global url
|
||||
global interval
|
||||
global source_name
|
||||
|
||||
url = obs.obs_data_get_string(settings, "url")
|
||||
interval = obs.obs_data_get_int(settings, "interval")
|
||||
source_name = obs.obs_data_get_string(settings, "source")
|
||||
|
||||
obs.timer_remove(update_text)
|
||||
|
||||
if url != "" and source_name != "":
|
||||
obs.timer_add(update_text, interval * 1000)
|
||||
|
||||
def script_defaults(settings):
|
||||
obs.obs_data_set_default_int(settings, "interval", 30)
|
||||
|
||||
def script_properties():
|
||||
props = obs.obs_properties_create()
|
||||
|
||||
obs.obs_properties_add_text(props, "url", "URL", obs.OBS_TEXT_DEFAULT)
|
||||
obs.obs_properties_add_int(props, "interval", "Update Interval (seconds)", 5, 3600, 1)
|
||||
|
||||
p = obs.obs_properties_add_list(props, "source", "Text Source", obs.OBS_COMBO_TYPE_EDITABLE, obs.OBS_COMBO_FORMAT_STRING)
|
||||
sources = obs.obs_enum_sources()
|
||||
if sources is not None:
|
||||
for source in sources:
|
||||
source_id = obs.obs_source_get_id(source)
|
||||
if source_id == "text_gdiplus" or source_id == "text_ft2_source":
|
||||
name = obs.obs_source_get_name(source)
|
||||
obs.obs_property_list_add_string(p, name, name)
|
||||
|
||||
obs.source_list_release(sources)
|
||||
|
||||
obs.obs_properties_add_button(props, "button", "Refresh", refresh_pressed)
|
||||
return props
|
||||
Loading…
Add table
Add a link
Reference in a new issue