coppthi
coppthi

Reputation: 105

Turn chrome.tabcapture.capture into an audio file?

I"m trying to use the chrome API https://developers.chrome.com/extensions/tabCapture. How do I get a audio file out of it. For example, if I'm watching youtube and want to export whatever song I'm doing into an audio file MP3, wav, etc. I know there are some chrome extensions out there that does this but I want to know if there is an API. Thanks!

Upvotes: 0

Views: 1682

Answers (1)

kzahel
kzahel

Reputation: 2785

Use the desktopCapture API with DesktopCaptureSourceType "audio"

Saving the stream may be more challenging. You could create a Web Audio API Audio context and call decodeAudioData() to get raw PCM data (e.g. .wav file). MP3 encoding you might be able to find some kind of Emscripten module for.

Alternatively, it looks like there is a media recorder API (demo) I'm not sure if this is stable in many browsers yet, but I just tried in Chrome and it seemed to work.

Upvotes: 1

Related Questions