當前位置:首頁 » 安卓系統 » android視頻錄制播放

android視頻錄制播放

發布時間: 2025-03-13 02:10:32

❶ ADB錄制視頻 Android 視頻錄制命令 screenrecord

在Android 4.4(Kitkat - API level 19)上集成了一個比較好用的視頻(.mp4格式)錄制功能 – screenrecord 。

使用方法

1.  基本用法

$ adb shell screenrecord /sdcard/myscreenrecord.mp4

/sdcard/myscreenrecord.mp4 為視頻錄制文件路徑

錄制默認解析度,默認4Mbps,默認180s的視頻,保存到sdcard上名為myscreenrecord.mp4

2.  旋轉(參數:–rotate)

$ adb shell screenrecord --rotate /sdcard/myscreenrecord.mp4

旋轉90度

3.  指定解析度(參數:–size)

$adb shell screenrecord --size 112x112 /sdcard/myscreenrecord.mp4

解析度為112x112,建議不要指定解析度,使用默認解析度效果最佳;

注意,解析度不是完全可以隨意定製的,比如在我手機上錄制100x100的會提示錯誤:

The max width/height supported by codec is1920x1088

100x100is not supported by codec, suggest to set it as112x112

4.  指定比特率(參數:–bit-rate)

$adb shell screenrecord --bit -rate 8000000 /sdcard/myscreenrecord.mp4

設置比特率為8Mbps,比特率越大,文件越大,畫面越清晰;

5.  限制錄制時間 (參數: –time-limit)

$adb shell screenrecord --time -limit 10 /sdcard/myscreenrecord.mp4

限制視頻錄制時間為10s,如果不限制,默認180s

6.  導出視頻

$adb pull /sdcard/myscreenrecord.mp4

7.  注意

請關注視頻文件生成大小,根據自身情況而定;

暫不支持聲音;

咱時不支持模擬器錄制( 模擬器錄制看這里 ),出現如下提示:Unable to get output buffers (err=-38)

Encoder failed (err=-38),可認為是此原因;

8.  命令查看

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),        1280x720if not.  For best

results,use a size supported by the AVC encoder.

--bit -rate RATE

   Set the video bit rate, in megabits per second.  Default4Mbps.

--time -limit TIME

   Set the maximum recording time, in seconds.  Default / maximum is180.

--rotate

    Rotate the output90 degrees.

--verbose

    Display interesting information on stdout.

--help

    Showthis message.

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

❷ Android錄制視頻,可限制時長,限大小

Android 錄制視頻:

public static voidrecordVideo(Context context, intlimit_time, intsize) {    

    Intent intent =newIntent();

    intent.setAction(MediaStore. ACTION_VIDEO_CAPTURE );

    intent.putExtra(MediaStore. EXTRA_VIDEO_QUALITY ,1);

    intent.addCategory(Intent. CATEGORY_DEFAULT );

    if(size !=0) {        

      //大小限制是long型,int 型無效,所以後邊要寫一個L

        intent.putExtra(MediaStore. EXTRA_SIZE_LIMIT ,size *1024*1024L);//限制錄制大小(10M=10 * 1024 * 1024L)

    }

    if(limit_time !=0) {      

          intent.putExtra(MediaStore. EXTRA_DURATION_LIMIT ,limit_time);//限制錄制時間(10秒=10)

    }    

    File videoFile =createVideoFile(context);

    if(videoFile !=null) {        

        intent.putExtra(MediaStore. EXTRA_OUTPUT ,Uri.fromFile(videoFile));

        context.startActivityForResult(intent, CAPTURE_VIDEO_CODE );

    }

}

熱點內容
安卓手機怎麼找到應用的文件夾 發布:2025-03-13 06:27:27 瀏覽:204
我的世界伺服器右鍵進化怎麼設置 發布:2025-03-13 06:26:49 瀏覽:18
用路由器搭建私有雲伺服器 發布:2025-03-13 06:26:45 瀏覽:182
車架號為什麼跟配置不匹配 發布:2025-03-13 06:20:33 瀏覽:489
wpk文件解壓 發布:2025-03-13 06:17:40 瀏覽:230
OP編譯驅動 發布:2025-03-13 05:54:41 瀏覽:75
圖片集體壓縮 發布:2025-03-13 05:53:47 瀏覽:877
壓縮文件是什麼 發布:2025-03-13 05:19:38 瀏覽:996
debian自啟動腳本 發布:2025-03-13 05:16:23 瀏覽:429
如何登錄微信找回密碼 發布:2025-03-13 05:06:20 瀏覽:450