Class: RecordRTC

© Muaz Khan . @WebRTCWeb . Github . Latest issues . What's New?

new RecordRTC(mediaStream, config)

JavaScript audio/video recording library runs top over WebRTC getUserMedia API.

RecordRTC is a JavaScript-based media-recording library for modern web-browsers (supporting WebRTC getUserMedia API). It is optimized for different devices and browsers to bring all client-side (pluginfree) recording solutions in single place.
Parameters:
Name Type Description
mediaStream MediaStream MediaStream object fetched using getUserMedia API or generated using captureStreamUntilEnded or WebAudio API.
config object {type:"video", disableLogs: true, numberOfAudioChannels: 1, bufferSize: 0, sampleRate: 0, video: HTMLVideoElement, etc.}
Author:
License:
Source:
See:
Example
var recordRTC = RecordRTC(mediaStream, {
    type: 'video' // audio or video or gif or canvas
});

// or, you can even use keyword "new"
var recordRTC = new RecordRTC(mediaStream[, config]);

Members

blob

It is equivalent to "recordRTC.getBlob()" method.
Properties:
Name Type Description
blob Blob Recorded Blob can be accessed using this property.
Source:
Example
recordRTC.stopRecording(function() {
    var blob = recordRTC.blob;

    // equivalent to: recordRTC.getBlob() method
    var blob = recordRTC.getBlob();
});

buffer

Properties:
Name Type Description
buffer ArrayBuffer Audio ArrayBuffer, supported only in Chrome.
Source:
To Do:
  • Add descriptions.
Example
recordRTC.stopRecording(function() {
    var buffer = recordRTC.buffer;
});

bufferSize

Properties:
Name Type Description
bufferSize number Either audio device's default buffer-size, or your custom value.
Source:
To Do:
  • Add descriptions.
Example
recordRTC.stopRecording(function() {
    var bufferSize = recordRTC.bufferSize;
});

sampleRate

Properties:
Name Type Description
sampleRate number Audio device's default sample rates.
Source:
To Do:
  • Add descriptions.
Example
recordRTC.stopRecording(function() {
    var sampleRate = recordRTC.sampleRate;
});

view

Properties:
Name Type Description
view DataView Audio DataView, supported only in Chrome.
Source:
To Do:
  • Add descriptions.
Example
recordRTC.stopRecording(function() {
    var dataView = recordRTC.view;
});

Methods

(static) getFromDisk(type, callback)

This method can be used to get all recorded blobs from IndexedDB storage.
Parameters:
Name Type Description
type string 'all' or 'audio' or 'video' or 'gif'
callback function Callback function to get all stored blobs.
Source:
Example
RecordRTC.getFromDisk('all', function(dataURL, type){
    if(type === 'audio') { }
    if(type === 'video') { }
    if(type === 'gif')   { }
});

(static) writeToDisk(options)

This method can be used to store recorded blobs into IndexedDB storage.
Parameters:
Name Type Description
options object {audio: Blob, video: Blob, gif: Blob}
Source:
Example
RecordRTC.writeToDisk({
    audio: audioBlob,
    video: videoBlob,
    gif  : gifBlob
});

clearRecordedData()

This method can be used to clear/reset all the recorded data.
Source:
Example
recordRTC.clearRecordedData();

getBlob()

It is equivalent to "recordRTC.blob" property.
Source:
Example
recordRTC.stopRecording(function() {
    var blob = recordRTC.getBlob();

    // equivalent to: recordRTC.blob property
    var blob = recordRTC.blob;
});

getDataURL(callback)

This method returns DataURL. It takes single "callback" argument.
Parameters:
Name Type Description
callback function DataURL is passed back over this callback.
Source:
Example
recordRTC.stopRecording(function() {
    recordRTC.getDataURL(function(dataURL) {
        video.src = dataURL;
    });
});

getFromDisk()

This method gets blob from indexed-DB storage. It takes single "callback" argument.
Source:
Example
recordRTC.getFromDisk(function(dataURL) {
    video.src = dataURL;
});

initRecorder()

This method initializes the recording process.
Source:
Example
recordRTC.initRecorder();

pauseRecording()

This method pauses the recording process.
Source:
Example
recordRTC.pauseRecording();

resumeRecording()

This method resumes the recording process.
Source:
Example
recordRTC.resumeRecording();

save()

This method saves blob/file into disk (by inovking save-as dialog). It takes single (optional) argument i.e. FileName
Source:
Example
recordRTC.stopRecording(function() {
    recordRTC.save('file-name');
});

setAdvertisementArray(arrayOfWebPImages)

This method appends prepends array of webp images to the recorded video-blob. It takes an "array" object.
Parameters:
Name Type Description
arrayOfWebPImages Array Array of webp images.
Source:
Example
var arrayOfWebPImages = [];
arrayOfWebPImages.push({
    duration: index,
    image: 'data:image/webp;base64,...'
});
recordRTC.setAdvertisementArray(arrayOfWebPImages);

setRecordingDuration()

This method initializes the recording process.
Source:
Example
recordRTC.initRecorder();

startRecording()

This method starts recording. It doesn't take any argument.
Source:
Example
recordRTC.startRecording();

stopRecording(callback)

This method stops recording. It takes single "callback" argument. It is suggested to get blob or URI in the callback to make sure all encoders finished their jobs.
Parameters:
Name Type Description
callback function This callback function is invoked after completion of all encoding jobs.
Source:
Example
recordRTC.stopRecording(function(videoURL) {
    video.src = videoURL;
    recordRTC.blob; recordRTC.buffer;
});

toURL()

This method returns Virutal/Blob URL. It doesn't take any argument.
Source:
Example
recordRTC.stopRecording(function() {
    video.src = recordRTC.toURL();
});

Help Improve Documentation

Enter your email too; if you want "direct" reply!