You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用expo-camera无法录制视频,三星Galaxy A71报错求助

解决Expo Camera在三星Galaxy A71无法录制视频的问题

针对你遇到的Error retrieving camcorder profile params错误,这是因为Galaxy A71的前置摄像头不支持expo-camera默认的录制配置,以下是具体解决方法:

1. 指定兼容的录制参数

在recordAsync方法中传入自定义的视频质量、帧率等参数,选择设备支持的低分辨率配置:

const takeVideo = async () => {
    if(cameraRef){
        try{
            const data = await cameraRef.current.recordAsync({
                quality: Camera.Constants.VideoQuality['480p'],
                fps: 24,
                maxDuration: 60 // 可选,按需设置
            });
            setSequence(data.uri)
        } catch(e){
            console.error(e);
        }
    }
}

2. 动态获取设备支持的录制配置

先获取当前摄像头支持的视频配置,再选择合适的配置进行录制,避免使用不兼容的参数:

// 获取当前摄像头支持的视频配置
const getSupportedProfiles = async () => {
    if(cameraRef.current){
        const profiles = await cameraRef.current.getAvailableVideoProfilesAsync();
        console.log('设备支持的视频配置:', profiles);
        return profiles[0]; // 取第一个兼容配置,可按需筛选
    }
}

// 修改录制函数使用兼容配置
const takeVideo = async () => {
    if(cameraRef){
        try{
            const profile = await getSupportedProfiles();
            const data = await cameraRef.current.recordAsync({
                videoProfile: profile,
            });
            setSequence(data.uri)
        } catch(e){
            console.error(e);
        }
    }
}

3. 更新Expo依赖版本

旧版本的expo-camera可能存在设备兼容性问题,更新到最新稳定版:

expo install expo-camera@latest
# 或整体升级Expo SDK
expo upgrade

4. 完善权限请求逻辑

确保所有必要权限都正确获取,之前的代码未等待MediaLibrary权限请求结果,修改如下:

useEffect(() => {
    (async () => {
        const mediaStatus = await MediaLibrary.requestPermissionsAsync();
        const cameraStatus = await Camera.requestCameraPermissionsAsync();
        const soundStatus = await Camera.requestMicrophonePermissionsAsync();
        setHasPermission(
            mediaStatus.granted && 
            cameraStatus.granted && 
            soundStatus.granted
        );
    })();
}, []);

内容的提问来源于stack exchange,提问作者CSAlex

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.18 16:34:54