Using userMedia I get a stream that contains both video and audio. Is there a way to separate them? Ie out of the one stream get 2 streams one that has only video and the other has only audio?
Asked
Active
Viewed 2,086 times
5
-
This might be better to do server side with ffmpeg or something similar.. – Mr Zach Dec 02 '17 at 19:23
1 Answers
11
Use the MediaStream
constructor to create new streams from the audio and video tracks:
let stream = await navigator.mediaDevices.getUserMedia({video: true, audio: true});
audioStream = new MediaStream(stream.getAudioTracks());
videoStream = new MediaStream(stream.getVideoTracks());
Here's a working fiddle.

jib
- 40,579
- 17
- 100
- 158