Created
February 20, 2018 04:48
-
-
Save DDRBoxman/e9b057388e0590d9a435688b1b100a95 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
obs = obslua | |
local bit = require("bit") | |
source_name = "" | |
function resize(pressed) | |
if not pressed then | |
return | |
end | |
local source = obs.obs_get_source_by_name(source_name) | |
if source ~= nil then | |
local videoInfo = obs.obs_video_info() | |
obs.obs_get_video_info(videoInfo) | |
videoInfo.base_width = obs.obs_source_get_width(source) | |
videoInfo.base_height = obs.obs_source_get_height(source) | |
videoInfo.output_width = obs.obs_source_get_width(source) | |
videoInfo.output_height = obs.obs_source_get_height(source) | |
local result = obs.obs_reset_video(videoInfo) | |
print(result) | |
obs.obs_source_release(source) | |
end | |
end | |
function resize_button_clicked(props, p) | |
resize(true) | |
return false | |
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_properties defines the properties that the user | |
-- can change for the entire script module itself | |
function script_properties() | |
local props = obs.obs_properties_create() | |
local p = obs.obs_properties_add_list(props, "source", "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 | |
-- only allow selecting video sources | |
if bit.band(obs.obs_source_get_output_flags(source), obs.OBS_SOURCE_VIDEO) == obs.OBS_SOURCE_VIDEO 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_button(props, "resize_button", "Resize", resize_button_clicked) | |
return props | |
end | |
-- a function named script_load will be called on startup | |
function script_load(settings) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment