4

Okay I've reviewed Fadden's example of implementing Android MediaMux. I am not sure how to get my scene into the surface input for a MP4 muxed codec. I am working on a audio processor which eats up the audio and video I/O so MediaRecord fails, but the MediaMux sounds like a viable solution.

From the codec create an inputSurface:

videoInputSurface = codec.createInputSurface();

I already have an implemented openGLSurfaceView. I can get the surface from the view simply by calling:

myGLSurface = myGLView.getHolder().getSurface();

but this doesn't set the surface. It just grabs it. Is there an easy way to get myGLSurface to write to videoInputSurface.

To further complicate things I have a cameraPreview being added to same viewgroup, vg, myGLView is written to:

vg.addView(mCameraPreview);

And myGLView is set to transparent so that the openGL scene is overlayed ontop of the cameraPreview.

myGLView.getHolder().setFormat(PixelFormat.TRANSLUCENT);

Is there an easy way to get at the surface element of a vg? To simply put what is being written to the vg frame on the videoInputSurface for the codec?

Thanks,

JasonMArcher
  • 14,195
  • 22
  • 56
  • 52
HPP
  • 1,074
  • 1
  • 13
  • 28
  • 1
    Just to be clear: you want to take frames from the camera, draw on top of them with OpenGL, and send the result to a video encoder? Does this need to appear on-screen as well? (It might help to re-phrase the question in terms of what you're trying to do, rather than describing what you currently have implemented.) – fadden Sep 27 '13 at 04:51
  • 1
    Yes that is correct, take frames from camera, draw on top via OpenGL, and send to video encoder ... and obviously needs to be previewed or displayed. I could write about what I am trying to do, but I am sure that would muck it up more, so sticking to the basics. – HPP Sep 28 '13 at 20:48

1 Answers1

2

Try to look at this. The first example shows how to draw by OpenGL ES commands on codec input surface to record it by MediaMuxer to MP4 file.

  • 1
    Okay so let me see if I have this correct. after I create the codec surface, I use it to create an eglsurface within my openGL stuff, and then simply swap buffers everytime I want what I was drawing to be rendered to the codec? Will this pick up my cameraPreview or will I need to push that to a openGL texture? – HPP Sep 27 '13 at 05:27
  • 1
    When you look at example you can see the _testEncodeVideoToMp4_ function. If you have Open GL renderer, you need execute commands from _onSurfaceCreated_ and _onSurfaceChanged_ before main _for_ loop and commands from onDrawFrame move to _generateSurfaceFrame_ function. – Dmitry Sedukhin Sep 27 '13 at 21:44