thomasWind
New Member
Sorry I post this thread at wrong place....
Hello!
I'm working to use obs api to push stream of specific window. The profile is 4k-4k-60fps.
When I use Api to do this work, the cpu usage is 6% higher than using obs-studio software. GPU stays in high usage. (If I use software, gpu usage would decrease slowly.
I read the source code of obs and set the same values.
Also I tried the transition to contain scene, but the usage is still high.
Here are the rough steps I use api :
Hello!
I'm working to use obs api to push stream of specific window. The profile is 4k-4k-60fps.
When I use Api to do this work, the cpu usage is 6% higher than using obs-studio software. GPU stays in high usage. (If I use software, gpu usage would decrease slowly.
I read the source code of obs and set the same values.
Also I tried the transition to contain scene, but the usage is still high.
Here are the rough steps I use api :
Code:
// firstly start_up
auto res = obs_startup("en-US", nullptr, nullptr); //"en-US""zh-CN"
obs_data_t *settings = obs_data_create();
obs_data_set_bool(settings, "BrowserHWAccel", true);
obs_apply_private_data(settings);
obs_data_release(settings);
//load_module
obs_add_module_path("../Debug/obs-plugins/64bit", "../Debug/data/obs-plugins/%module%");
obs_load_all_modules();
//create scene and set output
obs_scene_t *scene = obs_scene_create(this->scene_name.c_str());
if (!scene)
return;
obs_set_output_source(0, obs_scene_get_source(scene));
//reset video
struct obs_video_info ovi;
ovi.adapter = 0;
ovi.fps_num = fps;
ovi.fps_den = 1;
ovi.graphics_module = "libobs-d3d11.dll";
ovi.output_format = VIDEO_FORMAT_NV12;
ovi.scale_type = OBS_SCALE_BICUBIC;
ovi.colorspace = VIDEO_CS_709;
ovi.range = VIDEO_RANGE_PARTIAL;
ovi.gpu_conversion = true;
ovi.base_width = base_width;
ovi.base_height = base_height;
ovi.output_width = output_width;
ovi.output_height = output_height;
std::cout << "start reset video" << std::endl;
int rtn = obs_reset_video(&ovi);
//create window-capture source and add to scene
this->addCaptureSource();
obs_scene_add(scene, this->m_window_source)
//create encoder
m_h264Streaming = obs_video_encoder_create("obs_x264",...)
m_AacStreaming = obs_audio_encoder_create("CoreAudio_AAC"...)
//create rtmp service
m_rtmpService = obs_service_create("rtmp_common",...)
m_streamOutput = obs_output_create("rtmp_output",...)
obs_encoder_set_video(m_h264Streaming, obs_get_video());
obs_encoder_set_audio(m_AacStreaming, obs_get_audio());
//start live
obs_output_set_video_encoder(m_streamOutput, m_h264Streaming);
obs_output_set_audio_encoder(m_streamOutput, m_AacStreaming, 0);
obs_output_set_service(m_streamOutput, m_rtmpService);
auto res = obs_output_start(m_streamOutput);
std::cout << "start_living res=" << res << std::endl;
if (!res)
{
return false;
}
return true;