@@ -62,21 +62,7 @@ Read [AVRecorder](../reference/apis/js-apis-media.md#avrecorder9) for the API re
...
@@ -62,21 +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).
> - 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
```ts
classAVProfile{
letavProfile:media.AVRecorderProfile={
fileFormat:media.ContainerFormatType;
videoBitrate:number;
videoCodec:media.CodecMimeType;
videoFrameWidth:number;
videoFrameHeight:number;
videoFrameRate:number;
}
classAVConfig{
videoSourceType:media.VideoSourceType;
profile:AVProfile;
url:string;
rotation:number;
}
letavProfile:AVProfile={
fileFormat:media.ContainerFormatType.CFT_MPEG_4,// Video file encapsulation format. Only MP4 is supported.
fileFormat:media.ContainerFormatType.CFT_MPEG_4,// Video file encapsulation format. Only MP4 is supported.
videoBitrate:200000,// Video bit rate.
videoBitrate:200000,// Video bit rate.
videoCodec:media.CodecMimeType.VIDEO_AVC,// Video file encoding format. Both MPEG-4 and AVC are supported.
videoCodec:media.CodecMimeType.VIDEO_AVC,// Video file encoding format. Both MPEG-4 and AVC are supported.
...
@@ -84,7 +70,7 @@ Read [AVRecorder](../reference/apis/js-apis-media.md#avrecorder9) for the API re
...
@@ -84,7 +70,7 @@ Read [AVRecorder](../reference/apis/js-apis-media.md#avrecorder9) for the API re
videoFrameHeight:480,// Video frame height.
videoFrameHeight:480,// Video frame height.
videoFrameRate:30// Video frame rate.
videoFrameRate:30// Video frame rate.
}
}
letavConfig:AVConfig={
letavConfig:media.AVRecorderConfig={
videoSourceType:media.VideoSourceType.VIDEO_SOURCE_TYPE_SURFACE_YUV,// Video source type. YUV and ES are supported.
videoSourceType:media.VideoSourceType.VIDEO_SOURCE_TYPE_SURFACE_YUV,// Video source type. YUV and ES are supported.
profile:avProfile,
profile:avProfile,
url:'fd://35',// Create, read, and write a file by referring to the sample code in Application File Access and Management.
url:'fd://35',// Create, read, and write a file by referring to the sample code in Application File Access and Management.
...
@@ -139,24 +125,10 @@ Refer to the sample code below to complete the process of starting, pausing, res
...
@@ -139,24 +125,10 @@ Refer to the sample code below to complete the process of starting, pausing, res
importmediafrom'@ohos.multimedia.media'
importmediafrom'@ohos.multimedia.media'
import{BusinessError}from'@ohos.base';
import{BusinessError}from'@ohos.base';
constTAG='VideoRecorderDemo:'
constTAG='VideoRecorderDemo:'
classAVProfile{
fileFormat:media.ContainerFormatType;
videoBitrate:number;
videoCodec:media.CodecMimeType;
videoFrameWidth:number;
videoFrameHeight:number;
videoFrameRate:number;
}
classAVConfig{
videoSourceType:media.VideoSourceType;
profile:AVProfile;
url:string;
rotation:number;
}
exportclassVideoRecorderDemo{
exportclassVideoRecorderDemo{
privateavRecorder:media.AVRecorder;
privateavRecorder:media.AVRecorder;
privatevideoOutSurfaceId:string;
privatevideoOutSurfaceId:string;
privateavProfile:AVProfile={
privateavProfile:media.AVRecorderProfile={
fileFormat:media.ContainerFormatType.CFT_MPEG_4,// Video file encapsulation format. Only MP4 is supported.
fileFormat:media.ContainerFormatType.CFT_MPEG_4,// Video file encapsulation format. Only MP4 is supported.
videoBitrate:100000,// Video bit rate.
videoBitrate:100000,// Video bit rate.
videoCodec:media.CodecMimeType.VIDEO_AVC,// Video file encoding format. Both MPEG-4 and AVC are supported.
videoCodec:media.CodecMimeType.VIDEO_AVC,// Video file encoding format. Both MPEG-4 and AVC are supported.
...
@@ -164,7 +136,7 @@ export class VideoRecorderDemo {
...
@@ -164,7 +136,7 @@ export class VideoRecorderDemo {
videoFrameHeight:480,// Video frame height.
videoFrameHeight:480,// Video frame height.
videoFrameRate:30// Video frame rate.
videoFrameRate:30// Video frame rate.
}
}
privateavConfig:AVConfig={
privateavConfig:media.AVRecorderConfig={
videoSourceType:media.VideoSourceType.VIDEO_SOURCE_TYPE_SURFACE_YUV,// Video source type. YUV and ES are supported.
videoSourceType:media.VideoSourceType.VIDEO_SOURCE_TYPE_SURFACE_YUV,// Video source type. YUV and ES are supported.
profile:this.avProfile,
profile:this.avProfile,
url:'fd://35',// Create, read, and write a file by referring to the sample code in Application File Access and Management.
url:'fd://35',// Create, read, and write a file by referring to the sample code in Application File Access and Management.