Chrome扩展程序:通过增加缓冲区大小来防止chrome.tabCapture.capture声音不稳定? [英] Chrome extension: Prevent chrome.tabCapture.capture choppy sound by increasing buffer size?
问题描述
似乎使用 chrome.tabCapture.capture
进行音频捕获>会产生一些断断续续的声音.
It's seems like audio capturing using chrome.tabCapture.capture
can produce some choppy sounds.
已经有一个错误报告.
是否可以增加接收捕获流的缓冲区以防止卡顿,或者 tabCapture
方法是否已经定义了缓冲区?
Is it possible to increase the buffer that receives the captured stream in order to prevent the stutter, or does the tabCapture
method already defines a buffer?
基本捕获:
chrome.tabCapture.capture({
audio: true,
video: false
}, function (stream) {
var ctx = new AudioContext();
var output = ctx.createMediaStreamSource(stream);
output.connect(ctx.destination)
});
推荐答案
我遇到了同样的问题,但是如果您创建带有 LatencyHint
的 AudioContext
,则杂音似乎消失了code>参数:
I had the same issue, but the choppy sound seems to disappear if you create the AudioContext
with a LatencyHint
argument:
new AudioContext({latencyHint: 'playback'});
在这里您可以阅读有关它的更多信息: MDN AudioContext.AudioContext()
Here you can read more about it: MDN AudioContext.AudioContext()
latencyHint:此值标识播放的类型,这会影响音频输出延迟和功耗之间的折衷.首选值为平衡",互动"和播放" ,默认值为互动".这些值表示平衡音频输出等待时间和功耗",提供最低的音频输出等待时间而不出现毛刺"和优先考虑持续播放而不中断音频输出等待时间" .您还可以将延迟秒数指定为double值,以实现更好的控制.
latencyHint: This value identifies type of playback, which affects tradeoffs between audio output latency and power consumption. The prefered values are "balanced", "interactive", and "playback", with the default value: "interactive". These values mean "balance audio output latency and power consumption", "provide lowest audio output latency as possible without glitching", and "prioritize sustained playback without interruption over audio output latency". You can also specify double value for the number of seconds of latency, for finer control.
这篇关于Chrome扩展程序:通过增加缓冲区大小来防止chrome.tabCapture.capture声音不稳定?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!