I am using javascript to record video with webcam and also upload/download the recorded blob as a video file.
I would like the ability to chop off starting section and trailing sections of the video.
/**
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);
}
Unfortunately, the result blob is not recognized as a video by the browser. any ideas ?