New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

videojs-record

Package Overview
Dependencies
Maintainers
1
Versions
78
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

videojs-record

A video.js plugin for recording audio/video/image files.

  • 0.9.2
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Video.js Record

A Video.js plugin for recording audio/video/image files.

Screenshot

npm version npm License Build Status

Installation

Use bower (bower install videojs-record) or npm (npm install videojs-record) to install the plugin or download the library and dependencies elsewhere.

Note about video.js v5.0: this plugin is currently only compatible with video.js v.4.x releases (for example 4.12.15).

Dependencies

The plugin has the following mandatory dependency:

  • Video.js - HTML5 media player that provides the user interface.

When recording audio and/or video you also need:

And when recording audio-only, the following dependencies are also required:

Optional dependencies for other output formats:

  • libvorbis.js - Converts PCM audio data to compressed Ogg Vorbis audio, resulting a smaller audio files with similar quality.

Usage

Start by including the video.js stylesheet and library:

<link href="//vjs.zencdn.net/4.12.15/video-js.css" rel="stylesheet">
<script src="//vjs.zencdn.net/4.12.15/video.js"></script>

If you're going to record audio and/or video you need to include RecordRTC as well:

<script src="//cdn.webrtc-experiment.com/RecordRTC.js"></script>

The videojs-record plugin automatically registers itself when the script is included on the page:

<script src="videojs.record.js"></script>

Add the extra stylesheet for the plugin that includes a custom font with additional icons:

<link href="videojs.record.css" rel="stylesheet">

Audio/video/image

When recording either audio/video, video-only, animated GIF or a single image, include a video element:

<video id="myVideo" class="video-js vjs-default-skin"></video>

Check out the full audio/video (demo / source), image (demo / source), animated GIF (demo / source) or the video-only (demo or source) examples.

Note that recording both audio and video into a single WebM file is currently only supported in Mozilla Firefox >= 29. In the Chrome browser two separate Blob objects are created: one for audio and one for video.

Audio-only

Audio-only screenshot

When recording audio-only, also include the wavesurfer.js library and the videojs-wavesurfer and microphone plugins. Make sure to place this before the videojs.record.js script.

<script src="http://wavesurfer-js.org/dist/wavesurfer.min.js"></script>
<script src="http://wavesurfer-js.org/dist/plugin/wavesurfer.microphone.min.js"></script>
<script src="videojs.wavesurfer.js"></script>

And define an audio element:

<audio id="myAudio" class="video-js vjs-default-skin"></audio>

Check out the full audio-only example (demo / source).

Options

Configure the player using the video.js options, and enable the plugin by adding a record configuration to plugins. For example:

var player = videojs("myVideo",
{
    controls: true,
    loop: false,
    width: 320,
    height: 240,
    plugins: {
        record: {
            image: false,
            audio: false,
            video: true,
            maxLength: 5
        }
    }
});

The available options for this plugin are:

OptionTypeDefaultDescription
imagebooleanfalseCreate single snapshot image.
audiobooleanfalseInclude audio in the recorded clip.
videobooleanfalseInclude video in the recorded clip.
animationbooleanfalseAnimated GIF.
maxLengthfloat10Maximum length of the recorded clip.
audioEnginestringrecordrtcAudio recording library to use. Legal values are recordrtc and libvorbis.js.
audioBufferSizefloat4096The size of the audio buffer (in sample-frames per second). Legal values: 0, 256, 512, 1024, 2048, 4096, 8192 and 16384.
audioSampleRatefloat44100The audio sample rate (in sample-frames per second) at which the AudioContext handles audio. Legal values are in the range of 22050 to 96000.
audioWorkerURLstring''URL for the audio worker, for example: libvorbis.oggvbr.asyncencoder.worker.min.js. Currently only used for libvorbis.js.
audioModuleURLstring''URL for the audio module, for example: libvorbis.asmjs.min.js. Currently only used for libvorbis.js.
animationFrameRatefloat200Frame rate for animated GIF (in frames per second).
animationQualityfloat10Sets quality of color quantization (conversion of images to the maximum 256 colors allowed by the GIF specification). Lower values (minimum = 1) produce better colors, but slow processing significantly. The default produces good color mapping at reasonable speeds. Values greater than 20 do not yield significant improvements in speed.
debugbooleanfalseEnables console log messages.

Methods

Methods for this plugin documented below are available on the recorder object of the video.js player instance. For example:

player.recorder.destroy();
MethodDescription
isRecordingReturns a boolean indicating whether recording is active or not.
getRecordTypeGet recorder type as string. Either image_only, animation, audio_only, video_only or audio_video.
destroyDestroys the recorder instance and children (including the video.js player).
stopDeviceStop the recording and the active audio and/or video device(s).
getDeviceStart the audio and/or video device(s).

Events

Plugin events that are available on the video.js player instance. For example:

player.on('startRecord', function()
{
    console.log('started recording!');
});
EventDescription
deviceReadyThe webcam and/or microphone is ready to use.
deviceErrorUser doesn't allow the browser to access the webcam and/or microphone. Check player.deviceErrorCode for the specific error code.
startRecordUser pressed the record or camera button to start recording.
stopRecordUser pressed the stop button to stop recording.
finishRecordThe recorded stream or image is available. Check the player.recordedData object for the recorded data.

Get recorded data

Listen for the finishRecord event and obtain the recorded data from the player.recordedData object for further processing:

// user completed recording and stream is available
player.on('finishRecord', function()
{
    // the recordedData object contains the stream data that
    // can be downloaded by the user, stored on server etc.
    console.log('finished recording: ', player.recordedData);
});

Note that in the Chrome browser player.recordedData returns an object with audio and video properties when recording both audio/video. In Firefox it returns a single WebM Blob object containing both audio and video.

Customizing controls

To disable and hide specific controls, use the video.js children option:

children: {
    controlBar: {
        children: {
            // hide fullscreen control
            fullscreenToggle: false
        }
    }
},

Other output formats

Microphone recordings can result in large audio files, especially when there is no native support for other audio formats (.ogg for example) in the browser (like Chrome). libvorbis.js provides a Javascript implementation of a PCM to Ogg Vorbis encoder and you can choose to use this instead of RecordRTC (currently only available when recording audio-only).

Include the libvorbis.js library (instead of RecordRTC.js) and place it before any other scripts:

<script src="/path/to/libvorbis.oggvbr.asyncencoder.min.js" async></script>

And specify the libvorbis.js audioEngine, audioWorkerURL and audioModuleURL options.

Check out the audio-only Ogg example (demo / source).

Localization

This plugin supports multiple languages. Each language has it's own file (found in the lang directory) that contains the translated text.

Using a different language, for example Dutch (nl), is done by including the Video.js language file and the plugin's language file:

<script src="videojs-record/dist/lang/nl.js"></script>
<script src="//vjs.zencdn.net/4.12.15/lang/nl.js"></script>

And setting the Video.js player's language option:

language: "nl"

Adding support for an additional language is done by adding a new file with a filename that consists of the countrycode and the .json extension, eg. fr.json. The build script compiles the JSON into a usable language file, eg. fr.js. Check the Video.js wiki for a list of supported countrycodes. Pull requests to add more languages to this plugin are always welcome!

More features using other plugins

The Video.js community created lots of plugins that can be used to enhance the player's functionality. Plugins actually tested with videojs-record:

  • videojs-persistvolume - Saves user's volume setting using localStorage, but falls back to cookies if necessary.

Development

Install grunt-cli:

sudo npm install -g grunt-cli

Install dependencies using npm:

npm install

Or using bower:

bower install

Build a minified version:

grunt

Generated files are placed in the dist directory.

License

This work is licensed under the MIT License.

Keywords

FAQs

Package last updated on 06 Oct 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc