当前位置: 首页 > news >正文

Linux(麒麟系统)多显示器屏幕录制

   Linux桌面设备在接入多显示器的情况下,有些只录主显示器,有些场景要单独录制每个显示器,X Window System支持多显示器配置和显示器列表获取,需要XRandR 1.5及以上版本,查看RandR version 命令:

xrandr --version

  使用xrandr查看显示器列表:

xrandr --listactivemonitors

  " --listactivemonitors" 详细说明:

  libXrandr提供了获取显示器列表的接口(Xrandr.h):

/** Copyright © 2000 Compaq Computer Corporation, Inc.* Copyright © 2002 Hewlett-Packard Company, Inc.* Copyright © 2006 Intel Corporation* Copyright © 2008 Red Hat, Inc.** Permission to use, copy, modify, distribute, and sell this software and its* documentation for any purpose is hereby granted without fee, provided that* the above copyright notice appear in all copies and that both that copyright* notice and this permission notice appear in supporting documentation, and* that the name of the copyright holders not be used in advertising or* publicity pertaining to distribution of the software without specific,* written prior permission.  The copyright holders make no representations* about the suitability of this software for any purpose.  It is provided "as* is" without express or implied warranty.** THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO* EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE* OF THIS SOFTWARE.** Author:  Jim Gettys, HP Labs, Hewlett-Packard, Inc.*	    Keith Packard, Intel Corporation*/#ifndef _XRANDR_H_
#define _XRANDR_H_#include <X11/extensions/randr.h>
#include <X11/extensions/Xrender.h>#include <X11/Xfuncproto.h>_XFUNCPROTOBEGINtypedef struct _XRRMonitorInfo {Atom name;Bool primary;Bool automatic;int noutput;int x;int y;int width;int height;int mwidth;int mheight;RROutput *outputs;
} XRRMonitorInfo;XRRMonitorInfo *
XRRAllocateMonitor(Display *dpy, int noutput);XRRMonitorInfo *
XRRGetMonitors(Display *dpy, Window window, Bool get_active, int *nmonitors);void
XRRSetMonitor(Display *dpy, Window window, XRRMonitorInfo *monitor);void
XRRDeleteMonitor(Display *dpy, Window window, Atom name);void
XRRFreeMonitors(XRRMonitorInfo *monitors);_XFUNCPROTOEND#endif /* _XRANDR_H_ */

  为方便集成调用,SDK提供了获取显示器列表和选择采集显示器的接口:

   /** Copyright (C) 1130758427@qq.com. All rights reserved. * 问题沟通微信:ldxevt*//** 获取active XRR-Monitor列表, X RandR 1.5及以上版本支持(用:"xrandr --version"查看版本)* x_display_name:传入实际使用的名称或者NULL,调用XOpenDisplay时使用.* monitors: 预分配的XRR-Monitor数组* monitors_array_size: 预分配的XRR-Monitor数组长度* out_count: 返回实际的XRR-Monitor数量* 成功返回:NT_ERC_OK, 如果返回值是:NT_ERC_MORE_DATA, 说明预分配的数组长度不够, 请分配更大的数组再尝试.*/NT_UINT32 NT_API NT_PB_GetXRRMonitors(NT_PCSTR x_display_name, NT_PB_XRR_MonitorBaseInfo* monitors, NT_INT32 monitors_array_size, NT_INT32* out_count);/** 设置要采集的XRRMonitor id, 采集X屏幕时使用* xrr_monitor_id: -1:采集所有屏幕, SDK默认为-1.*/NT_UINT32 NT_API NT_PB_SetCaptureXRRMonitor(NT_HANDLE handle, NT_INT64 xrr_monitor_id);

   上述接口可以实现只采集主显示器, 或选择要采集的显示器. 对于监控场景支持每个显示器分别采集录制,然后输出RTSP或RTMP流; 另外考虑到网络带宽和设备性能等限制, 支持屏幕采集后缩放, 然后再编码输出.如有其他问题请联系qq: 1130758427, 微信: ldxevt .


http://www.mrgr.cn/news/34227.html

相关文章:

  • Vue前端开发,组件及组件的使用
  • 大语言模型理论基础
  • ssm103宠物领养系统+vue(论文+源码)_kaic
  • FreeSWITCH的介绍及应用
  • Vector Optimization – Stride
  • 导游基础知识丨各民族民俗知识节选
  • 软件测试实验室如何利用GB/T25000标准建立测试技术体系
  • 828华为云征文 | 云服务器Flexus X实例,Docker集成搭建NGINX
  • 超详细超实用!!!AI编程之cursor编写官网新增轮播效果(三)
  • 【二分算法】模板总结
  • 系统分析师12:系统规划
  • 沁恒CH32V307读写flash出错
  • 远程升级频频失败?你可能忽略了模组差分包…
  • 学生宿舍管理:Spring Boot框架的高效策略
  • Apache Iceberg 概述
  • HOJ网站开启https访问 申请免费SSL证书 部署证书详细操作指南
  • 现代前端框架实战指南:React、Vue.js、Angular核心概念与应用
  • 【数列求值 / B】
  • 手把手教您轻松实现微信/QQ/TIM多开,消息防撤回!
  • 机械手末端快换技术:工业自动化的强大新动力
  • python:django项目知识点02——搭建简易授权码核销系统
  • 记录我的常用开发地址
  • 骨传导耳机推荐什么牌子好?盘点五款高性价比热门机型推荐!
  • Azure Pipeline 常用任务记录
  • Kubernetes之Kubectl命令行工具操作
  • 【C++】哈希桶