-1

I'm trying to create a screen capturer app for android. I already have the webRTC portion setup with a video capturer using Camera2Enumerator library from here. How can I modify this to create a pre-recorded video capturer instead of camera capturer.

Thanks!

snigdha v
  • 1
  • 3

1 Answers1

0

Just wanted to give an update that I have solved this. I'm unable to share the entire code but here's a process that might help:

  1. Acquire one frame of your pre-recorded file and store in a byte array(must be in YUV format)

  2. Replace the VideoCapturer() with the following:

    fun onGetFrame(p0: ByteArray?) {
    
        var timestampNS = java.util.concurrent.TimeUnit.MILLISECONDS.toNanos(SystemClock.elapsedRealtime())
    
        var buffer:NV21Buffer = NV21Buffer(p0,288,352,null)
    
        var videoFrame:VideoFrame = VideoFrame(buffer,0,timestampNS)
    
        localVideoSource.capturerObserver.onFrameCaptured(videoFrame)
    
        videoFrame.release()
    
    }
    

    where p0 is the byte array with the frame

  3. Call this function in startLocalVideoCapture() using a timer (every few milliseconds...I used 10 nanoseconds) https://developer.android.com/reference/android/os/CountDownTimer

  4. remove this line in startLocalVideoCapture()--->

    VideoCapturer.initialize(
                surfaceTextureHelper,
                localVideoOutput.context,
                localVideoSource.capturerObserver)
    
Dharman
  • 30,962
  • 25
  • 85
  • 135
snigdha v
  • 1
  • 3