1414
1515from scriptUtils import utils
1616
17- #需要Android4.4及4.4以上版本,运行脚本后可录制设备上的操作,默认使用手机分辨率,时间3min。手动按Enter结束录制 。
17+ #需要Android4.4及4.4以上版本,运行脚本后可录制设备上的操作,默认使用手机分辨率,手动设置录制时间 。
1818#录制结果存放于当前目录下的video目录下
1919
2020PATH = lambda p : os .path .abspath (p )
2121
2222def record ():
23- utils .shell ("screenrecord /data/local/tmp/video.mp4" )
24- input_key = raw_input ("Please press the Enter key to stop recording:\n " )
25- if input_key == "" :
26- utils .adb ("kill-server" )
27-
28- print "Get Video file..."
29- utils .adb ("start-server" )
30- time .sleep (1.5 )
31-
32- path = PATH ("%s/video" % os .getcwd ())
33- if not os .path .isdir (path ):
34- os .makedirs (path )
35-
36- utils .adb ("pull /data/local/tmp/video.mp4 %s" % PATH ("%s/%s.mp4" % (path , utils .timestamp ()))).wait ()
23+ utils .shell ("rm -f /data/local/tmp/video.mp4" )
24+ limit_time = raw_input ("Please set the maximum recording time, in seconds. Maximum is 180.\n " )
25+ if limit_time == "" :
26+ utils .shell ("screenrecord --time-limit 180 /data/local/tmp/video.mp4" )
27+ try :
28+ _limit_time = int (limit_time ) + 1
29+ except :
30+ record ()
31+ if 0 < _limit_time <= 180 :
32+ utils .shell ("screenrecord --time-limit %s /data/local/tmp/video.mp4" % limit_time ).wait ()
33+ else :
34+ print "Please set again!"
35+ record ()
3736
3837if __name__ == "__main__" :
3938 sdk = string .atoi (utils .shell ("getprop ro.build.version.sdk" ).stdout .read ())
@@ -42,4 +41,12 @@ def record():
4241 sys .exit (0 )
4342 else :
4443 record ()
44+ print "Get Video file..."
45+ time .sleep (3 )
46+
47+ path = PATH ("%s/video" % os .getcwd ())
48+ if not os .path .isdir (path ):
49+ os .makedirs (path )
50+
51+ os .popen ("adb pull /data/local/tmp/video.mp4 %s" % PATH ("%s/%s.mp4" % (path , utils .timestamp ())))
4552 print "Completed"
0 commit comments