In a previous post we described the capabilities of the Android SDK and Android Debug Bridge (adb) to generate user interaction events to debug and test the UI of an App. There are many other gems hidden inside Android that can be accessed through adb. Today we are looking into screenrecord, an application that lets you record a video of the device screen.

This service only works from version KitKat so make sure that your Android device is 4.4 or higher. To use the tool, you will first need to install the Android SDK in your PC and enable the USB debugging in your Android device (read here if you need help).

Now, connect your Android device to your PC with a USB cable, go to the platform-tools folder in the Android SDK directory ( C:\Program Files (x86)\Android\android-sdk\platform-tools in my PC installation) and start a terminal window.

The command to start the video recording is sent from the PC using the adb application but the actual recording and storage of the video is done by the Android device itself, without intervention of the PC.

This mechanism does not require to root your device, however there are many other applications that require a rooted device, that can launch a recording session directly from the device without requiring a PC. Apparently, if you are running Android Lollipop (5.x) you can find screen video recording Apps that require no root (I am using a Motorola G with Android 4.4)

The screenrecord service is launched from the PC. You can set a number of options: where the file will be stored (always in the Android device), the quality of the video or its length. All these options are described in the command documentation, as shown below:

>adb shell screenrecord --help
Usage: screenrecord [options] <filename>

Records the device's display to a .mp4 file.

    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 megabits per second. Default 4Mbps.
--time-limit TIME
    Set the maximum recording time, in seconds. Default / maximum is 180.
    Rotate the output 90 degrees.
    Display interesting information on stdout.
    Show this message.

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

The maximum allowed video duration is 3 minutes, but you can indicate a shorter duration or stop a recording session by hitting Control-C in your PC terminal. For instance, you can send this command to record a 15-second video:

>adb shell screenrecord --time-limit 15 /sdcard/testvideo.mp4


  • Unfortunately, Android does not record audio (at least on version 4.4), so if your App uses audio you will need to record and mix it through other tools.

  • If you want to capture the user interactions on the display, you can make them visible in the Settings menu: Settings -> Developer options -> Show Touches

adb also works over WiFi (detailed instructions can be found in our previous post), so you can record the video without being physically connected to your PC. This is especially useful if your Android USB socket is in use by a OTG device (e.g., a mouse).

First, we set the TCP/IP connection parameters:

> adb tcpip 5555
> adb connect

Then we disconnect the USB cable between the PC and the Android device, and type the video recording command:

adb shell screenrecord /sdcard/myvideo.mp4

I am positively shocked by the simplicity and quality of this tool. Judge by yourself watching the sample video that we have recorded while writing this article:

If you liked this content and don't want to miss future articles, you can subscribe to our mailing list and get notified!

About the Author