Skip to content

Instantly share code, notes, and snippets.

S = obslua
local function skip_tick_render(ctx)
local target = S.obs_filter_get_target(ctx.source)
local width, height;
if target == nil then width = 0; height = 0; else
width = S.obs_source_get_base_width(target)
height = S.obs_source_get_base_height(target)
end
ctx.width, ctx.height = width , height
obs = obslua
S = obs
ffi = require "ffi"
function try_load_library(alias, name)
if ffi.os == "OSX" then name = name .. ".0.dylib" end
ok, _G[alias] = pcall(ffi.load, name)
if not ok then
print(("WARNING:%s:Has failed to load, %s is nil"):format(name, alias))
end
@upgradeQ
upgradeQ / obj3d.lua
Last active March 8, 2024 18:23
3D model viewer (.obj format) for OBS Studio
-------------------------------------------------------
-- version 0.1.2 .obj 3D model viewer for OBS Studio --
-- upgradeQ 2024 --
-- Released to the Public Domain --
-------------------------------------------------------
local S = obslua
local time = 0.0
local vertex_num = 0
local clear_color = S.vec4()
local MODEL_FILENAME = "suzanne.obj"
@upgradeQ
upgradeQ / swig_and_ctypes.py
Created May 16, 2023 16:59
Get video frames programmatically in Obs Studio obspython
from types import SimpleNamespace as _G
from ctypes import *
from ctypes.util import find_library
import obspython as S
G, ffi = _G(), _G()
ffi.obsffi = CDLL(find_library("obs")) # ? PyDLL
G.lock = False
G.start_delay = 2
G.duration = 0
@upgradeQ
upgradeQ / shader1.lua
Last active May 2, 2023 16:44
Simple multi pass shaders for OBS Studio
S = obslua
local ffi = require"ffi"
local C = ffi.C
local _OR = bit.bor
ffi.cdef[[
typedef struct {int x, y;} Point;
bool GetCursorPos(Point *lpPoint);
]]
RESOLUTION = {2560,1440};
local mouse_pos = ffi.new("Point")
@upgradeQ
upgradeQ / audio_level.lua
Created November 22, 2020 18:13
audio volume level. RIP source_volume_level
local obs = obslua
local ffi = require 'ffi'
local jit = require 'jit'
local obsffi
if ffi.os == "OSX" then
obsffi = ffi.load("obs.0.dylib")
else
obsffi = ffi.load("obs")
end
@upgradeQ
upgradeQ / TriggerHotkeyByName.lua
Created November 22, 2020 18:11
Hotkey enumeration via obs_enum_hotkeys
local obs = obslua
local ffi = require 'ffi'
local obsffi
if ffi.os == "OSX" then
obsffi = ffi.load("obs.0.dylib")
else
obsffi = ffi.load("obs")
end
ffi.cdef[[
local obs = obslua
local coroutine = require 'coroutine'
local math = require 'math'
local Timer = {}
function Timer:init(o)
o = o or {}
setmetatable(o,self)
self.__index = self
return o
local obs = obslua
--- name of a scene item
local source_name = ''
--- get the name of the current scene
local function current_scene_name()
local source = obs.obs_frontend_get_current_scene()
local name = obs.obs_source_get_name(source)
obs.obs_source_release(source)
@upgradeQ
upgradeQ / print_properties.lua
Last active September 25, 2024 17:56
Double pointers obslua
-- https://obsproject.com/forum/threads/how-to-enumerate-script-properties-in-lua.83406/#post-397381
-- create source with name tmp , then add Color Correction filter named color
local obs = obslua
local ffi = require("ffi")
local obsffi
ffi.cdef[[
struct obs_source;