From 9893b66d5d682cd72c372494f34a0fd9b67147a9 Mon Sep 17 00:00:00 2001 From: yashrajbharticybtekk Date: Sun, 28 Apr 2024 05:19:46 +0530 Subject: [PATCH] add video capture js --- js/video-capture-and-save.mjs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/js/video-capture-and-save.mjs b/js/video-capture-and-save.mjs index be63a24..e467cb0 100644 --- a/js/video-capture-and-save.mjs +++ b/js/video-capture-and-save.mjs @@ -1,6 +1,7 @@ export let mediaRecorder = null; let chunks = []; let startTime = null; +let timerInterval; const recordingIndicator = document.createElement("div"); export const captureVideo = () => { @@ -30,7 +31,11 @@ const recordVideo = async (isMirrored = false, facingModeButton) => { startTime = Date.now(); // Start time for elapsed time calculation mediaRecorder.start(); mediaRecorder.ondataavailable = (event) => { - chunks.push(event.data); + const blob = new Blob([event.data], { + type: "video/mp4", + }); + chunks.push(blob); + console.log(chunks); }; // Start recording indicator @@ -39,7 +44,7 @@ const recordVideo = async (isMirrored = false, facingModeButton) => { document.body.appendChild(recordingIndicator); // Update recording indicator at regular intervals - const timerInterval = setInterval(() => { + timerInterval = setInterval(() => { const elapsedTime = Date.now() - startTime; recordingIndicator.textContent = formatTime(elapsedTime); }, 1000);