【Android】[轉] Android Codec默認profile使用的是Baseline


關於Android默認Codec使用的Profile找了半天沒發現,還是Google的時候發現了開源中國有網友寫的這邊博客,相關的內容很少,便貼了過來做個筆記。

以下內容轉自Android MediaCodec 設置 MediaFormat.KEY_PROFILE 問題

我在設置 MediaCodec profile 的時候,一直沒有成功,看了源碼之后才發現問題之所在:

https://android.googlesource.com/platform/frameworks/av/+/437ced8a14944bf5450df50c5e7e7a6dfe20ea40/media/libstagefright/ACodec.cpp

img

設置了 profile 之后,你還要設置一個 Level 屬性,但是目前最新的 SDK 里面並沒有提供這個 Key。

即使你手動的設置 level ,比如像這樣:

MediaCodec codec = createEncoderByType(MediaFormat.MIMETYPE_VIDEO_AVC);
MediaFormat format = = MediaFormat.createVideoFormat(MediaFormat.MIMETYPE_VIDEO_AVC, 1920, 1080);
format.setInteger(MediaFormat.KEY_PROFILE, MediaCodecInfo.CodecProfileLevel.AVCProfileHigh);
format.setInteger("level", Level_xxx);

codec.configure(format, null, null, MediaCodec.CONFIGURE_FLAG_ENCODE);

還是不行的,因為 Android 強制將 profile 設置為 Baseline 了。

// XXX
    if (h264type.eProfile != OMX_VIDEO_AVCProfileBaseline) {
        ALOGW("Use baseline profile instead of %d for AVC recording",
            h264type.eProfile);
        h264type.eProfile = OMX_VIDEO_AVCProfileBaseline;
    }

總之,Android 在使用 MediaCodec 進行 encode 的時候,只能使用 Baseline 的 profile。

Google 之后,發現也有其他的朋友發現了類似的問題,

https://code.google.com/p/android/issues/detail?id=163580

看來這個問題確實存在,不過不清楚為什么 Android 要強制使用 Baseline 的 profile。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2026 CODEPRJ.COM