| Name | Date | Size | #Lines | LOC | ||
|---|---|---|---|---|---|---|
| .. | - | - | ||||
| AppScope/ | 22-Oct-2025 | - | 36 | 33 | ||
| entry/ | 22-Oct-2025 | - | 2,638 | 2,406 | ||
| hvigor/ | 22-Oct-2025 | - | 23 | 22 | ||
| lib/ | 22-Oct-2025 | - | ||||
| screenshots/devices/ | 22-Oct-2025 | - | ||||
| README.md | D | 22-Oct-2025 | 1.5 KiB | 29 | 17 | |
| README_zh.md | D | 22-Oct-2025 | 6.3 KiB | 88 | 58 | |
| build-profile.json5 | D | 22-Oct-2025 | 1.1 KiB | 43 | 42 | |
| hvigorfile.ts | D | 22-Oct-2025 | 159 | 2 | 1 | |
| oh-package.json5 | D | 22-Oct-2025 | 833 | 27 | 26 | |
| ohosTest.md | D | 22-Oct-2025 | 940 | 12 | 8 |
README.md
1# AVRecorder 2 3### Introduction 4 5In this sample, you can use AVRecorder interfaces to record audio or video. 6 7### Required Permissions 8 9ohos.permission.MICROPHONE, which request the permission of microphone. 10 11ohos.permission.CAMERA, which request the permission of camera. 12 13ohos.permission.WRITE_MEDIA, which allows an app to write media files to the user's external storage. 14 15### Usage 16 171. On the home page, you can either choose **Video Recording** or **Audio Recording** button according to your purpose. 182. Click the **Video Recording** button to switch to the video recording page. You can click the setting button to choose video resolution. Click the start, pause, resume, stop button to control the recording process. 193. Click the **Audio Recording** button to switch to the audio recording page. You can click the setting button to choose audio sample rate. Click the start, pause, resume, stop button to control the recording process. 204. The files you have recorded can be found in Photos. 21 22### Constraints 23 241. This sample can only be run on standard-system devices that use the phone. 252. This sample is based on the stage model, which is supported from API version 12. You should manully fetch Full SDK from gitee and replace them in DevEco Studio. 263. DevEco Studio Next 5.0 Beta1 (Build Version:5.0.3.800, built on Sep 4, 2024) must be used. 273. Camera apis can only be used by system app. In order to run this sample, you should generate signature manually with hap-sign-tool. 28 29
README_zh.md
1# 音视频录制 2 3### 介绍 4 5音视频录制应用是基于AVRecorder接口开发的实现音频录制和视频录制功能的应用,音视频录制的主要工作是捕获音频信号,接收视频信号,完成音视频编码并保存到文件中,帮助开发者轻松实现音视频录制功能,包括开始录制、暂停录制、恢复录制、停止录制、释放资源等功能控制。它允许调用者指定录制的图像size、音频采样频率等参数。 6 7本示例主要使用@kit.MediaKit中的AVRecorder接口实现了录制功能;通过@kit.CoreFileKit接口支持,完成录制文件的创建,接口使用以及权限获取详见[文件管理](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-core-file-kit/Readme-CN.md)。使用@kit.CameraKit接口,实现了相机预览及出流功能,接口使用以及权限获取详见[相机管理](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-camera-kit/js-apis-camera.md)。 8 9### 效果预览 10 11| 主页 | 视频录制 | 音频录制 | 12| ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | 13| <img src="screenshots/devices/homePage.jpg" alt="homePage" style="zoom:25%;" /> | <img src="screenshots/devices/videoRecorder.jpg" alt="videoRecorder" style="zoom:25%;" /> | <img src="screenshots/devices/audioRecorder.jpg" alt="audioRecorder" style="zoom:25%;" /> | 14 15使用说明 16 171. 进入应用前请先安装[VideoRecorder](./lib/VideoRecorder-1.0.0.hap)。 182. 在主界面,可以点击视频录制、音频录制进入对应功能界面。 193. 点击视频录制页面,进入页面呈现摄像头预览画面,用户可以通过点击左上角的设置图标进行视频分辨率参数设置,点击”开始“”暂停“”恢复“”停止“等对应图标按钮进行视频录控相关操作。 204. 点击音频录制页面,用户可以通过点击左上角的设置图标进行音频采样率参数设置,点击”开始“”暂停“”恢复“”停止“等对应图标按钮进行音频录控相关操作。 215. 在RK板硬件平台上,录制功能的性能可能受限,请在多种设备上进行测试以确保兼容性。 22 23### 工程目录 24 25``` 26entry/src/main/ets/ 27|---entryability 28| |---data // 能力生命周期管理 29|---pages 30| |---ListPage.ets // 首页,选择音频录制或者视频录制 31|---recorder 32| |---AudioRecorder.ets // 音频录制页面 33| |---VideoRecorder.ets // 视频录制页面 34|---utils 35| |---DateTimeUtils // 录制显示时间转换函数 36| |---SaveCameraAsset.ets // 创建录制文件相关函数 37| |---Logger.ts // 封装的日志打印函数 38``` 39 40### 具体实现 41 42* 录控功能接口调用实现参考工程目录中的音频录制页面和视频录制页面 43 * 调用create()、prepare()、getInputSurface()、start()、pause()、resume()、stop()、reset()、release()接口实现录制器的创建、准备、录控操作、重置、销毁实例等功能; 44 * 视频录制[VRecorder.ets](entry/src/main/ets/recorder/VideoRecorder.ets)调用Camera接口实现相机出流配合视频录制功能,相机的实现方法参考自相机接口[@kit.CameraKit](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-camera-kit/js-apis-camera.md) 45* 调用文件基础服务接口实现创建录制文件代码在[SaveCameraAsset.ets](entry/src/main/ets/utils/SaveCameraAsset.ets),实现方法参考[@kit.CoreFileKit](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-core-file-kit/Readme-CN.md)接口说明 46 47### 相关权限 48 49开发者在进行录制功能开发前,需要先对所开发的应用配置相应权限,应用权限列表参考:[应用权限列表](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/AccessToken/permissions-for-all.md)。权限配置相关内容可参考:[访问控制授权申请指导](https://docs.openharmony.cn/pages/v4.0/zh-cn/application-dev/security/accesstoken-guidelines.md)。 50 51音视频录制涉及的权限包括: 52 531.允许应用使用麦克风:[ohos.permission.MICROPHONE](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/AccessToken/permissions-for-all.md#ohospermissionmicrophone) 54 552.允许应用使用相机拍照和录制视频:[ohos.permission.CAMERA](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/AccessToken/permissions-for-all.md#ohospermissioncamera) 56 573.允许应用读取用户外部存储中的媒体文件信息:[ohos.permission.READ_MEDIA](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/AccessToken/permissions-for-all.md#ohospermissionread_media) 58 594.允许应用读写用户外部存储中的媒体文件信息:[ohos.permission.WRITE_MEDIA](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/AccessToken/permissions-for-all.md#ohospermissionwrite_media) 60 615.允许应用获取设备位置信息:[ohos.permission.LOCATION](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/AccessToken/permissions-for-all.md#ohospermissionlocation) 62 63### 依赖 64 65不涉及 66 67### 约束与限制 68 691.本示例仅支持在标准系统上运行,支持设备:Phone。 70 712.本示例仅支持API12版本SDK,版本号:5.0.0.65。 72 733.本示例使用的IDE版本信息:DevEco Studio Next 5.0 Beta1 (Build Version:5.0.3.800, built on Sep 4, 2024)。 74 754.相机、媒体库为系统接口,需要配置高权限签名,相关权限级别可查阅权限列表,需要配置系统应用签名,可以参考[特殊权限配置方法](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/hapsigntool-overview.md)。 76 77### 下载 78 79如需单独下载本工程,执行如下命令: 80 81``` 82git init 83git config core.sparsecheckout true 84echo code/BasicFeature/Media/AVRecorder/ > .git/info/sparse-checkout 85git remote add origin https://gitee.com/openharmony/applications_app_samples.git 86git pull origin master 87``` 88