Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android14 设备上 录音异常 #231

Open
ScWen7 opened this issue Jul 1, 2024 · 7 comments
Open

Android14 设备上 录音异常 #231

ScWen7 opened this issue Jul 1, 2024 · 7 comments
Labels
bug Something isn't working

Comments

@ScWen7
Copy link

ScWen7 commented Jul 1, 2024

Android14 设备上WebView 录音开启成功,但是录音 编码异常

@ScWen7
Copy link
Author

ScWen7 commented Jul 1, 2024

编码后的音频播放出来是 嘟嘟嘟的电子音

问题为概率性发生,小概率可以正常录制,大概率录制异常 电子音

@ScWen7 ScWen7 changed the title Android14 设备上 录音没有任何声音 Android14 设备上 录音异常 Jul 1, 2024
@egoistme
Copy link

同样的问题,用户的UA是 Mozilla/5.0 (Linux; Android 14; V2244A Build/UP1A.231005.007; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/116.0.0.0 Mobile Safari/537.36,手机型号是vivo S16,Recorder配置为
type: "mp3", sampleRate: 16000, bitRate: 16,

@xiangyuecn
Copy link
Owner

不确定是哪里的问题,怀疑是 MediaRecorder 有问题,可尝试 Recorder.ConnectEnableWebM=false 禁用掉

在线demo里面有测试 https://xiangyuecn.github.io/Recorder/ ,页面中有个启用MediaRecorder的选项,取消勾选,测试看看能不能恢复正常

另外有个地方可能会导致录音兼容性变差:
trackSet[sampleRateTxt]=ctx[sampleRateTxt]; 这句指定了采样率,也可尝试删掉这句(同时要配置Recorder.ConnectEnableWebM=false)

var trackSet=set.audioTrackSet||{};
trackSet[sampleRateTxt]=ctx[sampleRateTxt];//必须指明采样率,不然手机上MediaRecorder采样率16k
var mSet={audio:trackSet};
try{
var pro=Recorder.Scope[getUserMediaTxt](mSet,f1,f2);
}catch(e){//不能设置trackSet就算了
This.CLog(getUserMediaTxt,3,e);
mSet={audio:true};
pro=Recorder.Scope[getUserMediaTxt](mSet,f1,f2);
};
This.CLog(getUserMediaTxt+"("+JSON.stringify(mSet)+") "+CtxState(ctx)

@heipaoDoctor
Copy link

有个疑问,为啥不设置采用率时,要关掉 ConnectEnableWebM 呢?ConnectEnableWebM=false

@xiangyuecn
Copy link
Owner

@heipaoDoctor 这行设置采样率的代码,也是为了给ConnectEnableWebM用的,开启ConnectEnableWebM后会优先使用MediaRecorder,如果不设置sampleRate参数,MediaRecorder录出来的数据采样率各种值都有,没法正常使用。去掉采样率配置后,就需要同时禁用掉ConnectEnableWebM

@xiangyuecn
Copy link
Owner

有些手机浏览器去掉采样率配置后可能无法打开录音,调用getUserMedia的时候如果失败了要做一次重试,提供上采样率配置重试

@xiangyuecn xiangyuecn added the bug Something isn't working label Aug 30, 2024
@xiangyuecn
Copy link
Owner

新版本 1.3.24102001 已发布,已经删除了getUserMedia参数中的sampleRate配置;同时增强了对MediaRecorder的支持,返回的任意采样率数据均可正常录制

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants