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.
- Add RecordableSurfaceview to your project
implementation 'com.uncorkedstudios.android:recordable-surfaceview:1.5.7'
- 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"/>
- in your main GL Activity or top-level renderer, implement
public class SomeActivity extends Activity implements RecordableSurfaceView.RendererCallbacks
- Set the callbacks on the
RecordableSurfaceView
and init the recording stack:
mSurfaceView.setRendererCallbacks(this);
mSurfaceView.doSetup();
- Ensure you've called
doSetup
and requested (and have been granted!) permissions. - Init the recording itself by creating a
File
object for output, and callinginitRecorder
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, andstopRecording
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 callinginitRecorder
again.
- expose configuration options of media recorder
Apache 2.0