How to disable GPU/OpenGL rendering?

daniel0228

New Member
How to disable OpenGL rendering?

I am using the OBS SDK to develop a program that can play videos to an AJA SDI card. However, I noticed that the CPU usage is too high because it's not utilizing the GPU. This is due to the use of OpenGL rendering. However, I only want to use FFmpeg to play videos to the SDI card without any transition effects. How can I disable the rendering feature?
1715317555998.png

1715317661677.png

------------------this is my program
class AjaCapture
{
public:
AjaCapture(){}
~AjaCapture(){}
bool init_obs();
void SetupFFmpeg();
private:
int set_scene_source();
private:
obs_source_t* fadeTransition = nullptr;
obs_source_t* cutTransition = nullptr;
obs_scene_t* scene = nullptr;
obs_source_t* captureSource;
obs_properties_t* properties;
OBSEncoder aacTrack[MAX_AUDIO_MIXES];
std::string aacEncoderID[MAX_AUDIO_MIXES];
};


void my_init_obs(){
string cfg_path = "/home/viashare/dz/obs-config2";
if (!obs_startup("en-US", cfg_path.c_str(), NULL))
{
return;
}
string plugin_path = "/home/share/obs/obs-studio/install/lib/obs-plugins";
string data_path = "/home/share/obs/obs-studio/install/share/obs/obs-plugins/%module%";
obs_add_module_path(plugin_path.c_str(), data_path.c_str());
obs_load_all_modules();
std::cout << "my init obs" << std::endl;
}
obs_data_t* g_setting = obs_data_create();

bool AjaCapture::init_obs()
{
struct obs_audio_info ai;
ai.samples_per_sec = 48000;
ai.speakers =SPEAKERS_STEREO;

if (!obs_reset_audio(&ai)){
return false;
}
struct obs_video_info ovi;
...
ovi.graphics_module = "libobs-opengl.so.30";
ovi.output_format = VIDEO_FORMAT_NV12;VIDEO_FORMAT_I420;

if (0 != obs_reset_video(&ovi)){
return false;
}
if (0 != set_scene_source())
return false;
return true;
}
int AjaCapture::set_scene_source()
{
obs_set_output_source(SOURCE_CHANNEL_TRANSITION, nullptr);
obs_set_output_source(SOURCE_CHANNEL_AUDIO_OUTPUT, nullptr);
obs_set_output_source(SOURCE_CHANNEL_AUDIO_INPUT, nullptr);
size_t idx = 0;
const char* id;
while (obs_enum_transition_types(idx++, &id)) {
const char* name = obs_source_get_display_name(id);
if (!obs_is_source_configurable(id)) {
obs_source_t* tr = obs_source_create_private(id, name, NULL);
if (strcmp(id, "cut_transition") == 0)
cutTransition = tr;
}
}
if (!cutTransition)
{
return -1;
}
obs_set_output_source(SOURCE_CHANNEL_TRANSITION, cutTransition);
obs_source_release(cutTransition);
scene = obs_scene_create("MyScene");
if (!scene)
{
return -2;
}
obs_source_t* s = obs_get_output_source(SOURCE_CHANNEL_TRANSITION);
obs_transition_set(s, obs_scene_get_source(scene));
obs_source_release(s);

captureSource = obs_source_create("ffmpeg_source", "FFmpegSource", NULL, nullptr);

if (!captureSource) {
std::cout << "********************** SOURCE failed:" << ", line: " << __LINE__ << std::endl;
return -3;
}
obs_scene_atomic_update(scene, AddSource, captureSource);
obs_data_t* setting = obs_data_create();
obs_data_t* curSetting = obs_source_get_settings(captureSource);
obs_data_apply(setting, curSetting);
obs_data_release(curSetting);
obs_data_set_string(setting, "local_file", "/home/share/10min_timecode.mxf");
obs_data_set_bool(setting, "is_local_file", true);
obs_source_update(captureSource, setting);
obs_data_release(setting);
return 0;
}

void AjaCapture::SetupFFmpeg()
{

std::cout << "aja output mode ================" << std::endl;
//{"aja_output_id":"aja_output","ui_prop_device":"Kona4_00U49390","ui_prop_vid_fmt":5,"ui_prop_output":2,"ui_prop_pix_fmt":1}
obs_data_t* settings = obs_data_create();
obs_data_set_string(settings, "ui_prop_device", "Kona4_00U49390");
obs_data_set_int(settings, "ui_prop_output", 1);
obs_data_set_string(settings, "aja_output_id", "aja_output");
obs_data_set_int(settings, "ui_prop_vid_fmt", NTV2_FORMAT_1080i_5994);
obs_data_set_int(settings, "ui_prop_pix_fmt", NTV2_FBF_8BIT_YCBCR);
obs_data_set_int(settings, "ui_prop_sdi_transport", 0);
obs_data_set_int(settings, "ui_prop_sdi_transport_4k", 1);

fileOutput = obs_output_create("aja_output", "aja_output", settings, NULL);
for (int i = 0; i < MAX_AUDIO_MIXES; i++) {
std::stringstream ss;
ss << "adv_aac" << i;
std::string name = ss.str();
aacTrack = obs_audio_encoder_create("ffmpeg_aac", name.c_str(), nullptr, i, nullptr);
if (!aacTrack){
std::cout << "aac track failed" << std::endl;
return;
}
obs_encoder_set_audio(aacTrack, obs_get_audio());
}
obs_data_t* curSetting = obs_output_get_settings(fileOutput);
if (curSetting){
std::cout << "curSetting------------------" << std::endl;
}
obs_output_set_mixer(fileOutput, 1);
obs_output_set_media(fileOutput, obs_get_video(), obs_get_audio());
obs_output_update(fileOutput, settings);
obs_data_release(settings);
}

int main() {
std::cout << "hello " << std::endl;
signal(SIGINT, signalHandler);
my_init_obs();

{
AjaCapture ow;
ow.init_obs();
std::cout << "begin rec" << std::endl;
ow.SetupFFmpeg();

if(!obs_output_start(fileOutput)){
std::cout << "outpu start failed============================" << std::endl;
return -1;
}
sleep(100000);
std::cout << "begin stop2" << std::endl;
obs_output_force_stop(fileOutput);// obs_output_stop(fileOutput);
}
std::cout << "end rec" << std::endl;
return 0;
}
 
Top