Objective: Sometimes some crash came relatively suddenly, do not remember how to operate, and this time if you can look at video on the perfect (the focus is: no hand flat screen recording function).
1. adb
adb shell screenrecord --size 1280x800 "/sdcard/screenrecord_log.mp4"
adb pull /sdcard/screenrecord_log.mp4 D:/screenrecord_log.mp4
Specific much to say, simply record it
adb shell screenrecord record video command
This value --size 1280x800 video size, screen size is generally set to acquire the screen size with adb shell wm size
"/Sdcard/screenrecord_log.mp4" to record a video store address
adb pull to copy files to a computer device
/sdcard/screenrecord_log.mp4 file path device
D: /screenrecord_log.mp4 file path will be stored in the computer
2.python adbutils module
https://github.com/openatx/adbutils GitHub address
Before using this module you need to install, usepip install adbutils
1 import adbutils 2 import time 3 import os 4 5 6 def main(): 7 8 d = adbutils.adb.device() 9 10 current_time = time.strftime('%Y%m%d_%H%M%S', time.localtime(time.time())) 11 12 screenrecord_file_name = 'log_screenrecord_' + current_time +'.mp4' 13 folder_path = 'D:\\ALOG\\' 14 screenrecord_file_path = os.path.join(folder_path, 'screenrecord',screenrecord_file_name) 15 16 17 sc = d.screenrecord("/sdcard/s.mp4") 18 19 20 time.sleep(15) 21 sc.stop_and_pull(screenrecord_file_path) 22 23 24 25 if __name__ == '__main__': 26 main()
= D adbutils.adb.device () Returns a adbDevice objects, then it may operate on the object
d.screenrecord ( remote_path = None, no_autostart = False)
wherein remote_path address stored in the device, such as input the default is not "/ sdcard / Video- % d.mp4 " % int (the time.time () * 1000), as 20191120.mp4-Video
no_autostart flag just start recording screen, if no_autostart is False, then start recording directly, the default is False, if this value is taken as True, then you need to call sc.start () to start recording.
Therefore, sc = d.screenrecord ( "/ sdcard /to start recording, storing files path"/sdcard/s.mp4"
stop_and_pull ( path: str)
to stop recording and the video to the computer, video equipment be deleted.
where the path path to store video for computer
if sc.stop (), it was just to stop recording, does not spread to the computer
screen recording method adbutils of actually usingadb shell screenrecord,But look at the demand, in some cases, directly adb command is not very convenient