Skip to content

Instantly share code, notes, and snippets.

@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 / obj3d.lua
Last active April 4, 2026 17:58
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"
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
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