无法在recordRTC中记录更高的帧率

时间:2018-05-17 16:13:50

标签: javascript angular webrtc webm recordrtc

使用recordRTC到webm不能记录高于30 fps的内容。相机能够以所需分辨率1920x1080以60 fps录制。关于如何完全记录60 fps的任何想法?

    var options = {
      mimeType: 'video/webm',
      video: {
          width: 1920,
          height: 1080
       },
      bitsPerSecond: 51200000,
      frameRate: 60
    };
  this.stream = stream;
  this.recordRTC = RecordRTC(stream, options);

1 个答案:

答案 0 :(得分:0)

请试试这个:

<script src="https://cdn.webrtc-experiment.com/RecordRTC.js"></script>
<script src="https://webrtc.github.io/adapter/adapter-latest.js"></script>

<button id="btn-record">Click To Record</button>
<hr>
<video id="your-video" autoplay playsinline controls style="width: 50%; border-adius: 9px;"></video>
<script>
var recorder;
var yourVideo = document.getElementById('your-video');
document.getElementById('btn-record').onclick = function() {
    this.disabled = true;
    this.style.background = 'transparent';
    this.style.color = 'grey';

    var cameraProperties = {
        video: {
            width: 1920,
            height: 1080
        },
        audio: true
    };

    navigator.mediaDevices.getUserMedia(cameraProperties)
        .then(function(cameraStream) {
            yourVideo.volume = 0;
            yourVideo.srcObject = cameraStream;

            recorder = RecordRTC(cameraStream, {
                videoBitsPerSecond: 51200000,
                mimeType: 'video/webm'
            });
            recorder.startRecording();

            setTimeout(function() {
                recorder.stopRecording(function() {
                    var blob = recorder.getBlob();
                    alert('Recording size: ' + bytesToSize(blob.size));

                    var videoURL = URL.createObjectURL(blob);
                    yourVideo.srcObject = null;
                    yourVideo.volume = 1;
                    yourVideo.src = videoURL;
                });
            }, 5000);
        }).catch(function(error) {
            console.error('Unable to capture 1080p', error);
            alert('Maybe 1080p is not supported by your camera. Please check yoru console logs.');
        });
};
</script>