Lakshmi Narasimhan
Lakshmi Narasimhan

Reputation: 11

How to switch from camera recording to on screen recording using RecordRTC API?

I am a newbie to Audio/Video Recording. The script works well for my cam and audio recorder. However, I would like to know how to implement it similar to the Extension available so that I can record a tab and all the audio involved. Thanks in advance. Currently using Ver.5.4.0

Upvotes: 1

Views: 1877

Answers (1)

Muaz Khan
Muaz Khan

Reputation: 7236

Here is an open-sourced chrome-extension that supports both tab, screen and any opened app's screen recording:

You can use tabCapture API to capture MediaStream object; now you can record the resulting stream using MediaRecorder API or RecordRTC.

RecordRTC can record following kind of streams:

  1. Stream captured from a webcam or microphone
  2. Stream captured using tabCapture API
  3. Stream captured using desktopCapture API
  4. Stream captured from <canvas> or <video> elements using captureStream API
  5. Streams generated by WebAudio API
e.g.
var capturedStream = videoElement.captureStream();

var recorder = RecordRTC(videoElement.captureStream(), {
   type: 'video'
});

Or:

var recorder = RecordRTC(tabCaptureStream, {
   type: 'video'
});

Simply make sure that you're getting the MediaStream object from above API; and now you can use RecordRTC to record that stream.

Regarding "replacing video track with secondary camera track or screen track", you can use addTrack, removeTrack as well as replaceTrack methods. However I'm not sure if MediaRecorder API can record replaced track:

// using Firefox
theStreamYouAreRecording.replaceTrack( screenTrack );

// using Chrome or Firefox
theStreamYouAreRecording.addTrack ( screenTrack );

So you must either record camera or screen. Do not replace tracks.

Upvotes: 1

Related Questions