![require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages](https://cdn.sanity.io/images/cgdhsj6q/production/be8ab80c8efa5907bc341c6fefe9aa20d239d890-1600x1097.png?w=400&fit=max&auto=format)
Security News
require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
videojs-record
Advanced tools
A Video.js plugin for recording audio/video/image files.
Use bower (bower install videojs-record
) or
npm (npm install videojs-record
) to install
the plugin or download and include the dependencies manually.
The plugin has the following mandatory dependency:
When recording audio and/or video you also need:
And when recording audio-only, the following dependencies are also required:
Start by including the video.js stylesheet and library:
<link href="http://cdnjs.cloudflare.com/ajax/libs/video.js/4.12.5/video-js.css" rel="stylesheet">
<script src="http://cdnjs.cloudflare.com/ajax/libs/video.js/4.12.5/video.js"></script>
If you're going to record audio and/or video you need to include RecordRTC as well:
<script src="http://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">
When recording both audio/video, video-only or an image, include a
video
element:
<video id="myVideo" class="video-js vjs-default-skin"></video>
Check out the full audio/video, the image or the video-only examples.
Note that recording both audio and video in a single WebM file is currently only supported in Mozilla Firefox >= 29. On other browsers the resulting file only contains video data.
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.fm/dist/wavesurfer.min.js"></script>
<script src="http://wavesurfer.fm/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.
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:
Option | Type | Default | Description |
---|---|---|---|
image | boolean | false | Create a snapshot image. |
audio | boolean | false | Include audio in the recorded clip. |
video | boolean | false | Include video in the recorded clip. |
maxLength | float | 10 | Maximum length of the recorded clip. |
audioBufferSize | float | 4096 | The size of the audio buffer (in sample-frames per second). Legal values: 256, 512, 1024, 2048, 4096, 8192 and 16384. |
audioSampleRate | float | 22050 | The audio sample rate (in sample-frames per second) at which the AudioContext handles audio. Legal values are in the range of 22050 to 96000. |
debug | boolean | false | Enables console logging for debugging purposes. |
Methods for this plugin:
Method | Description |
---|---|
isRecording | Returns a boolean indicating whether recording is active or not. |
getRecordType | Get recorder type as string, either image_only , audio_only , video_only or audio_video . |
destroy | Destroys the recorder instance and children. |
Plugin events that are available on the video.js player instance:
Event | Description |
---|---|
deviceReady | The webcam or microphone is ready to use. |
deviceError | User doesn't allow the browser to access the webcam and/or microphone. Check player.deviceErrorCode for the specific error code. |
startRecord | User pressed the record or camera button to start recording. |
stopRecord | User pressed the stop button to stop recording. |
finishRecord | The recorded stream or image is available. Check player.recordedData for the Blob data of the recording. |
Listen for the finishRecord
event and obtain the recorded data from the
player.recordedData
attribute 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);
});
To disable and hide specific controls, use the video.js children
option:
children: {
controlBar: {
children: {
// hide fullscreen control
fullscreenToggle: false
}
}
},
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="http://cdnjs.cloudflare.com/ajax/libs/video.js/4.12.5/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!
The Video.js community created
lots of plugins
that can be used to enhance the player's functionality. Plugins actually
tested with videojs-record
:
localStorage
, but falls back to cookies
if necessary.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.
This work is licensed under the MIT License.
0.8.0 - 2015/03/30
MRecordRTC
to enable recording audio/video blobs (in
Firefox >= 29 only at time of this release)FAQs
A video.js plugin for recording audio/video/image files.
We found that videojs-record demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
Security News
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.