Open DVRM opened 9 years ago
I'm sending the packerts from example1 over rtsp and trying to decode them with the media codec, but without succesful. Is it possible that the problem is that the libsreaming sending the h264 stream with no headers??
here is the decoding:
private void decodeVideo() {
new Thread(new Runnable() { @Override public void run() { int n = 0; MediaFormat mediaFormat = new MediaFormat(); mediaFormat.setString(MediaFormat.KEY_MIME, "video/avc"); mediaFormat.setInteger(MediaFormat.KEY_MAX_INPUT_SIZE,100000); mediaFormat.setInteger(MediaFormat.KEY_WIDTH, surfaceView.getWidth()); mediaFormat.setInteger(MediaFormat.KEY_HEIGHT, surfaceView.getHeight()); mediaFormat.setInteger( MediaFormat.KEY_PUSH_BLANK_BUFFERS_ON_STOP, 1); mediaFormat.setInteger(MediaFormat.KEY_COLOR_FORMAT, MediaCodecInfo.CodecCapabilities.COLOR_FormatL2); byte[] csd_info = { 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, 0, 0, 0, 1, 104, -18, 60, -128 }; mediaFormat.setByteBuffer("csd-0", ByteBuffer.wrap(csd_info)); mediaFormat.setInteger(MediaFormat.KEY_MAX_INPUT_SIZE, 1920 * 1080); mediaFormat.setInteger("durationUs", 63446722); MediaCodec codec = MediaCodec.createDecoderByType("video/avc"); /* mediaFormat.setByteBuffer("csd-0", csd0); */ codec.configure(mediaFormat, mHolder.getSurface(), null, 0); codec.start(); ByteBuffer[] inputBuffers = codec.getInputBuffers(); ByteBuffer[] outputBuffers = codec.getOutputBuffers(); BufferInfo info = new BufferInfo(); while (flag) { int inputBufferIndex = codec.dequeueInputBuffer(-1); if (inputBufferIndex >= 0) { while (mPackets.size() <= 0) { try { Log.d(TAG, "nopackets"); Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } } Log.d(TAG, "now I have packets!"); inputBuffers[inputBufferIndex].clear(); DatagramPacket currentDatagram = mPackets.remove(); byte[] byteBuffer = (ByteBuffer.wrap(currentDatagram .getData())).array(); inputBuffers[inputBufferIndex].put(byteBuffer, 0, byteBuffer.length); codec.queueInputBuffer(inputBufferIndex, 0, byteBuffer.length, timestamp(), 0); } int outputBufferIndex = codec.dequeueOutputBuffer(info, -1); .......
// for the last line in the above code I always get outputBufferIndex = -1 that means : INFO_TRY_AGAIN_LATER
please if you could help me and correct me what I'm doing wrong I really appreciate it.
thank you for giving your time.
I'm sending the packerts from example1 over rtsp and trying to decode them with the media codec, but without succesful. Is it possible that the problem is that the libsreaming sending the h264 stream with no headers??
here is the decoding:
private void decodeVideo() {
// for the last line in the above code I always get outputBufferIndex = -1 that means : INFO_TRY_AGAIN_LATER
please if you could help me and correct me what I'm doing wrong I really appreciate it.
thank you for giving your time.