Skip to content

A drop-in replacement for GLSurfaceView that can be used to record to an mp4 movie.

License

Notifications You must be signed in to change notification settings

spaceLenny/recordablesurfaceview

Repository files navigation

RecordableSurfaceView

RecordableSurfaceView is a lightweight library designed to record an Android OpenGL renderer and output an MP4 with minimal configuration or refactoring..

Features:

  • Functionally a drop-in replacement for GLSurfaceView
  • Full lifecycle callbacks in a View tree.
  • Minimal effort to implement.

How to get set up

  1. Add RecordableSurfaceview to your project
implementation 'com.uncorkedstudios.android:recordable-surfaceview:1.5.7'
  1. Add the following permissions to your Manifest (and request them!)
<uses-permission android:name="android.permission.RECORD_AUDIO"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
  1. in your main GL Activity or top-level renderer, implement
public class SomeActivity extends Activity implements RecordableSurfaceView.RendererCallbacks
  1. Set the callbacks on the RecordableSurfaceView and init the recording stack:
mSurfaceView.setRendererCallbacks(this);
mSurfaceView.doSetup();

How to record:

  • Ensure you've called doSetup and requested (and have been granted!) permissions.
  • Init the recording itself by creating a File object for output, and calling initRecorder on the surface. You will also need to supply the dimensions of the output movie file, and optionally implement the callbacks provided by the MediaRecorder
  • Call startRecording when looking to capture, and stopRecording when done.
  • NOTE the underlying MediaRecorder still abides by the lifecycle state machine as defined by the MediaRecorder in Android. In order to record again aftering calling stopRecording you will need to re-init by calling initRecorder again.

See also:

MediaRecorder

MediaRecorder.OnErrorListener

MediaRecorder.OnInfoListener

TODO:

  • expose configuration options of media recorder

License

Apache 2.0

About

A drop-in replacement for GLSurfaceView that can be used to record to an mp4 movie.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages