How to increase time limit of ADB screen record of Android Kitkat

An alternative solution:

adb shell "screenrecord --time-limit 5 /sdcard/testRun1.mp4; screenrecord --time-limit 5 /sdcard/testRun2.mp4"

Notice the quotes and the semi-colon. The shell command is executed as a shell script on the Android device. The command above would create two mp4 files of 5 seconds each, one after the other.

In our Jenkins test projects we do an exec step with a command like this:

adb shell "screenrecord /sdcard/test1.mp4; screenrecord /sdcard/test2.mp4; screenrecord /sdcard/test3.mp4" & 

The ampersand backgrounds the adb command to allow the rest of the test script to proceed. The command above will record up to 9 minutes.


I encounter the same problem.

Here is my solution. Briefly speaking, it can be solved by recompiling the android source. Patients are needed.

1, Following the instruction here https://source.android.com/source/initializing.html to initialize a build environment.

2, Download the source code from git (Take about 1 hour with 10 M bandwidth).

3, Modify the path_to_working_directory/frameworks/av/cmds/screenrecord/screenrecord.cpp by changing the kMaxTimeLimitSec to 7200 (means 2 hours).

4, Compile the android (Take about 2 hours with Core i5-2500k and 8G RAM)

5, Copy the path_to_working_directory/out/target/product/flo/system/bin/screenrecord to /system/bin in your android phone (Remember to make backup of origin screenrecord in case!)


On windows my trick is creating a screenrecord.bat file and running it. For 9 minutes:

adb shell screenrecord --bit-rate 8000000 /sdcard/sr1.mp4
adb shell screenrecord --bit-rate 8000000 /sdcard/sr2.mp4
adb shell screenrecord --bit-rate 8000000 /sdcard/sr3.mp4

Then you can merge the files with any video editing software.

I know this is a lame solution but adb screenrecord is to blame for not allowing longer video lengths...

Tags:

Android