Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Record video and audio from a GLSurfaceView and export it to .mp4

I am a newbie in OpenGL. I want to record video and audio from a GLSurfaceView and export it to .mp4 (or other formats). I have a GlsurfaceView that implement Renderer

I've tried using fadden examples's in bigflake.com like EncodeAndMuxTest.java ,or RecordFBOActivity.java in google/grafika but without success because I don't know how to implement it.

Is there any example or "How-to" for recording a GLSurfaceView?

like image 912
leon Avatar asked Feb 27 '15 11:02

leon


2 Answers

You can try to use INDE Media for Mobile: https://software.intel.com/en-us/articles/intel-inde-media-pack-for-android-tutorials GLCapturer class, it allows to make opengl capturing in a few lines of code, samples are here:

https://github.com/INDExOS/media-for-mobile/blob/master/samples/src/main/java/org/m4m/samples/GameRenderer.java

synchronized (videoCapture) {
    if (videoCapture.beginCaptureFrame()) {
        ...

        renderScene();

        videoCapture.endCaptureFrame();
    }
}

enter image description here

like image 175
Marlon Avatar answered Oct 18 '22 01:10

Marlon


You can give the Android Breakout patch a try. It adds game recording to Android Breakout.

The main difference when working with GLSurfaceView, rather than SurfaceView, is that GLSurfaceView wants to manage its own EGL context. This requires you to create a second context that shares data with GLSurfaceView's context. It's a bit awkward to manage, but is doable.

You may want to consider switching from GLSurfaceView to SurfaceView. This requires you to do your own EGL setup and thread handling, but you can find examples of both in Grafika. It's a bit more work to get things set up, but it makes fancy stuff like video recording easier. Of course, if you're using a game or graphics engine that requires GLSurfaceView, that won't be an option.

like image 31
fadden Avatar answered Oct 18 '22 01:10

fadden