join us on Discord for support, updates, and all things Snap AR! See you there!
[Camera-kit for Web] Recording mediastream
Hi guys,
I am trying to make a video recording function for camera-kit web. But I have a problem to get mediastream data. Actually, I couldn't get any data at all. I followed the tutorial posted in camera-kit docs. Code is as below.
- open capturestream
- initialize mediarecorder with capturestream
- check data
const stream = session.output.capture.captureStream();
const mediaRecorder = new MediaRecorder(stream, {mimeType: localMimeType});
let localChunks = [];
mediaRecorder.ondataavailable = (e) => {
if (typeof e.data === "undefined") return;
if (e.data.size === 0) return;
localChunks.push(e.data);
};
Comments
-
Hi @Tony! This is a bit outside of Camera Kit's purview but I'm happy to provide a little guidance based on what I see in your sample code.
In order for a
MediaRecorder
instance to begin recording and processing data, you need to callstart()
on it. Keep in mind, thestart
method has an optionaltimeslice
parameter (which is the number of milliseconds to record into eachBlob
). If you don't provide a value for this parameter, thedataavailable
event will only be fired after you callstop()
on theMediaRecorder
instance (which will place all of the recorded data in a singleBlob
).I hope this helps!
1