console.error('error happened, error message is '+err);
})
```
...
...
@@ -62,7 +62,7 @@ Read [AVRecorder](../reference/apis/js-apis-media.md#avrecorder9) for the API re
> - The recording output URL (URL in **avConfig** in the sample code) must be in the format of fd://xx (where xx indicates a file descriptor). You must call [ohos.file.fs](../reference/apis/js-apis-file-fs.md) to implement access to the application file. For details, see [Application File Access and Management](../file-management/app-file-access.md).
```ts
letavProfile={
letavProfile:media.AVRecorderProfile={
fileFormat:media.ContainerFormatType.CFT_MPEG_4,// Video file encapsulation format. Only MP4 is supported.
videoBitrate:200000,// Video bit rate.
videoCodec:media.CodecMimeType.VIDEO_AVC,// Video file encoding format. Both MPEG-4 and AVC are supported.
...
...
@@ -70,15 +70,15 @@ Read [AVRecorder](../reference/apis/js-apis-media.md#avrecorder9) for the API re
videoFrameHeight:480,// Video frame height.
videoFrameRate:30// Video frame rate.
}
letavConfig={
letavConfig:media.AVRecorderConfig={
videoSourceType:media.VideoSourceType.VIDEO_SOURCE_TYPE_SURFACE_YUV,// Video source type. YUV and ES are supported.
profile:this.avProfile,
profile:avProfile,
url:'fd://35',// Create, read, and write a file by referring to the sample code in Application File Access and Management.
rotation:0,// Video rotation angle. The default value is 0, indicating that the video is not rotated. The value can be 0, 90, 180, or 270.
}
avRecorder.prepare(avConfig).then(()=>{
console.info('avRecorder prepare success')
},(error)=>{
},(error:Error)=>{
console.error('avRecorder prepare failed')
})
```
...
...
@@ -90,9 +90,9 @@ Read [AVRecorder](../reference/apis/js-apis-media.md#avrecorder9) for the API re
The video data collection module obtains the surface based on the surface ID and transmits video data to the AVRecorder through the surface. Then the AVRecorder processes the video data.