问题
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.
回答1:
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".)
来源:https://stackoverflow.com/questions/22457683/record-glsurfaceview-on-android-4-3