npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

rippleberry-camera-recorder

v1.0.4

Published

RippleBerry video recorder - simple camera recorder to record video with ease

Downloads

241

Readme

Rippleberry Camera Recorder

rippleberry-camera-recorder is a powerful and easy-to-use JavaScript library for recording audio and video from user media devices. It provides a simple API for managing media streams, recording, and exporting blobs with various encoding options.

Features

  • Cross-Browser Support: Compatible with modern browsers.
  • Flexible Configuration: Customize audio and video settings.
  • Easy Integration: Quick setup for recording media.
  • Blob Fixing: Automatically fixes WebM blob duration.
  • Device Management: Retrieve available media devices.
  • Status Tracking: Access the current status of the recorder (idle, previewing, recording).

Installation

You can install the package via npm:

npm install rippleberry-camera-recorder

Usage

Basic Setup

To get started, import the library and create an instance of the RBCameraRecorder class:

import RBCameraRecorder from "rippleberry-camera-recorder"

// Creating a recorder instance with default options
const recorder = new RBCameraRecorder()

Configuration Options

You can customize the recorder by providing options in the constructor. All options are optional.

const recorder = new RBCameraRecorder({
  mimeType: "video/webm; codecs=vp8, opus", // Optional: Specify your desired mime type
  audio: {
    deviceId: "your-audio-device-id", // Optional: Specify audio device ID
  },
  video: {
    deviceId: "your-video-device-id", // Optional: Specify video device ID
    width: 1280, // Optional: Set video width
    height: 720, // Optional: Set video height
    frameRate: 30, // Optional: Set video frame rate
  },
  audioBitsPerSecond: 128000, // Optional: Set audio bit rate
  videoBitsPerSecond: 2500000, // Optional: Set video bit rate
})

Accessing Status

You can access the current status of the recorder using the status property, which can be one of the following values: idle, previewing, or recording.

console.log("Current status:", recorder.status) // Outputs the current status

Recording Media

  1. Preview the Media: Start by accessing the user's media devices and displaying a preview.

    try {
      const stream = await recorder.preview()
      console.log("Preview started:", stream)
    } catch (error) {
      console.error("Error during preview:", JSON.parse(error))
    }
  2. Start Recording: To start recording the media stream, call the start method.

    try {
      const stream = await recorder.start()
      console.log("Recording started:", stream)
    } catch (error) {
      console.error("Error starting recording:", JSON.parse(error))
    }
  3. Stop Recording: Once you're done recording, stop the media recorder.

    try {
      const blob = await recorder.stop()
      console.log("Recording stopped. Blob:", blob)
    } catch (error) {
      console.error("Error stopping recording:", JSON.parse(error))
    }

Getting Connected Devices

You can retrieve the list of available audio and video devices:

try {
  const devices = await recorder.getConnectedDevices()
  console.log("Connected devices:", devices)
} catch (error) {
  console.error("Error fetching devices:", JSON.parse(error))
}

Additional Methods

  • getSupportedVideosOptions(): Retrieve a list of supported video options.
  • getSupportedAudiosOptions(): Retrieve a list of supported audio options.

Notes

  • Ensure that your application has permissions to access the camera and microphone.
  • Test the library in various browsers to confirm compatibility and performance.

Example

Here’s a complete example demonstrating how to use the rippleberry-camera-recorder:

import RBCameraRecorder from "rippleberry-camera-recorder"

const recorder = new RBCameraRecorder({
  mimeType: "video/webm; codecs=vp8, opus", // Optional configuration
})

async function startRecording() {
  try {
    await recorder.preview()
    console.log("Current status:", recorder.status) // Check status after preview
    const stream = await recorder.start()
    console.log("Recording started:", stream)
    console.log("Current status:", recorder.status) // Check status after starting recording

    // Stop recording after 10 seconds
    setTimeout(async () => {
      const blob = await recorder.stop()
      console.log("Recording stopped. Blob:", blob)
      console.log("Current status:", recorder.status) // Check status after stopping
    }, 10000)
  } catch (error) {
    console.error("An error occurred:", JSON.parse(error))
  }
}

startRecording()

License

This project is licensed under the MIT License - see the LICENSE file for details.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request or report issues.

Contact

For any inquiries or support, please contact [[email protected]].