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
RecordableSurfaceViewand init the recording stack:
mSurfaceView.setRendererCallbacks(this);
mSurfaceView.doSetup();- Ensure you've called
doSetupand requested (and have been granted!) permissions. - Init the recording itself by creating a
Fileobject for output, and callinginitRecorderon 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
startRecordingwhen looking to capture, andstopRecordingwhen 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
stopRecordingyou will need to re-init by callinginitRecorderagain.
- expose configuration options of media recorder
Apache 2.0