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
View swig_and_ctypes.py
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
View shader1.lua
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
View audio_level.lua
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
View TriggerHotkeyByName.lua
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[[
View concurrent.lua
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
View is_it_group_item_question_mark.lua
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
Created November 6, 2020 15:51
Double pointers obslua
View print_properties.lua
-- 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;
@upgradeQ
upgradeQ / beep.lua
Last active September 19, 2022 13:43
Beep when the replay buffer has fully stopped. [windows]
View beep.lua
local obs = obslua
local ffi = require("ffi")
ffi.cdef[[
void Beep(int freq,int dur);
]]
function beep()
ffi.C.Beep(7000,300)
end
@upgradeQ
upgradeQ / init.vim
Last active October 10, 2023 14:33
neovim config
View init.vim
call plug#begin()
Plug 'folke/tokyonight.nvim'
"---------------------------------------------------------------------------------
Plug 'mbbill/undotree', { 'on': 'UndotreeToggle' }
map <F3> :UndotreeToggle<cr>
"---------------------------------------------------------------------------------
Plug 'mhinz/vim-startify',{'on':'Startify'}
nnoremap <F4> :Startify <cr>
"---------------------------------------------------------------------------------
Plug 'psf/black', {'on':'Black'}
View read_aiofiles.py
import aiofiles
import asyncio
async def red():
print('where did lost ')
async with aiofiles.open('data.txt', mode='r') as f:
contents = await f.read()
return contents
events = asyncio.get_event_loop()
try:
coro = events.run_until_complete(red())