mardi 3 juillet 2018

How to set maximum fragment size when using MediaRecoder() API?

I am trying to use MediaRecoder API to record video in format 'webm/h264'. It works well, until I wanna set the maximum group of picture(GOP) size cause I don't want many video formatted in a whole fragment. After reading some material I found there might be two solutions:

  1. Making each blob produced by mediaRecorder.ondataavailable() a single fragment.

  2. set maximum gop size. But I still don't know what to write in my code to realize these ways. Here is part of the code:

    var options = {mimeType: 'video/webm;codecs=h264'}
    recordedBlobs = [];
    mediaRecorder = new MediaRecorder(window.stream, options);
    mediaRecorder.onstop = handleStop;
    mediaRecorder.ondataavailable = handleDataAvailable;
    mediaRecorder.start(100);
    
    function handleDataAvailable(event) {
        if (event.data && event.data.size > 0) {
        recordedBlobs.push(event.data);
        }
    }
    
    

    Anyone help? Thanks!!




Aucun commentaire:

Enregistrer un commentaire