3

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 ?

user193116
  • 3,498
  • 6
  • 39
  • 58
  • See [How to make range request for any portion of a media fragment?](https://stackoverflow.com/questions/45024915/how-to-make-range-request-for-any-portion-of-a-media-fragment), [How to use Blob URL, MediaSource or other methods to play concatenated Blobs of media fragments?](https://stackoverflow.com/questions/45217962/how-to-use-blob-url-mediasource-or-other-methods-to-play-concatenated-blobs-of), [How to use “segments” mode at SourceBuffer of MediaSource to render same result at Chomium, Chorme and Firefox?](https://stackoverflow.com/questions/46379009/) – guest271314 Oct 17 '17 at 04:54

0 Answers0