Open Osiris-Team opened 1 month ago
Hi, I've taken a look at your code and it seems like everything should work fine, so I am not sure what the issue may be.
My guess would be that there is an issue creating the obs_video_info
object. I am not familiar with Java or the JNA library that you are using, but I'm guessing it may be related to JNA not correctly handling the initialization of the object.
static inline bool valid_video_params(const struct video_output_info *info)
{
return info->height != 0 && info->width != 0 && info->fps_den != 0 &&
info->fps_num != 0;
}
From what I can tell, it looks like you are initializing the object correctly; output_height
, output_width
, fps_den
, and fps_num
should be non-zero values. Could you maybe try to print out the properties of the object before calling obs_reset_video
to double check if its valid?
@lulzsun I am currently porting this bad boy over to Java and encountering the error above. Any help would be really appreciated! Log:
Show code
```java package com.osiris.sandbox; import com.sun.jna.*; import java.io.File; import java.util.*; public class LibOBS { static { String path = System.getProperty("jna.library.path"); path += File.pathSeparator + "C:\\Program Files (x86)\\obs-studio\\bin\\64bit" + File.pathSeparator + "C:\\Program Files (x86)\\obs-studio\\obs-plugins\\64bit"; System.setProperty("jna.library.path", path); } public interface ObsLibrary extends Library { ObsLibrary INSTANCE = Native.load("obs", ObsLibrary.class); String obs_get_version_string(); boolean obs_initialized(); boolean obs_startup(String locale, String module_config_path, Pointer profiler_name); void obs_shutdown(); void obs_add_data_path(String path); void obs_add_module_path(String bin_path, String data_path); boolean obs_reset_audio(obs_audio_info avi); int obs_reset_video(obs_video_info ovi); void obs_load_all_modules(); void obs_log_loaded_modules(); void obs_post_load_modules(); Pointer obs_source_create(String id, String name, Pointer settings, Pointer hotkey_data); void obs_set_output_source(int channel, Pointer source); Pointer obs_data_create(); void obs_data_set_bool(Pointer data, String name, boolean value); void obs_data_set_string(Pointer data, String name, String value); void obs_data_set_int(Pointer data, String name, long value); Pointer obs_video_encoder_create(String id, String name, Pointer settings, Pointer hotkey_data); void obs_encoder_set_video(Pointer encoder, Pointer video); void obs_data_release(Pointer data); Pointer obs_audio_encoder_create(String id, String name, Pointer settings, long track, Pointer hotkey_data); void obs_encoder_set_audio(Pointer encoder, Pointer audio); Pointer obs_output_create(String id, String name, Pointer settings, Pointer hotkey_data); void obs_output_set_video_encoder(Pointer output, Pointer encoder); void obs_output_set_audio_encoder(Pointer output, Pointer encoder, long track); boolean obs_output_start(Pointer output); String obs_output_get_last_error(Pointer output); Pointer obs_output_get_proc_handler(Pointer output); String obs_output_get_id(Pointer output); Pointer obs_get_video(); int obs_get_video_info(obs_video_info ovi); } public static class VideoResetError { public static final int OBS_VIDEO_SUCCESS = 0; public static final int OBS_VIDEO_FAIL = -1; public static final int OBS_VIDEO_NOT_SUPPORTED = -2; public static final int OBS_VIDEO_INVALID_PARAM = -3; public static final int OBS_VIDEO_CURRENTLY_ACTIVE = -4; public static final int OBS_VIDEO_MODULE_NOT_FOUND = -5; public static String getErrorString(int error) { switch (error) { case OBS_VIDEO_SUCCESS: return "Success"; case OBS_VIDEO_FAIL: return "Fail"; case OBS_VIDEO_NOT_SUPPORTED: return "Not Supported"; case OBS_VIDEO_INVALID_PARAM: return "Invalid Parameter"; case OBS_VIDEO_CURRENTLY_ACTIVE: return "Video Currently Active"; case OBS_VIDEO_MODULE_NOT_FOUND: return "Module Not Found"; default: return "Unknown Error"; } } } public static class obs_audio_info extends Structure { public int samples_per_sec; public int speakers; @Override protected List