forked from gb112211/AndroidTestScripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscreenrecord.py
More file actions
53 lines (42 loc) · 1.44 KB
/
screenrecord.py
File metadata and controls
53 lines (42 loc) · 1.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
Created on 2015年1月26日
@author: xuxu
'''
import os
import string
import sys
import time
from scriptUtils import utils
#需要Android4.4及4.4以上版本,运行脚本后可录制设备上的操作,默认使用手机分辨率,手动设置录制时间。
#录制结果存放于当前目录下的video目录下
PATH = lambda p: os.path.abspath(p)
def record():
utils.shell("rm -f /data/local/tmp/video.mp4")
limit_time = raw_input("Please set the maximum recording time, in seconds. Maximum is 180.\n")
if limit_time == "":
utils.shell("screenrecord --time-limit 180 /data/local/tmp/video.mp4")
try:
_limit_time = int(limit_time) + 1
except:
record()
if 0 < _limit_time <= 180:
utils.shell("screenrecord --time-limit %s /data/local/tmp/video.mp4" %limit_time).wait()
else:
print "Please set again!"
record()
if __name__ == "__main__":
sdk = string.atoi(utils.shell("getprop ro.build.version.sdk").stdout.read())
if sdk < 19:
print "sdk version is %s, less than 19!"
sys.exit(0)
else:
record()
print "Get Video file..."
time.sleep(3)
path = PATH("%s/video" %os.getcwd())
if not os.path.isdir(path):
os.makedirs(path)
utils.adb("pull /data/local/tmp/video.mp4 %s" %PATH("%s/%s.mp4" %(path, utils.timestamp())))
print "Completed"