WebRTC保存视频和音频

时间:2014-05-04 17:16:20

标签: webrtc

我想将录制的视频和音频保存到服务器。但我不想在客户端对视频和音频进行编码,我想在服务器端对它们进行编码。如何将视频和音频发送到服务器?我流了吗?

2 个答案:

答案 0 :(得分:2)

您可以查看此回购:Html5_Video_Audio_Recorder

以下是库的基本用法

var virec = new VIRecorder.initVIRecorder(
            {   
                recorvideodsize : 0.4, // recorded video dimentions are 0.4 times smaller than the original
                webpquality     : 0.7, // chrome and opera support webp imags, this is about the aulity of a frame
                framerate       : 15,  // recording frame rate 
                videotagid      : "viredemovideoele", 
                videoWidth      : "640",
                videoHeight     : "480",            
            } ,
            function(){
                //success callback. this will fire if browsers supports 
            },
            function(err){
                //onerror callback, this will fire if browser does not support
                console.log(err.code +" , "+err.name);
            }
     );
     startRecord.addEventListener("click" , function(){
            virec.startCapture(); // this will start recording video and the audio 
            startCountDown(null);
     });

     stopRecord.addEventListener("click" , function(){
            virec.stopCapture(oncaptureFinish); 
     });

     playBackRecord.addEventListener("click" , function(){
            virec.play(); /*Clientside playback,*/
     });

     discardRecordng.addEventListener("click" , function(){
            virec.clearRecording();
     });

     uploadrecording.addEventListener("click" , function(){
            var uploadoptions = {
                    blobchunksize : 1048576,
                    requestUrl : "php/fileupload.php",
                    requestParametername : "filename", 
                    videoname : "video.webm",
                    audioname : "audio.wav"
            };
            virec.uploadData( uploadoptions , function(totalchunks, currentchunk){
                progressNumber.innerHTML = ((currentchunk/totalchunks)*100);
                console.log(currentchunk +" OF " +totalchunks);
            });
     });

答案 1 :(得分:1)

您可以通过websockets将音频和视频发送到WebSocket服务器,然后WebSocket服务器可以按您希望的方式处理数据包。目前有记录器,我已经修改了一些,专注于通过websockets发送,而不是下载文件。

Link to Repo