TextureMovieEncoder

Encode a movie from frames rendered from an external texture image.

The object wraps an encoder running on a dedicated thread. The various control messages may be sent from arbitrary threads (typically the app UI thread). The encoder thread manages both sides of the encoder (feeding and draining); the only external input is the GL texture.

The design is complicated slightly by the need to create an EGL context that shares state with a view that gets restarted if (say) the device orientation changes. When the view in question is a GLSurfaceView, we don't have full control over the EGL context creation on that side, so we have to bend a bit backwards here.

To use:

  • create TextureMovieEncoder object
  • create an EncoderConfig
  • call TextureMovieEncoder#startRecording() with the config
  • call TextureMovieEncoder#setTextureId() with the texture object that receives frames
  • for each frame, after latching it with SurfaceTexture#updateTexImage(), call TextureMovieEncoder#frameAvailable().
TODO: tweak the API (esp. textureId) so it's less awkward for simple use cases.

Constructors

Link copied to clipboard
constructor()

Types

Link copied to clipboard
open class EncoderConfig
Encoder configuration.
Link copied to clipboard

Functions

Link copied to clipboard
Tells the video recorder that a new frame is available.
Link copied to clipboard
open fun isRecording(): Boolean
Returns true if recording has been started.
Link copied to clipboard
open fun run()
Encoder thread entry point.
Link copied to clipboard
open fun setTextureId(id: Int)
Tells the video recorder what texture name to use.
Link copied to clipboard
Tells the video recorder to start recording.
Link copied to clipboard
open fun stopRecording()
Tells the video recorder to stop recording.
Link copied to clipboard
open fun updateSharedContext(sharedContext: EGLContext)
Tells the video recorder to refresh its EGL surface.