- reset:使codec返回到初始(未初始化)状态。
2.4 Talk is cheap, Show me the code
初始化MediaCodec
/**
- 视频类型
*/
private final static String MIME_TYPE = “video/avc”;
/**
- 初始化播放
*/
private void initVideo(SurfaceHolder holder) {
try {
// 初始化MediaCodec,方法有两种,分别是通过名称和类型来创建
// 这里使用通过类型来创建
mMediaCodec = MediaCodec.createDecoderByType(MIME_TYPE);
// 获取视频的宽高
mVideoHeight = holder.getSurfaceFrame().width();
mVideoWidth = holder.getSurfaceFrame().height();
// MediaFormat,这个类包含了比特率、帧率、关键帧间隔时间等,其中比特率如果太低就会造成类似马赛克的现象。
mMediaFormat = MediaFormat.createVideoFormat(MIME_TYPE,
1080, 1920);
// 设置比特率
mMediaFormat.setInteger(KEY_BIT_RATE,
mVideoHeight * mVideoWidth