Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/88.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 使用Webrtc捕获网络摄像头视频时,如何修剪录制的视频?_Javascript_Html_Video_Webrtc_Web Mediarecorder - Fatal编程技术网

Javascript 使用Webrtc捕获网络摄像头视频时,如何修剪录制的视频?

Javascript 使用Webrtc捕获网络摄像头视频时,如何修剪录制的视频?,javascript,html,video,webrtc,web-mediarecorder,Javascript,Html,Video,Webrtc,Web Mediarecorder,我使用javascript通过网络摄像头录制视频,并将录制的blob上传/下载为视频文件 我想能够砍掉视频的开始部分和结尾部分 /** extract a segment from the video starting at startTS and ending at endTS tempBlob : is an array where data was accumulated by the mediaRecorder.ondataavailable method pus

我使用javascript通过网络摄像头录制视频,并将录制的blob上传/下载为视频文件

我想能够砍掉视频的开始部分和结尾部分

/**
     extract a segment from the video starting at startTS and ending at endTS

     tempBlob : is an array where data was accumulated by the mediaRecorder.ondataavailable  method pushed data
    startTS : staring time
    endTS : end time 

    **/    
    var trimRecordedBlob= function(tempBlob, startTS, endTS,videoelement ){
            var startIndex= Math.floor(startTS*1000/app.MIN_VIDEO_SLICE_TIME_MS);
            if(startIndex===0) startIndex=2;

            var deleteCount= Math.floor( ((endTS - startTS)*1000)/app.MIN_VIDEO_SLICE_TIME_MS)

            console.log("trim recorded blob" );

            var newArray1 = tempBlob.slice();

             newArray1.splice(startIndex, deleteCount);
            var superBuffer = new Blob(newArray1, { type: 'video/webm' });
            videoelement.src = window.URL.createObjectURL(superBuffer);
        }
不幸的是,浏览器无法将结果blob识别为视频。有什么想法吗?

请参见,