我使用MediaCodec对视频流进行编码,我需要设置" csd-0"和" csd-1"如http://imgur.com/DxNOXd9所述:
byte[] sps = { 0, 0, 0, 1, 103, 100, 0, 40, -84, 52, -59, 1, -32, 17, 31, 120, 11, 80, 16, 16, 31, 0, 0, 3, 3, -23, 0, 0, -22, 96, -108 };
byte[] pps = { 0, 0, 0, 1, 104, -18, 60, -128 };
MediaFormat format = MediaFormat.createVideoFormat("video/avc", width, height);
format.setByteBuffer("csd-0", ByteBuffer.wrap(sps));
format.setByteBuffer("csd-1", ByteBuffer.wrap(pps));
...
但我收到了一个错误:
format: {frame-rate=15, height=1280, csd-0=java.nio.ByteArrayBuffer[position=0,limit=31,capacity=31], color-format=2130708361, width=720, bitrate=819200, csd-1=java.nio.ByteArrayBuffer[position=0,limit=8,capacity=8], mime=video/avc, i-frame-interval=3}
E/ACodec ( 2692): [OMX.Exynos.AVC.Encoder] ERROR(0x80001006)
E/MediaCodec( 2692): Codec reported an error. (omx error 0x80001006, internalError -2147483648)
PS: os版本是Android 4.4.2,soc是Exynos5430