adb screenrecord Secondary Display 来自 dumpsys 中列出的显示

adb screenrecord Secondary Display from listed displays in dumpsys

您好,我正在尝试通过 HDMI 连接并录制连接到 Android 设备的辅助显示器。我能够成功地截屏并记录主 Android Phone 屏幕,但我有一个显示到第二个屏幕的设备。

我想做什么:

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

目前做了什么:

  1. 确定是否有显示:

    亚行shell 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 options

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

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

屏幕录制可以很好地捕获 phone 显示器,但作为 type-C HDMI 输出迷你投影仪的外部显示器不能,目标是捕获和记录通过 HDMI 发送的其他应用程序 no重要的应用程序。第三方应用程序投影的内容与 Android Phone 屏幕上显示的内容不同(例如 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源代码你可以看看。