最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Html5 separating audio stream from video stream - Stack Overflow

programmeradmin0浏览0评论

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?

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?

Share Improve this question asked Dec 2, 2017 at 18:54 Ronen RabinoviciRonen Rabinovici 9,1326 gold badges38 silver badges46 bronze badges 1
  • This might be better to do server side with ffmpeg or something similar.. – Mr Zach Commented Dec 2, 2017 at 19:23
Add a ment  | 

1 Answer 1

Reset to default 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.

发布评论

评论列表(0)

  1. 暂无评论