Android視頻錄制命令screenrecord
1.screenrecord是一個shell命令
2.支持Android4.4(API level 19)以上
3.支持視頻格式: mp4
adb錄制使用
開始錄制命令:adb shell screenrecord /sdcard/demo.mp4? 說明:錄制手機(jī)屏幕,視頻格式為mp4,存放到手機(jī)sd卡里,默認(rèn)錄制時(shí)間為180s
錄制時(shí)間限制:
參數(shù): --time-limit
adb shell screenrecord? --time-limit 10 /sdcard/demo.mp4
說明:限制視頻錄制時(shí)間為10s,如果不限制,默認(rèn)180s
指定視頻分辨率大型铡:
參數(shù): --size
adb shell screenrecord --size 1280*720 /sdcard/demo.mp4
說明:錄制視頻臂拓,分辨率為1280*720距境,如果不指定默認(rèn)使用手機(jī)的分辨率,為獲得最佳效果,請使用設(shè)備上的高級視頻編碼(AVC)支持的大小
指定視頻的比特率
參數(shù): --bit-rate
adb shell screenrecord --bit-rate 6000000 /sdcard/demo.mp4
說明:指定視頻的比特率為6Mbps,如果不指定,默認(rèn)為4Mbps. 你可以增加比特率以提高視頻質(zhì)量或?yàn)榱俗屛募《档捅忍芈?/p>
在命令行顯示log
參數(shù): --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
旋轉(zhuǎn)90度
參數(shù): --rotate
說明:此功能為實(shí)驗(yàn)性的祭阀,好不好用不知道
查看幫助命令
參數(shù): --help
bixiaopeng@bixiaopeng ~$ adb shell screenrecord --help
Usage: screenrecord [options]
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.
導(dǎo)出視頻:
adb pull /sdcard/demo.mp4
端口報(bào)錯:
netstat -ano |findstr "5037"
C:\Users\gaojs>adb shell
error: more than one device and emulator
C:\Users\gaojs>adb install e:\**.apk
error: more than one device and emulator
碰到這種情況鹉戚,首先要查一下,是不是真的有多個設(shè)備或模擬器柬讨。
C:\Users\gaojs>adb devices
List of devices attached
emulator-5554?? device
4dfadcb86b00cf05??????? device
發(fā)現(xiàn)還真是多個設(shè)備崩瓤,那就需要為ADB命令指定設(shè)備的序列號了。
C:\Users\gaojs>adb -s emulator-5554 shell
也就是如上所示踩官,給命令加上-s的參數(shù)就可以了却桶!
如果實(shí)際上只有一個設(shè)備或模擬器,并且查到有offline的狀態(tài)蔗牡;
那就說明是ADB本身的BUG所導(dǎo)致的颖系,就需要用如下的方法處理下了:
C:\Users\gaojs>adb kill-server
C:\Users\gaojs>taskkill /f /im adb.exe
第一條命令是殺ADB的服務(wù),第二條命令是殺ADB的進(jìn)程辩越!
如果第一條沒有用嘁扼,才考慮用第二條命令再試試看的!