Saturday, 21 March 2015

Recording Android Device screen with ADB


There are various app / recording software's that you get in market to record your Android device videos. But there is an inbuilt way too similar to the the backup method we saw in one of the previous posts - 
From Android 4.4 Kitkat (API 19) there is an inbuilt command to take screencast  of your device. You can read the same in Kitkat official documentation -

"With the screen recording utility, you can capture video of your device screen contents and store the video as an MP4 file on the device. You can record at any device-supported resolution and bitrate you want, and the output retains the aspect ratio of the display. By default, the utility selects a resolution equal or close to the device's display resolution in the current orientation. When you are done recording, you can share the video directly from your device or pull the MP4 file to your host computer for post-production."

So now you can record your device , save it in mp4 format and share it easily. For this you will need Android SDK (ADB ) .

Note : You can also do this directly from your device but your device should be rooted for that.

Prerequisites :  Android device running Android Kitkat (API 19) or higher, USB cable for debugging and machine with adb setup.

 Getting Started with Recording

Connect your device to your machine having ADB setup.  Ensure debugging is enabled. Next open command prompt and type -

C:\Users\athakur>adb devices
List of devices attached
ZX1B32P5VL      device

Make sure you see your device listed as shown above. If it does not show up you may want to troubleshoot it first -

After this you can connect to your device using adb shell and execute the  screenrecord command to start the video capture. Command to be executed is -
  • screenrecord filePathToMP4File
For example I can do something like following

C:\Users\athakur>adb shell
shell@condor_umtsds:/ $ screenrecord /sdcard/test.mp4
shell@condor_umtsds:/ $ exit
C:\Users\athakur>adb pull /sdcard/test.mp4 .
3197 KB/s (2076164 bytes in 0.634s)

Note : Notice after video has been recorded I have pulled it back to my Laptop using adb pull  command.

Yes it's that easy :)

You can read more about the command and it's option by executing following command -
  • adb shell screenrecord --help

Attention! - Not available in Emulators

This does not work on Android Emulator's. This is a bug and does not look like is going to be fixed in near future. If you try above approach on Emulator command will fail with following Error -

ERROR: unable to create encoder input surface (err=-38)
WARNING: failed at 320x480, retrying at 720x1280
ERROR: unable to create encoder input surface (err=-38)

This bug is tracked in 
if you wish to read the discussion around it.

I created following screencast today using this method as it was required by Android course that i am doing from coursera -

Related Links

1 comment:

  1. This free screen recorder is superb and good for those who hold android device. I use Total Recall app which is the recording app with supreme sound recording for calls made or received and one can get this app from Play Store in merely half price.


t> UA-39527780-1 back to top