Stream getUserMedia to an Icecast server?

2020-02-09 15:10发布

问题:

Is there a way to stream the local blob created by webrtc's getUserMedia (vidio and audio) to an Icecast server, making it possible to live broadcast using HTML5?

Specifically in the following example (from Justin Uberti's 2012 Google I/O video) I can capture audio/video and play it locally in a video element:

<script type="text/javascript">
var onGotStream = function(stream) {
  var url = webkitURL.createObjectURL(stream);
  video.src = url; //
}
navigator.webkitGetUserMedia({video: true, audio: true}, onGotStream, null);
<script>

<video = id='video' autoplay='autoplay'/>

But instead of setting the video src to the local blob I'd like to send the stream to an Icecast server and then play that live stream using video elements pointing to the Icecast server.

Is this possible? How would I go about it?

Thanks!!

回答1:

Take a look at this

https://github.com/webcast/webcaster

it captures getUserMedia PCM, encodes it to MP3 format using JavaScript right in your browser, sends encoded MP3 data to Liquidsoap http://liquidsoap.fm/ via Websockets and then Liquidsoap can broadcast that stream to Icecast server.