Class VideoFileRecorder

java.lang.Object
com.banuba.sdk.player.VerifyCloseable
com.banuba.sdk.video.VideoFileRecorder
All Implemented Interfaces:
IVideoRecorder, Closeable, AutoCloseable
Direct Known Subclasses:
VideoOutput

public class VideoFileRecorder extends VerifyCloseable implements IVideoRecorder
Render video to the offscreen surface and save it to a video file
  • Constructor Details

    • VideoFileRecorder

      public VideoFileRecorder()
    • VideoFileRecorder

      protected VideoFileRecorder(String tag)
  • Method Details

    • recordAudioFromMicrophone

      public void recordAudioFromMicrophone(boolean recordAudio)
      Capture audio from microphone
      Parameters:
      recordAudio - do the capture flag
    • setRecordingStateChangedListener

      protected void setRecordingStateChangedListener(VideoFileRecorder.IRecordingStateChangedListener listener)
      Set a callback to change the state of a record
      Parameters:
      listener - callback
    • startRecording

      @CallSuper public void startRecording(File outputFile)
      Start recording to video file
      Specified by:
      startRecording in interface IVideoRecorder
      Parameters:
      outputFile - the output filename
    • startRecording

      @CallSuper public void startRecording(File outputFile, IAudioDataProvider audioDataProvider)
      Start recording to video file
      Specified by:
      startRecording in interface IVideoRecorder
      Parameters:
      outputFile - the output filename
      audioDataProvider - callback with audio data
    • pauseRecording

      @CallSuper public void pauseRecording()
      Check state and pause recording
      Specified by:
      pauseRecording in interface IVideoRecorder
    • resumeRecording

      @CallSuper public void resumeRecording()
      Check state and resume recording
      Specified by:
      resumeRecording in interface IVideoRecorder
    • stopRecording

      @CallSuper public void stopRecording()
      Stop recording. After call this method the file will be automatically saved to the path specified at the start of recording. File will be saved in another thread. To wait for a video file to be written, use the stopRecordingAndWaitForFinish() method.
      Specified by:
      stopRecording in interface IVideoRecorder
    • stopRecordingAndWaitForFinish

      @CallSuper public void stopRecordingAndWaitForFinish()
      Stops recording if recording was started and waits for the end of the video writing.
      Specified by:
      stopRecordingAndWaitForFinish in interface IVideoRecorder
      See Also:
    • getRecordingState

      public RecordingState getRecordingState()
      Get current state of recording
      Specified by:
      getRecordingState in interface IVideoRecorder
      Returns:
      recording state
    • close

      public void close()
      Close an instance and free resources
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Overrides:
      close in class VerifyCloseable
    • initializeMuxerAndSurface

      protected void initializeMuxerAndSurface(@NonNull EglCore eglCore, android.util.Size frameSize)
      Must be called after calling startRecording(...) method and before frameAvailable(...). Initializes writing to a file.
      Parameters:
      eglCore - opengl context
      frameSize - output video file resolution
    • getRenderingSurface

      protected WindowSurface getRenderingSurface()
      Returns the surface for drawing the frame
    • frameAvailable

      protected void frameAvailable(long frameTimeNanos)
      Captures the next frame and writes it to a file
      Parameters:
      frameTimeNanos - frame time in nanoseconds