Edit this Doc Android Device Screen Streaming With Appium

Since Appium 1.16 there is a possibility to stream the screen of the device under test to one or more remote clients. The currently displayed content is broadcasted as configurable MJPEG stream over http protocol. This allows to observe automated test execution while it is running and catch possible issues earlier. Single MJPEG server supports multiple simultaneous clients that can receive screen updates at the same time. The framerate there depends on the server and device performance, but is close to the real time one and can reach up to 60 frames per second, especially with properly adjusted bitrate and/or scaled screen dimensions.

mobile: startScreenStreaming

Starts streaming of the device's screen. The streaming can only be started if all the requirements are met: - GStreamer binaries are installed on the server machine. For example, it can be installed using the following command on Mac OS: brew install gstreamer gst-plugins-base gst-plugins-good gst-plugins-bad gst-plugins-ugly gst-libav - The device under test has screenrecord utility available and the utility supports --output-format=h264 option. Emulators only have this utility since API 27. - The adb_screen_streaming server feature is enabled.

The command initializes low-level streaming with adb, pipes it to GStreamer pipeline, which converts h264-encoded frames into JPEG images and sends them to a TCP socket. At the end of this sequence there is Node.js http server, which wraps the TCP stream into HTTP protocol, so the video can be viewed with a normal browser. In case the streaming is already running the command just returns silently. Simultaneous streaming on multiple ports/with different configs is not supported. It is necessary to stop the current stream before starting a new one.

Supported arguments

Usage examples

Map<String, Object> args = new HashMap<>();
args.put("width", 1080);
args.put("height", 1920);
args.put("considerRotation", true);
args.put("quality", 45);
args.put("bitRate", 500000);
driver.executeScript("mobile: startScreenStreaming", args);
driver.execute_script('mobile: shell', {
    'width': 1080,
    'height': 1920,
    'considerRotation': True,
    'quality': 45,
    'bitRate': 500000,
})

mobile: stopScreenStreaming

Stops the running screen streaming session. If no session has been started before then no action is done. Note that screen streaming session is always stopped automatically as soon as the container driver session is terminated.

Usage examples

driver.executeScript("mobile: stopScreenStreaming");
driver.execute_script('mobile: stopScreenStreaming')