Android screen recording with Ubuntu

Android screen recording with Ubuntu

My 9 years old boy who is a huge fan of Minecraft wanted to record the Android tablet screen while playing in order to put the video on his Instagram account... at the same time my 11 year old girl wanted to share Growtopia videos on Youtube so this applies to that also.



So today's challenge is to record screen as video file using Android 4.4.x device (mobile or tablet) with Linux workstation (Ubuntu 14.04 LTS (and 13.10) to be exact).
One rather easy option is to root the device as Google Play is full of apps to record screen with root rights... but that would be too easy so lets do it the official way - please find the needed steps below.

On Ubuntu

You need to install Android Debug Brigde (aka adb) which comes with package named android-tools-adb (Android Debug Bridge CLI tool). Install it with a command (on terminal)

sudo apt-get install android-tools-adb

After installation you can connect the Android device using the standard USB cable (like the one that comes with your charger). To get the list of the connected devices on Ubuntu just type

teemu@teemu-vaio:~$ adb devices
* daemon not running. starting it now on port 5037 *
* daemon started successfully *
List of devices attached 

The list of connected devices seems to be empty so let's fix this. 

On Android device

In order to get the connection working you need to enable Developer options and USB debugging. With various versions of Android the location of Developer option varies... I guess Google is trying to hide these setting due to FUD Apple and Microsoft are throwing at Android. Anyways here are two ways to advance

Easy

Just install for example Track Android Hacker app from Google Play Store, start it and click on Mock Location and enable Developer options (upper right side) + enable USB debugging (see screenshot later in this post). This should work on all Android versions

Few clicks more but leave the apps alone

Follow the next few screenshots (applies at least to Android 4.4.X versions)  

1. Enable Developer options view by clicking few times (max 10 times) on Build Number field and that will add Developer Options to the settings menu



2. Select the just added Developer Options view and Enable the feature


3. Select the USB debugging (the Verify apps via USB will be enabled at the same time)


4. You may get following warning - it's OK, just click OK 




That's it!

Let's wrap it up

Lets try the list of connected devices on Ubuntu again
teemu@teemu-vaio:~$ adb devices
List of devices attached
58fcxxx device
So now we can grab the video - the command below will record default 30 second clip with default bitrate 4Mbps on verbose mode 
teemu@teemu-vaio:~$ adb shell screenrecord --verbose /sdcard/defaultvalues.mp4
Main display is 2560x1600 @59.00fps (orientation=0)
Configuring recorder for 2560x1600 video at 4.00Mbps
Content area is 2560x1600 at offset x=0 y=0
Time limit reached
Encoder stopping; recorded 4188 frames in 180 seconds
Stopping encoder and muxer
Executing: /system/bin/am broadcast -a android.intent.action.MEDIA_SCANNER_SCAN_FILE -d file:///sdcard/demo.mp4
Broadcasting: Intent { act=android.intent.action.MEDIA_SCANNER_SCAN_FILE dat=file:///sdcard/demo.mp4 }
Broadcast completed: result=0
To retrieve the file
teemu@teemu-vaio:~$ adb pull /sdcard/defaultvalues.mp4
6091 KB/s (88095107 bytes in 14.121s)
The recording quality is not really top notch so lets tweak the default values
teemu@teemu-vaio:~$ adb shell screenrecord --bit-rate 8000000 --time-limit 30 /sdcard/doublerate.mp4
teemu@teemu-vaio:~$ adb pull /sdcard/doublerate.mp4
6057 KB/s (29384879 bytes in 4.737s)

For more details about the adb screenrecord options see the official documentation.

Troubleshooting:

  • Make sure your device is connected as MTP (quick link usually on the info curtain)
  • If you see that the device has offline status when using command adb devices then just go to the Developer options and disable-enable the USB debugging to re-initiate the connection.

Other stuff...

Pull command leaves the file on the Android device. You may want to delete the files at some time via some file manager (ES is my favorite) or using the the adb shell
teemu@teemu-vaio:~$ adb shell
shell@lt03lte:/ $ cd /sdcard/
shell@lt03lte:/sdcard $ rm doublerate.mp4                                    
shell@lt03lte:/sdcard $ exit

P.S.1. This setup was tested with two Ubuntu machines (13.10 Sony Vaio Laptop & 14.04LTS workstation) and two Android devices (Nexus 10 (Android 4.4.3) & Samsung Galaxy Note 10.1 2014 edition (Android 4.4.2)). No fragmentation FUD here :-)
P.S.2. Although Samsung bloatware sucks I have to admit that Galaxy Note is the ultimate workhorse: split screen (two apps on a screen) , screen write, pen window, etc are just awesome. BTW. Don't foget to smoke the default launcher with for example Nova Launcher

Comments