Chrome extension: Prevent chrome.tabCapture.capture choppy sound by increasing buffer size?

ⅰ亾dé卋堺 提交于 2021-01-27 13:48:07

问题


It's seems like audio capturing using chrome.tabCapture.capture can produce some choppy sounds.

There is already a bug report for this.

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?

Basic capturing:

chrome.tabCapture.capture({
        audio: true,
        video: false
    }, function (stream) {
        var ctx = new AudioContext();
        var output = ctx.createMediaStreamSource(stream);
        output.connect(ctx.destination)
    });

回答1:


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'});

Here you can read more about it: MDN AudioContext.AudioContext()

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.



来源:https://stackoverflow.com/questions/45910705/chrome-extension-prevent-chrome-tabcapture-capture-choppy-sound-by-increasing-b

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!