androidadbandroid-sourcescreen-recordingexternal-display

adb screenrecord Secondary Display from listed displays in dumpsys


Hello I am trying to connect and screenrecord a secondary display attached to the Android Device through HDMI. I am successfully able to screen capture and record the main Android Phone Screen but I have a device that displays to second screen.

What I am trying to do:

  1. Screen record what appears on a second display and not the main display
  2. The display from the application is through HDMI out from the Android device to the projection

What has been currently done:

  1. Identify if displays are there:

    adb shell c1q:/ $ dumpsys SurfaceFlinger --display-id Display 16409431620704260 (HWC display 1): port=4 pnpId=PRO displayName="projector" Display 19261213734341249 (HWC display 0): port=129 pnpId=QCM displayName="ss_dsi_panel_"

  2. Attempt to connect:

When attempting to screenrecord the Second display (HWC display 1), adb does not seem to have a option to switch to a specific listed display neither does the 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.

I have looked through some documentation listed below:

Android AOSP here: 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

The screenrecord works fine for capturing the phone display, but the external display which is a type-C HDMI output mini projector does not, the goal is to capture and record other applications sent to through HDMI no matter the application. The Third Party Application projects something different than what appears on the Android Phone screen (ex. Android Watch) and wanting to record this wirelessly from desktop.

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

This works perfectly fine, the next part is recording the second display

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

I do understand a implementation can be created for your own Android Application to access the display but I am wanting to record any application, switch to a specific display and record there, SurfaceFlinger sees it but not seeing a option to connect to it and record


Solution

  • The possibility of selecting a different display is provided by screenrecord version 1.3 (Android 11). In particular, --display-id is the parameter you have to use to provide the ID or your projection.

    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.
    

    And here screenrecord source code you can look at.