首页 文章

WebRTC保存视频和音频[重复]

提问于
浏览
2

这个问题在这里已有答案:

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

2 回答

  • 1

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

    Link to Repo .

  • 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);
                });
         });
    

相关问题