Android截圖命令screencap
查看幫助命令
bixiaopeng@bixiaopeng ~$ adb shell screencap -v
screencap: invalid option -- v
usage: screencap [-hp] [-d display-id] [FILENAME]
-h: this message
-p: save the file as a png.
-d: specify the display id to capture, default 0.
If FILENAME ends with .png it will be saved as a png.
If FILENAME is not given, the results will be printed to stdout.
注意:
如果文件名以.png結尾時,它將保存為png文件
如果文件名沒有給出,則結果被會被輸出到stdout
截圖保存到SD卡里再導出
$ adb shell screencap -p /sdcard/screen.png
$ adb pull /sdcard/screen.png
$ adb shell rm /sdcard/screen.png
這種方法比較麻煩,需要3步:1. 截圖保存到sdcard 2.將圖片導出 3.刪除sdcard中的圖片
截圖直接保存到電腦
$ adb shell screencap -p | sed 's/\r$//' > screen.png
執行adb shell 將\n轉換\r\n, 因此需要用sed刪除多余的\r
如果直接當命令用還可以用 alias 包裝裝起來:
$ alias and-screencap="adb shell screencap -p | sed 's/\r$//'"
$ and-screencap > screen.png
以后就可以方便的用and-screencap > 直接將截圖保存到電腦上了
轉:http://blog.csdn.net/wirelessqa/article/details/22725581
Android視頻錄制命令screenrecord
你要知道:
- screenrecord是一個shell命令
- 支持Android4.4(API level 19)以上
- 支持視頻格式: mp4
一些限制
- 某些設備可能無法直接錄制,原因是分辨率太高,如果遇到此類問題,請試着指定較低的分辨率
- 不支持錄制過程中屏幕旋轉,如果錄制過程中旋轉,有可能畫面被切斷
- 錄制視頻的時候聲音不會被錄下來
開始錄制命令:
adb shell screenrecord /sdcard/demo.mp4
說明:錄制手機屏幕,視頻格式為mp4,存放到手機sd卡里,默認錄制時間為180s
限制錄制時間:
參數: --time-limit
adb shell screenrecord --time-limit 10 /sdcard/demo.mp4
說明:限制視頻錄制時間為10s,如果不限制,默認180s
指定視頻分辨率大小:
參數: --size
adb shell screenrecord --size 1280*720 /sdcard/demo.mp4
說明:錄制視頻,分辨率為1280*720,如果不指定默認使用手機的分辨率,為獲得最佳效果,請使用設備上的高級視頻編碼(AVC)支持的大小
指定視頻的比特率
參數: --bit-rate
adb shell screenrecord --bit-rate 6000000 /sdcard/demo.mp4
說明:指定視頻的比特率為6Mbps,如果不指定,默認為4Mbps. 你可以增加比特率以提高視頻質量或為了讓文件更小而降低比特率
在命令行顯示log
參數: --verbose
bixiaopeng@bixiaopeng wirelessqa$ adb shell screenrecord --time-limit 10 --verbose /sdcard/demo.mp4
Main display is 1080x1920 @60.00fps (orientation=0)
Configuring recorder for 1080x1920 video at 4.00Mbps
Content area is 1080x1920 at offset x=0 y=0
Time limit reached
Encoder stopping; recorded 96 frames in 10 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
旋轉90度
參數: --rotate
說明:此功能為實驗性的,好不好用不知道
查看幫助命令
參數: --help
bixiaopeng@bixiaopeng ~$ adb shell screenrecord --help
Usage: screenrecord [options] <filename>
Records the device's display to a .mp4 file.
Options:
--size WIDTHxHEIGHT
Set the video size, e.g. "1280x720". Default is the device's main
display resolution (if supported), 1280x720 if not. For best results,
use a size supported by the AVC encoder.
--bit-rate RATE
Set the video bit rate, in megabits per second. Default 4Mbps.
--time-limit TIME
Set the maximum recording time, in seconds. Default / maximum is 180.
--rotate
Rotate the output 90 degrees.
--verbose
Display interesting information on stdout.
--help
Show this message.
Recording continues until Ctrl-C is hit or the time limit is reached.
導出視頻:
adb pull /sdcard/demo.mp4
說明:導出視頻到當前目錄