Class VideoFileRecorder

  • All Implemented Interfaces:
    IVideoRecorder, java.io.Closeable, java.lang.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 Detail

      • VideoFileRecorder

        public VideoFileRecorder()
      • VideoFileRecorder

        protected VideoFileRecorder​(java.lang.String tag)
    • Method Detail

      • recordAudioFromMicrophone

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

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

        @CallSuper
        public void startRecording​(java.io.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
      • close

        public void close()
        Close an instance and free resources
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.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