I set MEDIACODEC profile, has not been successful, read the source after the problem is found:
https://android.googlesource.com/platform/frameworks/av/+/437ced8a14944bf5450df50c5e7e7a6dfe20ea40/media/ Libstagefright/acodec.cpp
After you set up profile, you also set a Level property, but the current SDK does not provide this Key.
Even if you manually set the level, like this:
Mediacodec codec = Createencoderbytype (MEDIAFORMAT.MIMETYPE_VIDEO_AVC); Mediaformat format = = Mediaformat.createvideoformat (MEDIAFORMAT.MIMETYPE_VIDEO_AVC, 1920x1080); Format.setinteger ( Mediaformat.key_profile, MediaCodecInfo.CodecProfileLevel.AVCProfileHigh); Format.setinteger ("level", level_xxx); Codec.configure (format, NULL, NULL, MEDIACODEC.CONFIGURE_FLAG_ENCODE);
It's still not working, because Android forces profile to be set to Baseline.
XXX if (h264type.eprofile! = omx_video_avcprofilebaseline) { ALOGW ("Use baseline profiles instead of%d for AVC Recording ", H264type.eprofile); H264type.eprofile = Omx_video_avcprofilebaseline; }
In short, Android can only use Baseline profile when using mediacodc for encode.
Google, found that other friends have found similar problems,
https://code.google.com/p/android/issues/detail?id=163580
It seems that this problem does exist, but it is unclear why Android is forcing the use of Baseline profile.
Android Mediacodec Setting Mediaformat.key_profile issues