Gathering detailed insights and metrics for @scottjgilroy/react-record-webcam
Gathering detailed insights and metrics for @scottjgilroy/react-record-webcam
npm install @scottjgilroy/react-record-webcam
Typescript
Module System
Node Version
NPM Version
TypeScript (100%)
Total Downloads
971
Last Day
7
Last Week
20
Last Month
63
Last Year
971
56 Stars
113 Commits
22 Forks
3 Watching
6 Branches
4 Contributors
Minified
Minified + Gzipped
Latest Version
1.1.1
Package Id
@scottjgilroy/react-record-webcam@1.1.1
Unpacked Size
61.05 kB
Size
13.91 kB
File Count
15
NPM Version
10.2.3
Node Version
20.10.0
Publised On
11 Jun 2024
Cumulative downloads
Total Downloads
Last day
-12.5%
7
Compared to previous day
Last week
33.3%
20
Compared to previous week
Last month
18.9%
63
Compared to previous month
Last year
0%
971
Compared to previous year
1
Promise based zero dependency webcam library for React. Select video and audio input for one or multiple concurrent recordings using any mix of video and audio source.
Note version 1.0 is a complete rewrite so you will need to make some changes if updating.
npm i react-record-webcam
1// record a 3s. video 2 3import { useRecordWebcam } from 'react-record-webcam' 4 5... 6 7 const { 8 activeRecordings, 9 createRecording, 10 openCamera, 11 startRecording, 12 stopRecording, 13 } = useRecordWebcam() 14 15 const example = async () => { 16 try { 17 const recording = await createRecording(); 18 if (!recording) return; 19 await openCamera(recording.id); 20 await startRecording(recording.id); 21 await new Promise((resolve) => setTimeout(resolve, 3000)); 22 await stopRecording(recording.id); 23 } catch (error) { 24 console.error({ error }); 25 } 26 }; 27 28 return ( 29 <div> 30 <button onClick={example}>Start</button> 31 {activeRecordings.map(recording => ( 32 <div key={recording.id}> 33 <video ref={recording.webcamRef} autoPlay muted /> 34 <video ref={recording.previewRef} autoPlay muted loop /> 35 </div> 36 ))} 37 </div> 38 ) 39 40... 41
Check the CodeSandbox links for above demo and one with more features.
Pass options either when initializing the hook or at any point in your application logic using applyOptions
.
1const options = { fileName: string, fileType: string, mimeType: string } 2const { ... } = useRecordWebcam(options) 3 4// or 5 6const { applyOptions } = useRecordWebcam() // import utility 7applyOptions(recording.id: string, options) // add to your application logic 8 9
Option | default value |
---|---|
fileName | timestamp |
fileType | webm |
mimeType | video/webm;codecs=vp9 |
If you want to use a specific video/audio codec you can pass this in the mimeType
. For example:
'video/webm;codecs=vp9'
'video/webm;codecs=vp8'
'video/webm;codecs=h264'
'video/x-matroska;codecs=avc1'
Please check that the browser supports the selected codec.
Pass recorder options when initializing the hook.
1const recorderOptions: { audioBitsPerSecond: number, videoBitsPerSecond: number } 2const { ... } = useRecordWebcam(recorderOptions)
Link to MDN for supported MediaOptions.
1const constraints: { aspectRatio: number, height: number, width: number } 2const { ... } = useRecordWebcam(constraints) 3 4// or 5 6const { applyConstraints } = useRecordWebcam() // import utility 7applyConstraints(recording.id: string, constraints) // add to your application logic 8
Link to MDN for supported MediaConstraints.
Method | Description |
---|---|
activeRecordings | Array of currently active recordings. |
applyConstraints(recordingId, constraints): Promise<Recording> | Apply constraints to a recording session. See passing recording constraints. |
applyRecordingOptions(recordingId, options) Promise<Recording> | Apply options to a recording. See passing options. |
cancelRecording(recordingId): Promise<void> | Cancels and deletes a specified recording session. |
clearAllRecordings() | Clears all the active recordings and resets them. |
clearPreview(recordingId): Promise<Recording> | Clears the preview of a specific recording. |
closeCamera(recordingId): Promise<Recording> | Closes the camera of a specified recording session. |
createRecording(videoId?, audioId?): Promise<Recording> | Creates a new recording session with specified video and audio IDs. If none are give the system defaults are used. |
devicesById | Available input devices by their device ID. |
devicesByType | Available input devices based on their type (audio, video). |
download(recordingId): Promise<void> | Downloads the specified recording as a file. |
errorMessage | Returns the last error message, if any, from the hook's operations. |
muteRecording(recordingId): Promise<Recording> | Toggles mute on or off for a specified recording session. |
openCamera(recordingId): Promise<Recording> | Opens the camera for a specified recording session, preparing it for recording. |
pauseRecording(recordingId): Promise<Recording> | Pauses an ongoing recording session. |
resumeRecording(recordingId): Promise<Recording> | Resumes a paused recording session. |
startRecording(recordingId): Promise<Recording> | Starts a new recording for the specified session. |
stopRecording(recordingId): Promise<Recording> | Stops an ongoing recording session and finalizes the recording. |
webcam by iconfield from Noun Project (CC BY 3.0)
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
dependency not pinned by hash detected -- score normalized to 2
Details
Reason
9 existing vulnerabilities detected
Details
Reason
Found 1/24 approved changesets -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
project is not fuzzed
Details
Reason
security policy file not detected
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2025-01-27
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More