Open zlongCoding opened 4 years ago
如果出现这个错误,问题在于:
android.media.MediaCodec$CodecException: Error 0xfffffc0e
解决方案: 文件 flutter_rtmp/android/srs/main/java/net/ossrs/yasea/SrsEncoder.java 搜索
MediaFormat videoFormat = MediaFormat.createVideoFormat(VCODEC, vOutWidth, vOutHeight);
videoFormat.setInteger(MediaFormat.KEY_COLOR_FORMAT, mVideoColorFormat);
videoFormat.setInteger(MediaFormat.KEY_MAX_INPUT_SIZE, 0);
videoFormat.setInteger(MediaFormat.KEY_BIT_RATE, vBitrate);
videoFormat.setInteger(MediaFormat.KEY_FRAME_RATE, VFPS);
videoFormat.setInteger(MediaFormat.KEY_I_FRAME_INTERVAL, VGOP / VFPS);
vencoder.configure(videoFormat, null, null, MediaCodec.CONFIGURE_FLAG_ENCODE);
// add the video tracker to muxer.
videoFlvTrack = flvMuxer.addTrack(videoFormat);
videoMp4Track = mp4Muxer.addTrack(videoFormat);
然后改成:
try {
int formatWidth = vOutWidth;
int formatHeight = vOutHeight;
if ((formatWidth & 1) == 1) {
formatWidth--;
}
if ((formatHeight & 1) == 1) {
formatHeight--;
}
// final MediaFormat format = MediaFormat.createVideoFormat(MIME_TYPE, formatWidth, formatHeight);
MediaFormat videoFormat = MediaFormat.createVideoFormat(VCODEC, formatWidth, formatHeight);
videoFormat.setInteger(MediaFormat.KEY_COLOR_FORMAT, mVideoColorFormat);
videoFormat.setInteger(MediaFormat.KEY_MAX_INPUT_SIZE, 0);
videoFormat.setInteger(MediaFormat.KEY_BIT_RATE, vBitrate);
videoFormat.setInteger(MediaFormat.KEY_FRAME_RATE, VFPS);
videoFormat.setInteger(MediaFormat.KEY_I_FRAME_INTERVAL, VGOP / VFPS);
vencoder.configure(videoFormat, null, null, MediaCodec.CONFIGURE_FLAG_ENCODE);
videoFlvTrack = flvMuxer.addTrack(videoFormat);
videoMp4Track = mp4Muxer.addTrack(videoFormat);
} catch (Exception e) {
System.out.println(e);
}
希望对大家有所帮助。。。
作者大大帮忙看看呗,手机是小米,安卓系统是10