Android視頻錄製命令screenrecord

來源:互聯網
上載者:User

標籤:android   blog   http   io   ar   os   使用   sp   for   

    不管是教學,還是為了示範,如果能將Android手機(或平板)的螢幕錄製成視頻檔案,那是一件非常酷的事(iOS8已經提供了這一功能,能通過OS X直接在Mac上錄製iPad、iPhone的螢幕,windows沒試過,不知可不可以)。不過以前的方法都是通過截屏錄製的,效果極差。幸好 Android4.4以上版本提供了這一功能。但無法在手機上直接啟動,需要通過adb使用命令列啟動。

    大家可以進入shell。或乾脆直接用adb shell執行命令。該命令是screenrecord,可以輸入screenrecord --help,看看協助,如下所示。

Usage: screenrecord [options] <filename>

Android screenrecord v1.2.  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 bits per second.  Value may be specified as
    bits or megabits, e.g. ‘4000000‘ is equivalent to ‘4M‘.  Default 4Mbps.

--bugreport
    Add additional information, such as a timestamp overlay, that is helpful
    in videos captured to illustrate bugs.

--time-limit TIME
    Set the maximum recording time, in seconds.  Default / maximum is 180.

--verbose
    Display interesting information on stdout.

--help
    Show this message.

Recording continues until Ctrl-C is hit or the time limit is reached.

你要知道:
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
[email protected] 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
[email protected] ~$ 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
說明:匯出視頻到目前的目錄

 

參考連結:http://blog.csdn.net/wirelessqa/article/details/22725581

Android視頻錄製命令screenrecord

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.