3

我正在使用 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 识别为视频。有任何想法吗 ?

4

0 回答 0