I’m creating videos from MediaCodec, when running Android API on 29 there is no problem, from 29 down there is a problem, this is the error:
Video creation parameters:
private static final String MIME_TYPE = "video/avc"; public static int BIT_RATE = 12 * 1000000; private static int FRAMES_PER_SECOND = 30; private static final int IFRAME_INTERVAL = 5;
java.lang.IllegalStateException
at android.media.MediaCodec.native_dequeueOutputBuffer(Native Method)
at android.media.MediaCodec.dequeueOutputBuffer(MediaCodec.java:2789)
source code:
private void drainEncoder(boolean endOfStream) {
final int TIMEOUT_USEC = 10000;
if (VERBOSE) Log.d(TAG, "drainEncoder(" + endOfStream + ")");
if (mEncoder != null) {
if (endOfStream) {
if (VERBOSE) Log.d(TAG, "sending EOS to encoder");
mEncoder.signalEndOfInputStream();
}
// Retrieve the set of OutputBuffers
ByteBuffer[] encoderOutputBuffers = mEncoder.getOutputBuffers();
while (true) {
// Returns the index of an output buffer that has been successfully decoded.
// or one of the INFO_* constants.
int encoderStatus = mEncoder.dequeueOutputBuffer(mBufferInfo, TIMEOUT_USEC);
if (encoderStatus == MediaCodec.INFO_TRY_AGAIN_LATER) {
Log.d(TAG, "try again later");
// no output available yet
if (!endOfStream) {
break; // out of while
} else {
if (VERBOSE) Log.d(TAG, "no output available, spinning to await EOS");
} ....
If anyone has encountered the above problem, I look forward to your feedback.
New contributor
HoaPjhat is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.