• Home
Name Date Size #Lines LOC

..--

AppScope/12-May-2024-3633

entry/12-May-2024-2,5522,375

screenshots/devices/12-May-2024-

README.mdD12-May-20241.5 KiB2917

README_zh.mdD12-May-20244.1 KiB7245

build-profile.json5D12-May-20241 KiB4342

hvigorfile.tsD12-May-2024159 21

package.jsonD12-May-2024377 1918

README.md

1#  AVRecorder Demo
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. First, you can click the setting button to choose recording configurations. You can click the button on the top-right to check your configurations. You can 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 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 phone development board.
252. This sample is based on the stage model, which is supported from API version 9. You should manully fetch Full SDK from gitee and replace them in DevEco Studio.
263. DevEco Studio 3.1 (Build Version:3.1.0.200, built on Feburary 16, 2023) 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# AVRecorder
2
3## 介绍
4
5音视频录制Demo是基于AVRecorder接口开发的实现音频录制和视频录制功能的demo,音视频录制的主要工作是捕获音频信号,接收视频信号,完成音视频编码并保存到文件中,帮助开发者轻松实现音视频录制功能,包括开始录制、暂停录制、恢复录制、停止录制、释放资源等功能控制。它允许调用者指定录制的编码格式、封装格式、文件路径等参数。
6
7本示例主要使用@ohos.multimedia.media中的AVRecorder接口实现了录制功能;
8
9另外辅助使用@ohos.multimedia.medialibrary接口,实现了创建录制文件功能;使用@ohos.multimedia.camera接口,实现了相机预览及出流功能。
10
11### 效果预览
12
13| 主页                                                         | 视频录制                                                     | 音频录制                                                     |
14| ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ |
15| <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%;" /> |
16
17使用说明
18
191. 在主界面,可以点击视频录制、音频录制进入对应功能界面;
202. 点击视频录制页面,进入页面呈现摄像头预览画面,用户可以通过点击左下角的设置图标进行视频分辨率、帧率、编码格式参数设置,长按右上角详情图标可以查看当前配置参数,点击”开始“”暂停“”恢复“”停止“等对应图标按钮进行视频录控相关操作。
213. 点击音频录制页面,用户可以通过点击左下角的设置图标进行音频声道、采样率参数设置,长按右上角详情图标可以查看当前配置参数,点击”开始“”暂停“”恢复“”停止“等对应图标按钮进行音频录控相关操作。
22
23### 工程目录
24
25给出项目中关键的目录结构并描述它们的作用,示例如下:
26
27```
28entry/src/main/ets/
29|---entryability
30|   |---data                               // 能力生命周期管理
31|---pages
32|   |---ListPage.ets                       // 首页,选择音频录制或者视频录制
33|---recorder
34|   |---ARecorder.ets                      // 音频录制页面
35|   |---VRecorder.ets                      // 视频录制页面
36|---utils
37|   |---DateTimeUtils                      // 录制显示时间转换函数
38|   |---SaveCameraAsset.ets                // 创建录制文件相关函数
39```
40
41### 具体实现
42
43* 录控功能接口调用实现在ARecorder.etsVRecorder.ets
44  * 调用create()、prepare()、getInputSurface()、start()、pause()、resume()、stop()、reset()、release()接口实现录制器的创建、准备、录控操作、重置、销毁实例等功能;
45  * 视频录制VRecorder.ets调用Camera接口实现相机出流功能配合视频录制功能,相机的实现方法参考自相机接口@ohos.multimedia.camera
46* 调用MediaLibrary实现创建录制文件代码在SaveCameraAsset.ets,实现方法参考@ohos.multimedia.medialibrary接口说明
47
48### 相关权限
49
50音视频录制涉及的权限包括:
51
52ohos.permission.MICROPHONE
53
54ohos.permission.CAMERA
55
56ohos.permission.READ_MEDIA
57
58ohos.permission.WRITE_MEDIA
59
60ohos.permission.LOCATION
61
62### 约束与限制
63
641.本示例仅支持在标准系统上运行,支持设备:手机。
65
662.本示例仅支持API9版本SDK,版本号:3.2.10.8;系统权限的系统接口。本示例需要使用相机系统权限的系统接口,使用Full SDK时需要手动从镜像站点获取,并在DevEco Studio中替换。
67
683.本示例需要使用DevEco Studio 3.1 (Build Version:3.1.0.200, built on Feburary 16, 2023)才可编译运行。
69
704.相机为系统接口,需要配置高权限签名,相关权限级别可查阅权限列表,需要手动配置对应级别的权限签名。
71
72