diff options
author | elioat <elioat@tilde.institute> | 2024-07-03 22:24:23 -0400 |
---|---|---|
committer | elioat <elioat@tilde.institute> | 2024-07-03 22:24:23 -0400 |
commit | 764c606cd82ce02b6285f947231a6493d7dc2674 (patch) | |
tree | 8159486e6965874cf0d3b476c3e7476fb3a98784 | |
parent | 320706b226be2bdf519e4a47ee5b7b7181e803d1 (diff) | |
download | tour-764c606cd82ce02b6285f947231a6493d7dc2674.tar.gz |
*
-rw-r--r-- | js/pico-cam/pico-cam.js | 13 |
1 files changed, 10 insertions, 3 deletions
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'); |