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

126.0.6478.127 chrome desktop,M1 mac 机型静音问题 #230

Open
heipaoDoctor opened this issue Jun 27, 2024 · 8 comments
Open

126.0.6478.127 chrome desktop,M1 mac 机型静音问题 #230

heipaoDoctor opened this issue Jun 27, 2024 · 8 comments
Labels
bug Something isn't working

Comments

@heipaoDoctor
Copy link

heipaoDoctor commented Jun 27, 2024

有用户反馈,在如上的电脑型号上录音有静音的问题,在 官方demo 则没有这个问题 https://mdn.github.io/dom-examples/media/web-dictaphone/
大家有无遇到该问题?

@xiangyuecn
Copy link
Owner

Recorder默认也是使用的 MediaRecorder 获取音频数据,但多了个codec设置

new MediaRecorder(stream, {mimeType:"audio/webm; codecs=pcm"})

你可以修改一下mdn那个页面,MediaRecorder里面也加一下这个设置,试试是不是这个问题导致的

mediaRecorder.onstop里面直接把audioURL打印出来,复制这个url可以下载得到pcm文件,pcm文件拖进下面这个页面可以播放

https://xiangyuecn.github.io/Recorder/assets/%E5%B7%A5%E5%85%B7-%E8%A3%B8PCM%E8%BD%ACWAV%E6%92%AD%E6%94%BE%E6%B5%8B%E8%AF%95.html

@heipaoDoctor
Copy link
Author

这个问题又遇到了,也是 M1 机型,试了下老版本的测试页面没有问题:
https://xiangyuecn.github.io/Recorder/assets/%E5%B7%A5%E5%85%B7-GitHub%E9%A1%B5%E9%9D%A2%E5%8E%86%E5%8F%B2%E7%89%88%E6%9C%AC%E8%AE%BF%E9%97%AE.html#url=xiangyuecn:[email protected],/
请问新老版本有什么区别呢

@heipaoDoctor
Copy link
Author

改了一下官方html文件,加了 {mimeType:"audio/webm; codecs=pcm"} 参数,还是能正确工作

@heipaoDoctor
Copy link
Author

客户电脑里存在虚拟麦克风,该库的主测试页面:
https://xiangyuecn.github.io/Recorder/
在不设置麦克风的情况下:调用的是 getUserMedia({audio: {sampleRate: xxx}}) 不能使用正确的电脑默认麦克风设备,而选择了虚拟麦克风设备,导致无法录音。
原因还不明

@xiangyuecn
Copy link
Owner

去掉 trackSet[sampleRateTxt]=ctx[sampleRateTxt] 这个配置试试,可能是因为配置了sampleRate,同时设置 Recorder.ConnectEnableWebM=false 禁用掉MediaRecorder

trackSet[sampleRateTxt]=ctx[sampleRateTxt];//必须指明采样率,不然手机上MediaRecorder采样率16k
var mSet={audio:trackSet};
try{
var pro=Recorder.Scope[getUserMediaTxt](mSet,f1,f2);

@heipaoDoctor
Copy link
Author

hi, 经过测试,getUserMedia 中设置 audio 的 sampleRate 时,chrome 会根据该数据去选择麦克风。当 audio 为 true 时,chrome 会选择 chrome://settings/content/microphone 中设置的麦克风。这个比较符合我们的预期。

在使用该库时:如果传 audioTrackSet 为 true,在 react 中会有该类报错:Cannot create property 'sampleRate' on boolean 'true'

this.rec = Recorder({
type: 'mp3',
audioTrackSet: true,
sampleRate: option.config?.sampleRate || 32000,
bitRate: option.config?.bitRate || 64, //mp3格式,指定采样率hz、比特率kbps,其他参数使用默认配置
});

能否在 trackSet[sampleRateTxt]=ctx[sampleRateTxt];//必须指明采样率,不然手机上MediaRecorder采样率16k 设置时,先判断 trackSet 是否为对象呢?如果是对象再设置采样率,否则就不设置了

@xiangyuecn
Copy link
Owner

下一版本看看删掉这个采样率配置,移除MediaRecorder支持

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

@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

2 participants