From 764c606cd82ce02b6285f947231a6493d7dc2674 Mon Sep 17 00:00:00 2001 From: elioat Date: Wed, 3 Jul 2024 22:24:23 -0400 Subject: * --- js/pico-cam/pico-cam.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'js/pico-cam/pico-cam.js') diff --git a/js/pico-cam/pico-cam.js b/js/pico-cam/pico-cam.js index 4f2eada..d2c06f3 100644 --- a/js/pico-cam/pico-cam.js +++ b/js/pico-cam/pico-cam.js @@ -74,9 +74,9 @@ captureFrameButton.addEventListener('click', () => { }); captureVideoButton.addEventListener('click', () => { - const startRecording = (canvas, duration) => { + const startRecording = (canvas, duration, frameRate) => { return new Promise((resolve, reject) => { - const stream = canvas.captureStream(); + const stream = canvas.captureStream(frameRate); if (!stream) { const errtxt = 'Stream capture from canvas failed.'; console.error(errtxt); @@ -103,6 +103,12 @@ captureVideoButton.addEventListener('click', () => { reject(event.error); }; + // Set the desired frame rate + mediaRecorder.onstart = () => { + const options = mediaRecorder.videoBitsPerSecond; + mediaRecorder.videoBitsPerSecond = options * frameRate; + }; + // console.log('Starting recording...'); mediaRecorder.start(); setTimeout(() => { @@ -120,7 +126,8 @@ captureVideoButton.addEventListener('click', () => { try { captureVideoButton.disabled = true; - const videoBlob = await startRecording(ditheredOutput, videoLength); + const frameRate = 10; // Frame rate + const videoBlob = await startRecording(ditheredOutput, videoLength, frameRate); const videoURL = URL.createObjectURL(videoBlob); const videoLink = document.createElement('a'); -- cgit 1.4.1-2-gfad0