58

How to use a "custom" video capturer to create a VideoTrack and provide frames?

The classic approach to create a VideoTrack is:

1 - Get a VideoCapturer instance

VideoCapturer capturer = VideoCapturer.create(name);

2 - Create a VideoSource

VideoSource videoSource = peerconnectionFactory.createVideoSource(capturer, videoConstraints);

3 - Create a VideoTrack using the video source

VideoTrack videoTrack = peerconnectionFactory.createVideoTrack("Label", videoSource);

4 - Add the track to the MediaStream


I was wondering if there is a way to change step one. Instead of using the native Capturer instance, use an Android one, and provide the frames to the VideoTrack using the callback:

public void onPreviewFrame(byte[] data, Camera camera) {
   // provide the frames to the VideoTrack
}

Any suggestions?

10
  • Don't know what you want to achieve.Actually it is not native capturer. It is using android camera class to capture and frame is passes to native lib.May be the code you are using is inside the jar. Commented Aug 1, 2014 at 5:27
  • There is a class VideoCaptureAndroid.java in jar file from where the frames are capture and passes to native liberary. Commented Aug 1, 2014 at 5:29
  • @BirajZalavadia, yes I saw it, but as soon as I remember it all the "important" method were private so it looked like it had to be implemented
    – Manza
    Commented Aug 1, 2014 at 10:38
  • 2
    Mainly I want to be able to modify, edit or adding manually frames to the video track, and eventually provides frame for an external video source (e.g webcam)
    – Manza
    Commented Aug 1, 2014 at 10:48
  • 1
    @Manza Did you find a way to do this?
    – Andro
    Commented Jun 14, 2017 at 18:27

1 Answer 1

2

The easiest way (although a bit "hacky") to do this is to copy the source of RTCVideoCapturer to a local class withing your project and just use that local class. You can now edit the class to suit your needs. Even when not copying the file but actually building your own, it's probably better to copy large parts of the existing capturer than to reinvent the wheel.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.