Вопрос

I want to record audio through the web browser using mic and want to stream that to my shoutcast server. So that user can listen the live streaming instantly. Is there any possible way to do this. Will be playable from iPhone as well.

Had search a lot of things over the web but can't find the exact one. Please let me know if there any possible way.

Already used the WebRTC audio broadcasting script. Which is working over the web but the stream is not available on iPhone. Whenever I am going to joint a room it displays can't play the audio.

Это было полезно?

Решение

I've done this in the past. You can try it out at http://demo.audiopump.co:3000.

The only way to current get audio in the browser is with getUserMedia and the Web Audio API. This gets you PCM samples. Unfortunately there is no way to use the browser codecs programmatically currently.

I handle this by sending the PCM samples to the server. Now, I don't send them as 32-bit floats, which is the format they are in. I detect the buffer size for the web socket and adjust the bit depth accordingly. If there is enough bandwidth I will send 16-bit stereo. Otherwise I can drop down to 8-bit mono. On the server, the samples are converted back up to 32-bit float and encoded with Ffmpeg.

From there, the data is sent live to the SHOUTcast server.

Другие советы

Record audio using RecordRTC; use ffmpeg.js or ffmpeg-asm.js to convert WAV to mp3 or ogg; then you can make HTTP-PUT request to shoutcast server to upload low-size ogg; then shoutcast server can broadcast it to all relevant radio stations.

P.S. By "low-size" I mean, for 1 minute audio; you can get 700kb to 1024kb ogg.

P.S. I'll add some demos on my github repository; very soon.


Updated:

It is possible to use Google Speech Recognition API to convert voice to text; that text can be streamed to nodejs server through socketio; where you can use ffmpeg for text-to-speech and encode into ogg or other formats; that encoded ogg can be forwarded (using PUT request) to shoutcast server.

You can try Translator.js.

Yes, We can record the live Audio streaming using AVAudioSession . Please go through Apple document for further details.

https://developer.apple.com/library/ios/documentation/AVFoundation/Reference/AVAudioSession_ClassReference/Reference/Reference.html

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top