Hi, I am trying to encode HEVC/H264 with android Mediacodec. But I find that the IDR frame was separated into two parts, and causing some player to display half of the image. This happens to both H264 and HEVC, I take HEVC for instance.
I don't know if I fail to setup some parameters for mediacodec. My settings are like this
format.setString(MediaFormat.KEY_MIME, MediaFormat.MIMETYPE_VIDEO_HEVC);
format.setInteger(MediaFormat.KEY_BIT_RATE, bitRate);
format.setInteger(MediaFormat.KEY_BITRATE_MODE, MediaCodecInfo.EncoderCapabilities.BITRATE_MODE_VBR);
format.setInteger(MediaFormat.KEY_FRAME_RATE, frameRate);
format.setInteger(MediaFormat.KEY_COLOR_FORMAT, MediaCodecInfo.CodecCapabilities.COLOR_FormatSurface);
format.setInteger(MediaFormat.KEY_GRID_ROWS, 10);
format.setInteger(MediaFormat.KEY_MAX_INPUT_SIZE, 3000 3000);
format.setInteger(MediaFormat.KEY_I_FRAME_INTERVAL, iFrameInterval);
// display the very first frame, and recover from bad quality when no new frames
format.setLong(MediaFormat.KEY_REPEAT_PREVIOUS_FRAME_AFTER,
MICROSECONDS_IN_ONE_SECOND REPEAT_FRAME_DELAY / frameRate); // µs
format.setInteger(MediaFormat.KEY_PROFILE, MediaCodecInfo.CodecProfileLevel.HEVCProfileMain);
format.setInteger("level", MediaCodecInfo.CodecProfileLevel.HEVCMainTierLevel6);
format.setFloat(MediaFormat.KEY_MAX_FPS_TO_ENCODER, fps);
Hi, I am trying to encode HEVC/H264 with android Mediacodec. But I find that the IDR frame was separated into two parts, and causing some player to display half of the image. This happens to both H264 and HEVC, I take HEVC for instance.
0 0 0 1 64 (vps) 0 0 0 1 66 (sps) 0 0 0 1 68 (pps) 0 0 0 1 38 (IDR) 0 0 0 1 38 (IDR)
I don't know if I fail to setup some parameters for mediacodec. My settings are like this
format.setString(MediaFormat.KEY_MIME, MediaFormat.MIMETYPE_VIDEO_HEVC); format.setInteger(MediaFormat.KEY_BIT_RATE, bitRate); format.setInteger(MediaFormat.KEY_BITRATE_MODE, MediaCodecInfo.EncoderCapabilities.BITRATE_MODE_VBR); format.setInteger(MediaFormat.KEY_FRAME_RATE, frameRate); format.setInteger(MediaFormat.KEY_COLOR_FORMAT, MediaCodecInfo.CodecCapabilities.COLOR_FormatSurface); format.setInteger(MediaFormat.KEY_GRID_ROWS, 10); format.setInteger(MediaFormat.KEY_MAX_INPUT_SIZE, 3000 3000); format.setInteger(MediaFormat.KEY_I_FRAME_INTERVAL, iFrameInterval); // display the very first frame, and recover from bad quality when no new frames format.setLong(MediaFormat.KEY_REPEAT_PREVIOUS_FRAME_AFTER, MICROSECONDS_IN_ONE_SECOND REPEAT_FRAME_DELAY / frameRate); // µs format.setInteger(MediaFormat.KEY_PROFILE, MediaCodecInfo.CodecProfileLevel.HEVCProfileMain); format.setInteger("level", MediaCodecInfo.CodecProfileLevel.HEVCMainTierLevel6); format.setFloat(MediaFormat.KEY_MAX_FPS_TO_ENCODER, fps);