如何捕获HTML5麦克风输入到icecast? [英] How to capture HTML5 microphone input to icecast?

查看:312
本文介绍了如何捕获HTML5麦克风输入到icecast?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通过HTML5 / Javascript(不闪光)捕捉麦克风音频流,然后将其发送到已建立的icecast服务器的步骤和方法是什么?

解决方案必须完全基于浏览器/网络,不需要额外的软件。
服务器在Rails 5.0.0.1上。



我应该从哪里开始?



我很努力地在网上找到任何相关信息,因为所有内容都是关于将音频文件上传/录制为完整文件而不是流。


<这个解决方案必须是基于浏览器/网络的,不需要额外的软件。

目前还不可能,因为有


What are the steps and means of capturing microphone audio stream through HTML5 / Javascript (no flash) and then sending it to an already set up icecast server?

The solution must be solely browser/web-based, no additional software. The server is on Rails 5.0.0.1.

Where should I start?

I'm struggling to find any relevant info online as everything talks about uploading/recording audio files as complete files, not streams.

解决方案

The solution must be solely browser/web-based, no additional software.

That's not possible at the moment, because there is no way to make a streaming HTTP PUT request. That is, to make an HTTP request either via XHR or Fetch, the request body has to be immutable.

There is a new standard of ReadableStream which will be available any day now, allowing you to make a ReadableStream (your encoded audio) and PUT it to a server. Once that is available, this is possible.

The server is on Rails 5.0.0.1.

Not sure why you mention that since you said it has to all live in the browser. In any case, let me tell you how I implemented this, with a server-side proxy.

Client-side, you need to capture the audio with getUserMedia(). (Be sure to use adapter.js, as the spec has recently changed and you don't want to have to deal with the constraints object changes manually.) Once you have that, you can either send PCM samples (I'd recommend reducing from 32-bit float to 16-bit signed first), or you can use a codec like AAC or MP3 client-side. If you do the codec in the client, you're only going to be able to send one or two streams. If you do the codec server-side, you can derive as many as you want, due to CPU requirements, but you will take more bandwidth depending on the streams you're deriving.

For the codec on the client, you can either use MediaRecorder, or a codec compiled to JavaScript via emscripten (or similar). Aurora.js has some codecs for decoding, but I believe at least one of the codecs in there also had encoding.

To get the data to the server, you need a binary web socket.

On the server side, if you're keeping the codecs there, FFmpeg makes this easy.

Once you have the encoded audio, you need to make your HTTP PUT request to Icecast or similar, as well as update the metadata either out-of-band, or muxed into the container that you're PUT-ing to the server.


Self Promotion: If you don't want to do all of that yourself, I have some code you can license from me called the AudioPump Web Encoder, which does exactly what you ask for. You can modify it for your needs, take components and embed them into your project, etc. E-mail me at brad@audiopump.co if you're interested.

这篇关于如何捕获HTML5麦克风输入到icecast?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆