Screen recording on Android 4.4 KitKat

While doing a demo of an Android app, I was looking for a way to easily capture the device screen. Turns out it’s not that simple.

There are quite a few solutions available on the Play store, but they either require a rooted device or taking screenshots resulting in choppy video at best, or a slideshow at worst. The Android emulators are also having performance issues, and not all of them have Google Play Services installed, which was required for my app.

Using a physical device, I went with Android 4.4’s built-in screen recorder that can be accessed from the command line. It usually results in a nice smooth recording, but you probably need a higher-end device. Apart from the choppy first couple of seconds, I had no issue with it on Samsung Galaxy S5 and the Galaxy Note 2 was quite acceptable as well.

Step-by-step

  • You have to install the Android SDK on your PC.
  • Using the SDK manager, download and install the platform tools package.
  • Enable developer options on the device and activate USB debugging.
  • Your device will need to be connected to the PC while recording.
  • Start/stop recording from the command line to save video to device storage.
  • Download video from device and profit.

Pre-requisites

If you are an Android developer and have everything installed on your PC, you can skip this section.

To install the Android SDK you need to install the Java JRE first. Chances are that you already have it, in which case the SDK installer will detect and use it automatically.

You also have to enable developer options on your Android device as shown in my previous post. In short, you need to go to Settings / About Device and tap the disabled Build Number option 7 times. After this the Developer Options will magically appear in the settings menu. Go to it and enable USB debugging.

Connect your device to the PC and authorise connection via the popup dialog if needed, then wait for you operating system to recognise your device and install all necessary drivers.

To make sure everything is working, open a command line window. In case the Android SDK is not in your path, navigate to the [Android SDK]/platform-tools folder. Run adb shell and see if you get a linux terminal prompt. If you do, type exit and you’re all set to start recording.

If you get a device not found error, you probably missed something and try connecting your device again. You can also try restarting the adb service by running adb kill-server, then adb start-server.

Recording

To start recording, run the following command from the command line:

adb shell screenrecord /sdcard/test.mp4

This will start a recording at the device’s resolution and it will run for 3 minutes, or until stopped by pressing Ctrl-C. Unfortunately 3 minutes is the maximum length you can record for, so if you need a longer video, prepare to do some editing. It also doesn’t record sound, so you would need to record it separately through the headphone jack and mix it together afterwards.

The /sdcard/test.mp4 part is the path it will save the video to on the device. Once recording is finished, that’s where you can download it from to your PC. In this case, it saves the video into the root folder of the device’s storage. If your device has different path layout, try downloading a file manager app from the Play store and find the path you want to save to.

You can also supply extra parameters to the command, to see all command line options, run adb shell screenrecord --help:

Usage: screenrecord [options] 

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

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

That’s it, now you can record your devices screen using a fast, native recorder. As always, feedback is always welcome, I’d love to know what recording performance other devices have.

Share Button
Tagged with:

Leave a Reply