Javascript 使用Webrtc捕获网络摄像头视频时,如何修剪录制的视频?
我使用javascript通过网络摄像头录制视频,并将录制的blob上传/下载为视频文件 我想能够砍掉视频的开始部分和结尾部分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
/**
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识别为视频。有什么想法吗?请参见,