Hi i have android project that i have to receive audio and video from server via socket, the audio part run perfect. but the video part is not working i do not know what the reason because the decoder did not show any error when decoding video packets . the video codec that i use is H.264/AVC from ffmepeg encoder with the following settings :-
tune = zerolatency
profile = baseline
level = 3
Width = 320
Height = 240
frameRate = 30
GOPSize = 30
i found that i have to add CSD-0 and CSD-1 to MediaCodec config but i do not know how to add H.264 SPS/PPS data to the configurations
this is code i was found , but it's not wokring with me ,
byte[] header_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[] header_pps = { 0, 0, 0, 1, 104, -18, 60, -128 };
MediaFormat videoFormat = MediaFormat.createVideoFormat(MediaFormat.MIMETYPE_VIDEO_AVC , 320 , 240 );
videoFormat.setInteger(MediaFormat.KEY_MAX_INPUT_SIZE , 100000);
videoFormat.setByteBuffer("csd-0", ByteBuffer.wrap(header_sps));
videoFormat.setByteBuffer("csd-1", ByteBuffer.wrap(header_pps));
MediaCodec videoDecoder = MediaCodec.createDecoderByType(MediaFormat.MIMETYPE_VIDEO_AVC);
videoDecoder.configure(videoFormat , surface , null , 0);
videoDecoder.start();
if some one know what the correct way to decode H.264 in this case this will be helpfull