简体   繁体   English

如何流式传输blob

[英]How to stream the blob

I am developing a radio system with a microphone, the system admin will speak into the microphone and the audio will be transmitted in real time to the User ... I'm newbie using node.js and I'm unsure of how to make the stream the audio from the microphone to the User ... can anyone help me? 我正在开发一个带麦克风的无线电系统,系统管理员将对着麦克风说话,音频将实时传输给用户......我是使用node.js的新手,我不确定如何制作从麦克风到用户的音频流...任何人都可以帮助我吗?

I have the following problem, I have the audio from the microphone being recorded in a blob and I need to know how to stream live this blob ... 我有以下问题,我将麦克风中的音频记录在blob中,我需要知道如何直播这个blob ...

I do not have code to show only gives audio recording ... 我没有代码只显示录音...

    <script>
        function getByID(id) {
            return document.getElementById(id);
        }

        var recordAudio = getByID('record-audio'),
            stopRecordingAudio = getByID('stop-recording-audio');

        var audio = getByID('audio');


        var audioConstraints = {
            audio: true,
            video: false
        };

    </script>
    <script>
        var audioStream;
        var recorder;

        recordAudio.onclick = function() {
            if (!audioStream)
                navigator.getUserMedia(audioConstraints, function(stream) {
                    if (window.IsChrome) stream = new window.MediaStream(stream.getAudioTracks());
                    audioStream = stream;

                    audio.src = URL.createObjectURL(audioStream);
                    audio.muted = true;
                    audio.play();

                    // "audio" is a default type
                    recorder = window.RecordRTC(stream, {
                        type: 'audio'
                    });
                    recorder.startRecording();
                }, function() {
                });
            else {
                audio.src = URL.createObjectURL(audioStream);
                audio.muted = true;
                audio.play();
                if (recorder) recorder.startRecording();
            }

            window.isAudio = true;

            this.disabled = true;
            stopRecordingAudio.disabled = false;
        };


        stopRecordingAudio.onclick = function() {
            this.disabled = true;
            recordAudio.disabled = false;
            audio.src = '';

            if (recorder)
                recorder.stopRecording(function(url) {
                    audio.src = url;
                    audio.muted = false;
                    audio.play();

                    document.getElementById('audio-url-preview').innerHTML = '<a href="' + url + '" target="_blank">Recorded Audio URL</a>';

                });
        };

    </script>

I am no expert but I recalled that there are few articles about capturing audio on the html5rocks. 我不是专家,但我记得很少有关于在html5rocks上捕获音频的文章。

http://updates.html5rocks.com/2012/01/Web-Audio-FAQ http://www.html5rocks.com/en/tutorials/getusermedia/intro/#toc-webaudio-api http://updates.html5rocks.com/2012/01/Web-Audio-FAQ http://www.html5rocks.com/en/tutorials/getusermedia/intro/#toc-webaudio-api

You should try to search in the npm library. 您应该尝试在npm库中搜索。 I think it might have some streaming node modules. 我认为它可能有一些流节点模块。 (Starting develop from a core node.js API is really hard, i couldn't figured it out too.) (从核心node.js API开始开发真的很难,我也想不通。)

Also take a look at this: 另外看看这个:
Node.js synchronized audio streaming between server and clients? Node.js在服务器和客户端之间同步音频流?

and here is node modules for sending binary data (i think it's support streaming a blob): http://binaryjs.com/ 这里是用于发送二进制数据的节点模块(我认为它支持流式传输): http//binaryjs.com/

Hoped these helps! 希望这些帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM