Does anyone know which audio/video encoders does MediaRecorder
use?
I know we can choose the audio / video mimeTypes with mediaRecorder.setVideoEncoder()
and mediaRecorder.setAudioEncoder()
:
mediaRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.H264);
But this won't tell me which encoder implementation is being used, as each device can have multple encoders for H264 (for example, a hardware accelerated one and a software one like OMX.google.h264.encoder
).
Is there a way to know this?
Can anyone link to native source code where we can discover this?
When using low-level MediaCodec
, we can access all encoders through MediaCodecList
, get their name and capabilities, and finally instantiate the correct MediaCodec
. I'm sure that MediaRecorder
is doing the same in native code, I just can't find any source code reference. Thanks!
The answers I would expect are...
MediaCodec.createEncoderByType(type)
MediaRecoders native implementation is StagefrightRecorder.cpp.
In method setupVideoEncoder, line #1782 you can see it is using MediaCodecSource::Create
with a format that has 'video/avc' as 'mime' (Line #1660).
In MediaCodecSource.cpp in method initEncoder in line #515 the best suited encoder is selected.
How the Codec gets selected can be found here
I hope this helps navigating through androids native media impementations.