uni-app camera.startVideoCapture在苹果手机调用摄像头竖屏录制会变成横屏

uni-app camera.startVideoCapture在苹果手机调用摄像头竖屏录制会变成横屏

操作步骤:

await this.$plus.isAuthCamera();
await this.$plus.isAuthRecord(); // 录音权限
const camera = window.plus.camera.getCamera();
camera.startVideoCapture((res) => {
this.handleImage(res);
}, () => {
}, {
filename: '_doc/camera/',
videoPixelFormat: 'mp4'
});

预期结果:

竖屏显示

实际结果:

横屏显示

bug描述:

camera.startVideoCapture 在苹果手机调用摄像头,竖屏录制,会变成横屏
开发环境 版本号 项目创建方式
HBuilderX 4.76 云端打包

更多关于uni-app camera.startVideoCapture在苹果手机调用摄像头竖屏录制会变成横屏的实战教程也可以访问 https://www.itying.com/category-93-b0.html

1 回复

更多关于uni-app camera.startVideoCapture在苹果手机调用摄像头竖屏录制会变成横屏的实战教程也可以访问 https://www.itying.com/category-93-b0.html


这是由于iOS系统对摄像头视频捕获的默认方向处理与Android不同导致的。在iOS设备上,camera.startVideoCapture方法默认会以设备横屏方向(Landscape)录制视频,即使设备当前处于竖屏状态。

解决方案:

  1. 使用plus.camera.CameraOptions设置视频方向参数:
camera.startVideoCapture((res) => {
    this.handleImage(res);
}, () => {}, {
    filename: '_doc/camera/',
    videoPixelFormat: 'mp4',
    videoOrientation: 'portrait' // 强制竖屏录制
});
  1. 如果上述参数无效,可以在录制完成后通过plus.video.VideoEditor对视频进行旋转处理:
const videoEditor = plus.video.createVideoEditor();
videoEditor.rotate(res, 90, (processedPath) => {
    // 处理后的竖屏视频
});
回到顶部