当前位置:首页 » 安卓系统 » 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 07:11:31 浏览:877
编程报名网 发布:2025-03-13 06:54:11 浏览:972
androidstudio安装apk 发布:2025-03-13 06:48:39 浏览:497
电脑服务器怎么打开连接网络 发布:2025-03-13 06:42:12 浏览:629
阿里云服务器文档 发布:2025-03-13 06:39:51 浏览:776
安卓手机怎么找到应用的文件夹 发布:2025-03-13 06:27:27 浏览:205
我的世界服务器右键进化怎么设置 发布:2025-03-13 06:26:49 浏览:19
用路由器搭建私有云服务器 发布:2025-03-13 06:26:45 浏览:183
车架号为什么跟配置不匹配 发布:2025-03-13 06:20:33 浏览:490
wpk文件解压 发布:2025-03-13 06:17:40 浏览:231