Я пытаюсь преобразовать некоторые растровые изображения в видео и закодировать их с помощью этой библиотеки https://github.com/israel-fl/bitmap2video
В FrameBuilder.kt он кодирует задано в AVC/H264.
Однако dequeueOutputBuffer в конце потока вернет -1/INFO_TRY_AGAIN_LATER на моем Google Pixel Pixel 6 Pro, но он отлично работает на Samsung С21/С22. Почему?
Выход для Pixel 6 Pro
12:35:03.435 D drainCodec(false), encoderStatus=-1
12:35:03.457 D drainCodec(false), encoderStatus=-1
12:35:03.480 D drainCodec(false), encoderStatus=-1
12:35:03.493 D drainCodec(false), encoderStatus=-1
12:35:03.506 D drainCodec(false), encoderStatus=-1
12:35:03.516 D releasing encoder objects
12:35:03.516 D drainCodec(true), encoderStatus=-1
12:35:03.516 D sending EOS to encoder
12:35:03.527 D no output available, spinning to await EOS
12:35:03.537 D no output available, spinning to await EOS
12:35:03.549 D no output available, spinning to await EOS
12:35:03.560 D no output available, spinning to await EOS
12:35:03.571 D no output available, spinning to await EOS
12:35:03.583 D no output available, spinning to await EOS
~ continues indefinitely
Журналы Samsung S21:
12:49:05.493 I qqq uri=content://media/external/video/media/1000026049
12:49:14.362 D drainCodec(false)
12:49:14.396 D drainCodec(false)
12:49:14.442 D drainCodec(false)
12:49:14.492 D drainCodec(false)
12:49:14.494 D encoder output format changed: {max-bitrate=1500000, crop-right=2159, level=32768, mime=video/avc, profile=8, bitrate=1500000, priority=0, intra-refresh-period=0, color-standard=1, csd-1=java.nio.HeapByteBuffer[pos=0 lim=8 cap=8], color-transfer=3, crop-bottom=3839, prepend-sps-pps-to-idr-frames=0, video-qp-average=0, crop-left=0, width=2160, bitrate-mode=1, color-range=2, crop-top=0, frame-rate=30, height=3840, csd-0=java.nio.HeapByteBuffer[pos=0 lim=22 cap=22]}
12:49:14.498 D {max-bitrate=1500000, crop-right=2159, level=32768, mime=video/avc, profile=8, bitrate=1500000, priority=0, intra-refresh-period=0, color-standard=1, csd-1=java.nio.HeapByteBuffer[pos=0 lim=8 cap=8], color-transfer=3, crop-bottom=3839, prepend-sps-pps-to-idr-frames=0, video-qp-average=0, crop-left=0, width=2160, bitrate-mode=1, color-range=2, crop-top=0, frame-rate=30, height=3840, csd-0=java.nio.HeapByteBuffer[pos=0 lim=22 cap=22]}
12:49:14.507 D ignoring BUFFER_FLAG_CODEC_CONFIG
12:49:14.509 D sent 6605 bytes to muxer
12:49:14.510 D sent 1255 bytes to muxer
12:49:14.517 D sent 2901 bytes to muxer
12:49:14.548 D drainCodec(false)
12:49:14.578 D drainCodec(false)
12:49:14.579 D sent 7208 bytes to muxer
12:49:14.610 D drainCodec(false)
12:49:14.611 D sent 10116 bytes to muxer
12:49:14.646 D drainCodec(false)
12:49:14.648 D sent 18212 bytes to muxer
12:49:14.678 D drainCodec(false)
12:49:14.679 D sent 14077 bytes to muxer
12:49:14.711 D drainCodec(false)
12:49:14.712 D sent 13230 bytes to muxer
12:49:14.745 D drainCodec(false)
12:49:14.746 D sent 13348 bytes to muxer
12:49:14.778 D drainCodec(false)
12:49:14.778 D sent 14504 bytes to muxer
12:49:14.796 D drainCodec(false)
12:49:14.804 D sent 14219 bytes to muxer
12:49:14.814 D releasing encoder objects
12:49:14.814 D drainCodec(true)
12:49:14.814 D sending EOS to encoder
12:49:14.825 D no output available, spinning to await EOS
12:49:14.828 D sent 12867 bytes to muxer
12:49:14.838 D no output available, spinning to await EOS
12:49:14.843 D end of stream reached
функция dropCoded
private fun drainCodec(endOfStream: Boolean) {
if (VERBOSE) Log.d(TAG, "drainCodec($endOfStream)")
if (endOfStream) {
if (VERBOSE) Log.d(TAG, "sending EOS to encoder")
mediaCodec.signalEndOfInputStream()
}
while (true) {
val encoderStatus: Int = mediaCodec.dequeueOutputBuffer(bufferInfo, TIMEOUT_USEC.toLong())
if (VERBOSE) Log.d(TAG, "encoderStatus=$encoderStatus")
if (encoderStatus == MediaCodec.INFO_TRY_AGAIN_LATER) {
// no output available yet, stuck here on Google Pixel
if (!endOfStream) {
break // out of while
} else {
if (VERBOSE) Log.d(TAG, "no output available, spinning to await EOS")
}
} else if (encoderStatus == MediaCodec.INFO_OUTPUT_FORMAT_CHANGED) {
// should happen before receiving buffers, and should only happen once
if (frameMuxer.isStarted()) throw RuntimeException("format changed twice")
val newFormat: MediaFormat = mediaCodec.outputFormat
Log.d(TAG, "encoder output format changed: $newFormat")
// now that we have the Magic Goodies, start the muxer
frameMuxer.start(newFormat, audioExtractor)
} else {
val encodedData = mediaCodec.getOutputBuffer(encoderStatus) ?: throw RuntimeException("encoderOutputBuffer $encoderStatus was null")
if (bufferInfo.flags and MediaCodec.BUFFER_FLAG_CODEC_CONFIG != 0) {
// The codec config data was pulled out and fed to the muxer when we got
// the INFO_OUTPUT_FORMAT_CHANGED status. Ignore it.
if (VERBOSE) Log.d(TAG, "ignoring BUFFER_FLAG_CODEC_CONFIG")
bufferInfo.size = 0
} else {
if (VERBOSE) Log.d(TAG, "Flags not configured")
}
if (bufferInfo.size != 0) {
if (!frameMuxer.isStarted()) throw RuntimeException("muxer hasn't started")
frameMuxer.muxVideoFrame(encodedData, bufferInfo)
if (VERBOSE) Log.d(TAG, "sent " + bufferInfo.size + " bytes to muxer")
} else {
if (VERBOSE) Log.d(TAG, "No bytes sent")
}
mediaCodec.releaseOutputBuffer(encoderStatus, false)
if (bufferInfo.flags and MediaCodec.BUFFER_FLAG_END_OF_STREAM != 0) {
if (!endOfStream) {
Log.w(TAG, "reached end of stream unexpectedly")
} else {
if (VERBOSE) Log.d(TAG, "end of stream reached")
}
break // out of while
}
}
}
}
Подробнее здесь: https://stackoverflow.com/questions/790 ... -pixel-but
MediaCodec.dequeueOutputBuffer возвращает INFO_TRY_AGAIN_LATER в Google Pixel, но не в Samsung Galaxy ⇐ Android
Форум для тех, кто программирует под Android
1726918496
Anonymous
Я пытаюсь преобразовать некоторые растровые изображения в видео и закодировать их с помощью этой библиотеки https://github.com/israel-fl/bitmap2video
В FrameBuilder.kt он кодирует задано в AVC/H264.
Однако dequeueOutputBuffer в конце потока вернет -1/INFO_TRY_AGAIN_LATER на моем Google Pixel Pixel 6 Pro, но он отлично работает на Samsung С21/С22. Почему?
Выход для Pixel 6 Pro
12:35:03.435 D drainCodec(false), encoderStatus=-1
12:35:03.457 D drainCodec(false), encoderStatus=-1
12:35:03.480 D drainCodec(false), encoderStatus=-1
12:35:03.493 D drainCodec(false), encoderStatus=-1
12:35:03.506 D drainCodec(false), encoderStatus=-1
12:35:03.516 D releasing encoder objects
12:35:03.516 D drainCodec(true), encoderStatus=-1
12:35:03.516 D sending EOS to encoder
12:35:03.527 D no output available, spinning to await EOS
12:35:03.537 D no output available, spinning to await EOS
12:35:03.549 D no output available, spinning to await EOS
12:35:03.560 D no output available, spinning to await EOS
12:35:03.571 D no output available, spinning to await EOS
12:35:03.583 D no output available, spinning to await EOS
~ continues indefinitely
Журналы Samsung S21:
12:49:05.493 I qqq uri=content://media/external/video/media/1000026049
12:49:14.362 D drainCodec(false)
12:49:14.396 D drainCodec(false)
12:49:14.442 D drainCodec(false)
12:49:14.492 D drainCodec(false)
12:49:14.494 D encoder output format changed: {max-bitrate=1500000, crop-right=2159, level=32768, mime=video/avc, profile=8, bitrate=1500000, priority=0, intra-refresh-period=0, color-standard=1, csd-1=java.nio.HeapByteBuffer[pos=0 lim=8 cap=8], color-transfer=3, crop-bottom=3839, prepend-sps-pps-to-idr-frames=0, video-qp-average=0, crop-left=0, width=2160, bitrate-mode=1, color-range=2, crop-top=0, frame-rate=30, height=3840, csd-0=java.nio.HeapByteBuffer[pos=0 lim=22 cap=22]}
12:49:14.498 D {max-bitrate=1500000, crop-right=2159, level=32768, mime=video/avc, profile=8, bitrate=1500000, priority=0, intra-refresh-period=0, color-standard=1, csd-1=java.nio.HeapByteBuffer[pos=0 lim=8 cap=8], color-transfer=3, crop-bottom=3839, prepend-sps-pps-to-idr-frames=0, video-qp-average=0, crop-left=0, width=2160, bitrate-mode=1, color-range=2, crop-top=0, frame-rate=30, height=3840, csd-0=java.nio.HeapByteBuffer[pos=0 lim=22 cap=22]}
12:49:14.507 D ignoring BUFFER_FLAG_CODEC_CONFIG
12:49:14.509 D sent 6605 bytes to muxer
12:49:14.510 D sent 1255 bytes to muxer
12:49:14.517 D sent 2901 bytes to muxer
12:49:14.548 D drainCodec(false)
12:49:14.578 D drainCodec(false)
12:49:14.579 D sent 7208 bytes to muxer
12:49:14.610 D drainCodec(false)
12:49:14.611 D sent 10116 bytes to muxer
12:49:14.646 D drainCodec(false)
12:49:14.648 D sent 18212 bytes to muxer
12:49:14.678 D drainCodec(false)
12:49:14.679 D sent 14077 bytes to muxer
12:49:14.711 D drainCodec(false)
12:49:14.712 D sent 13230 bytes to muxer
12:49:14.745 D drainCodec(false)
12:49:14.746 D sent 13348 bytes to muxer
12:49:14.778 D drainCodec(false)
12:49:14.778 D sent 14504 bytes to muxer
12:49:14.796 D drainCodec(false)
12:49:14.804 D sent 14219 bytes to muxer
12:49:14.814 D releasing encoder objects
12:49:14.814 D drainCodec(true)
12:49:14.814 D sending EOS to encoder
12:49:14.825 D no output available, spinning to await EOS
12:49:14.828 D sent 12867 bytes to muxer
12:49:14.838 D no output available, spinning to await EOS
12:49:14.843 D end of stream reached
функция dropCoded
private fun drainCodec(endOfStream: Boolean) {
if (VERBOSE) Log.d(TAG, "drainCodec($endOfStream)")
if (endOfStream) {
if (VERBOSE) Log.d(TAG, "sending EOS to encoder")
mediaCodec.signalEndOfInputStream()
}
while (true) {
val encoderStatus: Int = mediaCodec.dequeueOutputBuffer(bufferInfo, TIMEOUT_USEC.toLong())
if (VERBOSE) Log.d(TAG, "encoderStatus=$encoderStatus")
if (encoderStatus == MediaCodec.INFO_TRY_AGAIN_LATER) {
// no output available yet, stuck here on Google Pixel
if (!endOfStream) {
break // out of while
} else {
if (VERBOSE) Log.d(TAG, "no output available, spinning to await EOS")
}
} else if (encoderStatus == MediaCodec.INFO_OUTPUT_FORMAT_CHANGED) {
// should happen before receiving buffers, and should only happen once
if (frameMuxer.isStarted()) throw RuntimeException("format changed twice")
val newFormat: MediaFormat = mediaCodec.outputFormat
Log.d(TAG, "encoder output format changed: $newFormat")
// now that we have the Magic Goodies, start the muxer
frameMuxer.start(newFormat, audioExtractor)
} else {
val encodedData = mediaCodec.getOutputBuffer(encoderStatus) ?: throw RuntimeException("encoderOutputBuffer $encoderStatus was null")
if (bufferInfo.flags and MediaCodec.BUFFER_FLAG_CODEC_CONFIG != 0) {
// The codec config data was pulled out and fed to the muxer when we got
// the INFO_OUTPUT_FORMAT_CHANGED status. Ignore it.
if (VERBOSE) Log.d(TAG, "ignoring BUFFER_FLAG_CODEC_CONFIG")
bufferInfo.size = 0
} else {
if (VERBOSE) Log.d(TAG, "Flags not configured")
}
if (bufferInfo.size != 0) {
if (!frameMuxer.isStarted()) throw RuntimeException("muxer hasn't started")
frameMuxer.muxVideoFrame(encodedData, bufferInfo)
if (VERBOSE) Log.d(TAG, "sent " + bufferInfo.size + " bytes to muxer")
} else {
if (VERBOSE) Log.d(TAG, "No bytes sent")
}
mediaCodec.releaseOutputBuffer(encoderStatus, false)
if (bufferInfo.flags and MediaCodec.BUFFER_FLAG_END_OF_STREAM != 0) {
if (!endOfStream) {
Log.w(TAG, "reached end of stream unexpectedly")
} else {
if (VERBOSE) Log.d(TAG, "end of stream reached")
}
break // out of while
}
}
}
}
Подробнее здесь: [url]https://stackoverflow.com/questions/79009402/mediacodec-dequeueoutputbuffer-returns-info-try-again-later-on-google-pixel-but[/url]
Ответить
1 сообщение
• Страница 1 из 1
Перейти
- Кемерово-IT
- ↳ Javascript
- ↳ C#
- ↳ JAVA
- ↳ Elasticsearch aggregation
- ↳ Python
- ↳ Php
- ↳ Android
- ↳ Html
- ↳ Jquery
- ↳ C++
- ↳ IOS
- ↳ CSS
- ↳ Excel
- ↳ Linux
- ↳ Apache
- ↳ MySql
- Детский мир
- Для души
- ↳ Музыкальные инструменты даром
- ↳ Печатная продукция даром
- Внешняя красота и здоровье
- ↳ Одежда и обувь для взрослых даром
- ↳ Товары для здоровья
- ↳ Физкультура и спорт
- Техника - даром!
- ↳ Автомобилистам
- ↳ Компьютерная техника
- ↳ Плиты: газовые и электрические
- ↳ Холодильники
- ↳ Стиральные машины
- ↳ Телевизоры
- ↳ Телефоны, смартфоны, плашеты
- ↳ Швейные машинки
- ↳ Прочая электроника и техника
- ↳ Фототехника
- Ремонт и интерьер
- ↳ Стройматериалы, инструмент
- ↳ Мебель и предметы интерьера даром
- ↳ Cантехника
- Другие темы
- ↳ Разное даром
- ↳ Давай меняться!
- ↳ Отдам\возьму за копеечку
- ↳ Работа и подработка в Кемерове
- ↳ Давай с тобой поговорим...
Мобильная версия