0

I'm developing an app for applying effects to the camera image in real-time. Currently I'm using the MediaMuxer class in combination with MediaCodec. Those classes were implemented with Android 4.3. Now I wanted to redesign my app and make it compatible for more devices. The only thing I found in the internet was a combination of FFmpeg and OpenCV, but I read that the framerate is not very well if I want to use a high resolution. Is there any possibility to encode video in real-time while capturing the camera image without using MediaMuxer and MediaCodec?

PS: I'm using GLSurfaceView for OpenGL fragment shader effects. So this is a must-have.

genpfault
  • 51,148
  • 11
  • 85
  • 139
chris6523
  • 530
  • 2
  • 8
  • 18

1 Answers1

0

Real-time encoding of large frames at a moderate frame rate is not going to happen with software codecs.

MediaCodec was introduced in 4.1, so you can still take advantage of hardware-accelerated compression so long as you can deal with the various problems. You'd still need an alternative to MediaMuxer if you want a .mp4 file at the end.

Some commercial game recorders, such as Kamcord and Everyplay, claim to work on Android 4.1+. So it's technically possible, though I don't know if they used non-public APIs to feed surfaces directly into the video encoder.

In pre-Jellybean Android it only gets harder.

(For anyone interested in recording GL in >= 4.3, see EncodeAndMuxTest or Grafika's "Record GL app".)

fadden
  • 51,356
  • 5
  • 116
  • 166
  • The ">= 4.3" example was for other people who find the question by searching. For you, the solution -- and whether or not there is one -- depends on what API level you're targeting, whether or not you want to use the NDK, and how willing you are to use non-public APIs. There is an existence proof that the problem can be solved on API 4.1 for some (perhaps not all) devices. You will probably need to use `SurfaceMediaSource.cpp` / `GraphicBufferSource.cpp` as your starting point. – fadden Mar 18 '14 at 14:47
  • I want to support at least Android 4.0 – chris6523 Mar 18 '14 at 15:59