I am trying to build an video recording system on Android 4.2.2
, I've done the encoding part, which is using OMX
. Now I am working on the Muxer part, since the code stream of the video can be a little different if I use FFMpeg
, so I wish to use the exact same Muxer tool of the original system.
So I want to extract the Muxer part of StagefrightRecorder
, compile it into a .so file, and then call it via JNI
in my application. But there are a lot of stuffs in StagefrightRecorder
, I am confused.
Can this way work? Can I just extract the code relevant to MPEG4Writer? Can anyone give me any instructions? Thanks!
If you are compiling within the context of the framework, you could simply include the relevant header files and create the MPEG4Writer
object directly. A very good example for this is the command line utility recordVideo
as can be observed from this file.
If you wish to write a separate application, then you need to link with libstagefright.so
and include the relevant header files and their path.
Note: If you wish to work with the standard MPEG4Writer
, it's source i.e. source of the MPEG4Writer
which would be an encoder should be modeled as a MediaSource
. The writer pulls the metadata
and actual bitstream through the read
method and hence, it is recommended to employ a standard built-in object such as OMXCodec
or ACodec
for the encoder.