1. 爲什麼要用Main Profile & High Profile
在Android上硬編碼視頻碼率遠遠高於軟編碼,原因是Android只支持H264 Baseline。MP(Main Profile )& HP(High Profile)可以大幅減少視頻的碼率。關於H264 Profile參見:H264 Profile。
2. Android平臺對MP & HP的支持情況
2.1 Android
Google聲稱在Android 6.0就已經支持MP,但是6.0的源代碼中還是強制使用Baseline:
if (h264type.eProfile != OMX_VIDEO_AVCProfileBaseline) {
ALOGW("Use baseline profile instead of %d for AVC recording",
h264type.eProfile);
h264type.eProfile = OMX_VIDEO_AVCProfileBaseline;
}
詳情參考:https://my.oschina.net/jerikc/blog/483641
在Android 7.0之後才移除了這段代碼。也就是說要想使用MP要求Android系統版本在7.0及其以上。
關於HP(High Profile)Android文檔中並沒有說明支持這個Profile,但是我們在源代碼中找到了對應的支持,詳情參考:Android MediaCodec參數筆記
在Android 7.0及其之後的系統中已經支持了MP和HP。
2.2 平臺廠商
這裏說的平臺廠商是指芯片提供商,如高通、MTK、華爲、三星等。
筆者測試了幾款機器結果如下: