Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Capture system sound from browser

I am trying to build a web app that captures both local and remote audios from a webrtc call, but I can`t record the remote audio(using recordRTC). I was wondering if I could capture the system sound somehow.

Is there a way to capture the system sound (not just the mic) from the browser. Maybe an extension?

like image 923
Victor Canezin de Oliveira Avatar asked Dec 12 '15 01:12

Victor Canezin de Oliveira


People also ask

Can I record audio from my browser?

Chrome Audio Capture is a Chrome extension that allows users to record any audio playing on the current tab. Multiple tabs can be recorded simultaneously. Recordings can be saved as either . mp3 or .


1 Answers

In Chrome, the chrome.desktopCapture extension API can be used to capture the screen, which includes system audio (but only on Windows and Chrome OS and without plans for OS X or Linux). E.g.

chrome.desktopCapture.chooseDesktopMedia([
    'screen', 'window' // ('tab' is not supported; use chrome.tabCapture instead)
], function(streamId) {
    navigator.webkitGetUserMedia({
        audio: {
            mandatory: {
                chromeMediaSource: 'system',
                chromeMediaSourceId: streamId
            }
        },
        video: false, // We only want audio for now.
    }, function(stream) {
        // Do what you want with this MediaStream.
    }, function(error) {
        // Handle error
    });
});

I'm not sure whether Firefox can capture system sound, but at the very least it is capable of capturing some output (tab/window/browser/OS?). First you need to visit about:config and set media.getusermedia.audiocapture.enabled to true (this could be automated through a Firefox add-on). Then the stream can be captured as follows:

navigator.mozGetUserMedia({
    audio: {
        mediaSource: 'audioCapture'
    },
    video: false, // Just being explicit, we only want audio for now
}, function(stream) {
    // Do what you want with this MediaStream.
}, function(error) {
    // Handle error
});

This was implemented in Firefox 42, at https://bugzilla.mozilla.org/show_bug.cgi?id=1156472

like image 118
Rob W Avatar answered Sep 17 '22 21:09

Rob W