未验证 提交 6b0232cb 编写于 作者: O openharmony_ci 提交者: Gitee

!23212 增加宽高比限制描述

Merge pull request !23212 from supeng/master
...@@ -10,6 +10,8 @@ ...@@ -10,6 +10,8 @@
XComponent组件为预览流提供的Surface,而XComponent的能力由UI提供,相关介绍可参考[XComponent组件参考](../reference/arkui-ts/ts-basic-components-xcomponent.md) XComponent组件为预览流提供的Surface,而XComponent的能力由UI提供,相关介绍可参考[XComponent组件参考](../reference/arkui-ts/ts-basic-components-xcomponent.md)
**注**:预览流与录像输出流的分辨率的宽高比要保持一致,如示例代码中宽高比为1920:1080 = 16:9,则需要预览流中的分辨率的宽高比也为16:9,如分辨率选择640:360,或960:540,或1920:1080,以此类推
```ts ```ts
// 创建XComponentController // 创建XComponentController
mXComponentController: XComponentController = new XComponentController; mXComponentController: XComponentController = new XComponentController;
...@@ -24,6 +26,7 @@ ...@@ -24,6 +26,7 @@
}) })
.onLoad(() => { .onLoad(() => {
// 设置Surface宽高(1920*1080),预览尺寸设置参考前面 previewProfilesArray 获取的当前设备所支持的预览分辨率大小去设置 // 设置Surface宽高(1920*1080),预览尺寸设置参考前面 previewProfilesArray 获取的当前设备所支持的预览分辨率大小去设置
// 预览流与录像输出流的分辨率的宽高比要保持一致
this.mXComponentController.setXComponentSurfaceSize({surfaceWidth:1920,surfaceHeight:1080}); this.mXComponentController.setXComponentSurfaceSize({surfaceWidth:1920,surfaceHeight:1080});
// 获取Surface ID // 获取Surface ID
globalThis.surfaceId = this.mXComponentController.getXComponentSurfaceId(); globalThis.surfaceId = this.mXComponentController.getXComponentSurfaceId();
......
...@@ -48,13 +48,15 @@ ...@@ -48,13 +48,15 @@
通过CameraOutputCapability类中的videoProfiles,可获取当前设备支持的录像输出流。然后,定义创建录像的参数,通过createVideoOutput方法创建录像输出流。 通过CameraOutputCapability类中的videoProfiles,可获取当前设备支持的录像输出流。然后,定义创建录像的参数,通过createVideoOutput方法创建录像输出流。
**注**:预览流与录像输出流的分辨率的宽高比要保持一致,如示例代码中宽高比为640:480 = 4:3,则需要预览流中的分辨率的宽高比也为4:3,如分辨率选择640:480,或960:720,或1440:1080,以此类推
```ts ```ts
let videoProfilesArray: Array<camera.VideoProfile> = cameraOutputCapability.videoProfiles; let videoProfilesArray: Array<camera.VideoProfile> = cameraOutputCapability.videoProfiles;
if (!videoProfilesArray) { if (!videoProfilesArray) {
console.error("createOutput videoProfilesArray == null || undefined"); console.error("createOutput videoProfilesArray == null || undefined");
} }
// 创建视频录制的参数 // 创建视频录制的参数,预览流与录像输出流的分辨率的宽(videoFrameWidth)高(videoFrameHeight)比要保持一致
let videoConfig = { let videoConfig = {
videoSourceType: media.VideoSourceType.VIDEO_SOURCE_TYPE_SURFACE_YUV, videoSourceType: media.VideoSourceType.VIDEO_SOURCE_TYPE_SURFACE_YUV,
profile: { profile: {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册