I use the MediaCodec to encode video stream and i need to set the "csd-0" and "csd-1" as following according to here:
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)); ... But i got an error:
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: The os version is Android 4.4.2 and soc is Exynos5430