Send chunks from MediaRecorder to server and play it back in the browser

后端 未结 3 907
温柔的废话
温柔的废话 2021-02-09 06:28

With the following code in NodeJS I\'m able to play a webm file served from server:

app.get(\'/video\', function(req, res){
    res.writeHead(200,{
        \'Con         


        
相关标签:
3条回答
  • 2021-02-09 06:49

    Thanks to key help from Brad's FB sample, I was able to put together a working version that sends an audio/video stream to icecast, which then can easily be played back in a browser. Since the audio and video codecs are directly copied, it's only 5 - 10 seconds of lag.

    Here's the link:

    https://gitlab.com/jamie/icecast-web-source-client

    0 讨论(0)
  • 2021-02-09 07:12

    You can't just needle-drop into the WebM stream. WebM/Matroska require some setup to initialize the track info and what not. After that, you'll have Clusters, and you have to start on a Cluster. Additionally, Chrome is going to require that each Cluster start on a keyframe, which you're not going to be able to guarantee with the data from MediaRecorder. Therefore, server-side transcoding (or at least, some nasty hacking on the VP8 stream) is needed.

    0 讨论(0)
  • 2021-02-09 07:13

    SFMediaStream could help you splitting media stream into chunk and play it back to the browser, or maybe on the server's speaker for Raspberry. And also adding effect on your stream, it would be fun enough to try the available effects.

    //* Broadcaster
    var presenterMedia = new ScarletsMediaPresenter(/*{options}*/);
    
    // Send the packet below somewhere
    presenterMedia.onRecordingReady = function(bufferHeader){};
    presenterMedia.onBufferProcess = function(packet){};
    
    //* Streamer
    var audioStreamer = new ScarletsAudioStreamer();
    audioStreamer.playStream();
    
    // Receive from somewhere
    audioStreamer.setBufferHeader(/* bufferHeader */);
    audioStreamer.receiveBuffer(/* packet */);
    

    There are some example on the repository if you want more detail on how to use it.

    0 讨论(0)
提交回复
热议问题