adb screenrecord dumpsys中列出的显示中的辅助显示

问题描述

您好,我正在尝试通过HDMI连接并屏幕记录附加到Android设备的辅助显示器。我可以成功捕获并记录Android Phone主屏幕,但是我的设备可以显示第二个屏幕。

要做什么:

  1. 屏幕记录第二个显示屏而不是主显示屏上显示内容
  2. 应用程序的显示是通过HDMI从Android设备输出的 到投影

当前已完成的操作:

  1. 确定显示内容是否存在:

    adb外壳 c1q:/ $ dumpsys SurfaceFlinger --display-id 显示16409431620704260(HWC显示1):port = 4 pnpId = PRO displayName =“ projector” 显示19261213734341249(HWC显示0):port = 129 pnpId = QCM displayName =“ ss_dsi_panel _”

  2. 尝试连接:

当尝试屏幕记录第二个显示(HWC显示1)时,adb似乎没有选择切换到列出的特定显示的选项,shell screenrecord --help选项也没有

127|c1q:/ $ screenrecord --help
Usage: screenrecord [options] <filename>

Android screenrecord v1.2.  Records the device's display to a .mp4 file.

Options:
--size WIDTHxHEIGHT
    Set the video size,e.g. "1280x720".  Default is the device's main
    display resolution (if supported),1280x720 if not.  For best results,use a size supported by the AVC encoder.
--bit-rate RATE
    Set the video bit rate,in bits per second.  Value may be specified as
    bits or megabits,e.g. '4000000' is equivalent to '4M'.  Default 20Mbps.
--bugreport
    Add additional information,such as a timestamp overlay,that is helpful
    in videos captured to illustrate bugs.
--time-limit TIME
    Set the maximum recording time,in seconds.  Default / maximum is 180.
--verbose
    display interesting information on stdout.
--help
    Show this message.

Recording continues until Ctrl-C is hit or the time limit is reached.

我浏览了下面列出的一些文档:

Android AOSP在这里https://source.android.com/devices/tech/display/multi_display/displays#static

source screenrecord.cpp: https://android.googlesource.com/platform/frameworks/av/+/ae6965ae7664aaea489a8d58358035610075c9af/cmds/screenrecord/screenrecord.cpp

屏幕记录可以很好地捕获电话显示,但外部显示器(C型HDMI输出微型投影仪)则不能,目标是捕获和记录通过HDMI发送到其他应用程序,无论应用程序如何。第三方应用程序投射的内容与Android手机屏幕(例如Android Watch)上显示内容有所不同,并且希望从桌面无线记录。

adb tcpip 5555
adb connect [Device IP Address]:5555
adb shell screenrecord /sdcard/Downloads/test.mp4

这工作得很好,下一部分是录制第二个显示

display 16409431620704260 (HWC display 1): port=4 pnpId=PRO displayName="projector"

我确实知道可以为您自己的Android应用程序创建一个实现来访问显示,但是我想记录任何应用程序,切换到特定的显示并在那里记录,SurfaceFlinger看到了它,但是没有看到连接到它的选项并记录

解决方法

screenrecord版本1.3(Android 11)提供了选择其他显示器的可能性。特别是,--display-id是提供ID或投影所必须使用的参数。

Android screenrecord v1.3.  Records the device's display to a .mp4 file.

Options:
--size WIDTHxHEIGHT
    Set the video size,e.g. "1280x720".  Default is the device's main
    display resolution (if supported),1280x720 if not.  For best results,use a size supported by the AVC encoder.
--bit-rate RATE
    Set the video bit rate,in bits per second.  Value may be specified as
    bits or megabits,e.g. '4000000' is equivalent to '4M'.  Default 20Mbps.
--bugreport
    Add additional information,such as a timestamp overlay,that is helpful
    in videos captured to illustrate bugs.
--time-limit TIME
    Set the maximum recording time,in seconds.  Default / maximum is 180.
--display-id ID
    specify the physical display ID to record. Default is the primary display.
    see "dumpsys SurfaceFlinger --display-id" for valid display IDs.
--verbose
    Display interesting information on stdout.
--help
    Show this message.

Recording continues until Ctrl-C is hit or the time limit is reached.

这里是screenrecord的源代码。