In-browser webcam source via openWebcamCapture()
One call opens a modal that previews the user's webcam, lets them snap a JPEG (mode: 'photo') or record a webm/mp4 clip (mode: 'video'), and resolves with a File ready to drop into the upload queue. Pure browser - no third-party SDK, no server work.
First click prompts for camera permission. Press Esc in the modal to cancel.
Browser requirements: secure context (HTTPS or
localhost) and user permission for the camera (and microphone in video mode). Falls back to a descriptive rejected promise if either is unavailable.
JavaScript API
// Photo mode (default) - resolves with image/jpeg.
uploader.openWebcamCapture()
.then(file => uploader.addFile(file));
// Video mode with mic + 60-second cap.
uploader.openWebcamCapture({
mode: 'video',
audio: true,
maxDurationSec: 60,
mimeType: 'video/webm;codecs=vp9,opus', // optional
fileName: 'demo-clip.webm' // optional
}).then(file => uploader.addFile(file));What ships
- Modal overlay with live
<video>preview, action buttons, and an elapsed-time status row. - Format negotiation via
MediaRecorder.isTypeSupported- picks the best WebM / MP4 codec the browser supports. - Esc cancels and rejects with
Error('cancelled')- easy to filter out of error logs. - All tracks stop automatically on close to release the camera light.
Pair with the image editor
Webcam -> image editor -> upload is a single Promise chain:
uploader.openWebcamCapture({ mode: 'photo' })
.then(file => uploader.openImageEditor(file, { aspectRatio: 1 }))
.then(edited => uploader.addFile(edited));