从Ubuntu21.04开始, 系统默认的显示服务器是Wayland, 不再是xorg, 这就导致以前所有基于x window的屏幕采集工具都不能使用,需要针对Wayland开发新的屏幕采集实现。目前看来Wayland可能是个趋势,说不定将来国产操作系统也会切换到Wayland上去。未雨绸缪, 自己的推送采集SDK先提前支持上.
通过查找各种资料,推送SDK算是支持了,对外提供的调用SDK代码和以前一样。下面是部分调用片段:
NT_HANDLE push_handle = nullptr;
if (NT_ERC_OK != push_api->Open(&push_handle, NT_PB_E_VIDEO_OPTION_SCREEN, NT_PB_E_AUDIO_OPTION_CAPTURE_SPEAKER, 0, NULL))
{
return nullptr;
}
push_api->SetScreenClip(push_handle, 0, 0, 1280, 720);
push_api->SetFrameRate(push_handle, dst_fps); // 帧率设置
push_api->SetVideoBitRate(push_handle, 2000); // 平均码率2000kbps
push_api->SetVideoQualityV2(push_handle, 26);
push_api->SetVideoMaxBitRate(push_handle, 4000); // 最大码率4000kbps
push_api->SetVideoKeyFrameInterval(push_handle, dst_fps*2); // 关键帧间隔
push_api->SetVideoEncoderProfile(push_handle, 3); // h264 baseline
push_api->SetVideoEncoderSpeed(push_handle, 3); // 编码速度设置到3
if ( NT_ERC_OK != push_api->SetURL(push_handle, rtmp_url.c_str(), NULL) )
{
push_api->Close(push_handle);
push_handle = nullptr;
return nullptr;
}
if ( NT_ERC_OK != push_api->StartPublisher(push_handle, NULL) )
{
push_api->Close(push_handle);
push_handle = nullptr;
return nullptr;
}
关于Wayland屏幕窗口采集更多问题可以看github,或联系QQ1130758427