ndi tools下载,需注册账号才能下载。需要的朋友可以私信。
ndi5 sdk,有win版和linux版,以下截图是win版
ndi receive #include <cstdio> #ifdef _WIN32 int main(int argc, char* argv[]) // Wait until there is one source // We now have at least one source, so we create a receiver to look at it. // Connect to our sources // Destroy the NDI finder. We needed to have access to the pointers to p_sources[0] // Run for one minute switch (NDIlib_recv_capture_v2(pNDI_recv, &video_frame, &audio_frame, nullptr, 5000)) // Video data // Audio data // Destroy the receiver // Not required, but nice // Finished |
ndi send #include <cstdio> #ifdef _WIN32 int main(int argc, char* argv[]) // We are going to create a 1920x1080 interlaced frame at 29.97Hz. // Run for one minute // Send 200 frames // We now submit the frame. Note that this call will be clocked so that we end up submitting at exactly 29.97fps. // Just display something helpful // Free the video frame // Destroy the NDI sender // Not required, but nice // Success |
小结:
1 ndi sdk提供了多个demo,如果要实现产品化,需要自行添加处理逻辑。比如本人的项目中添加了定时扫描ndi source上线下线,动态管理各ndi source的状态。
2 其次要注意recv video,audio frame之后,要free释放堆内存,否则运行一段时间,内存泄露,导致程序异常崩溃。
3 如果部署云端(服务端和客户端在云端的同一局域网内),find ndi时,接收端需要设置发送到的ip地址列表,逗号分隔。局域网内设置ip list,都能接收到局域网内所有ndi source。
4 send ndi,可以设置ndi名称,比如设置output1,ndi tools monitor工具查看,
ubuntu (output1),ubuntu是机器名,自动加的。
5 同一台主机,可能有多个ndi source