Accessing Video and Bitrate info in Lua scripts

wondible

New Member
I'd like to create a script to calculate bitrate tradeoffs and hopeful set the desired settings. However, I have not yet found a way to get the current OBS settings.

obs_get_video_info is not present in obslua, and I'm sure how to get a obs_video_info to pass to it.

obs_get_video appears to work, but no video_* functions seem to be available to work with it.

obs_enum_outputs is available, but requires a C function as an argument, and does not accept a Lua function (or I don't know to make a proper one)
 

wondible

New Member
I've figured out how to get width, height, and bitrate by looking up the default encoder name in the OBS source and using obs_get_encoder_by_name.

I've also gotten an output reference by looking up default output name. However, I am still unable to find the current FPS value. I currently believe the video_t objects have this information, but I have not found any functions exposed to Lua which can work with them.
 

wondible

New Member
Tyring to look up how to specify a callback led me to LuaJit FFI, and I recalled hearing that OBS uses LuaJit. I have been able to get the FPS by mapping additional functions, though I found the FFI interface only worked with the value from my own obs_get_video mapping.

Code:
ffi = require("ffi")

ffi.cdef[[

struct video_output;
typedef struct video_output video_t;

double video_output_get_frame_rate(const video_t *video);

video_t *obs_get_video(void);
]]

local obsffi = ffi.load("obs")
 

KuziaMother

New Member
very helpful information thx.
for convert Uint64 values i use
Code:
local to_value = tonumber(ffi.cast('uint64_t', ffi.cast('void *', any_uint64_value)))
Sample for convert rendering time
 
Top