为什么“queueInputBuffer”中的“MediaCodec CodecException”仅发生在 Android API 29 上?

2024-01-08

基本信息

目标SDK版本28

Goal:课程的目标是在发送到我的服务器之前调整视频大小。

Problem:应用程序仅在 API 29 上崩溃,无论是使用真实设备还是使用 AVD。例如,该代码可以正常工作像素 2 API 28,但不是在像素 2 API 29

源代码:我主要使用来自的示例代码bigflake.com https://android.googlesource.com/platform/cts/+/jb-mr2-release/tests/tests/media/src/android/media/cts/ExtractDecodeEditEncodeMuxTest.java.

错误信息(详细日志附在下面):

E/AndroidRuntime: FATAL EXCEPTION: Thread-20
    Process: com.myapp.myapp, PID: 9189
    android.media.MediaCodec$CodecException: Error 0xfffffff3
        at android.media.MediaCodec.native_queueInputBuffer(Native Method)
        at android.media.MediaCodec.queueInputBuffer(MediaCodec.java:2450)

我尝试过的由于日志信息有限MediaCodec$CodecException,我尝试从以下更改没有成功MediaCodecInfo.CodecCapabilities.COLOR_FormatSurface to MediaCodecInfo.CodecCapabilities.COLOR_FormatYUV420Flexible.


日志将显示最后两个缓冲周期。我希望你能看到一些有价值的东西。

无法在 *Pixel 2 API 29* 上运行的日志

D/VideoResolutionChanger: no audio encoder output buffer
D/VideoResolutionChanger: loop: V(true){extracted:49(done:false) decoded:45(done:false) encoded:43(done:false)} A(true){extracted:45(done:false) decoded:44(done:false) encoded:1(done:false) pending:-1} muxing:true(V:0,A:1)
D/VideoResolutionChanger: video decoder: returned input buffer: 3
    video extractor: returned buffer of size 31007
    video extractor: returned buffer for time 4448177
D/VideoResolutionChanger: audio decoder: returned input buffer: 1
    audio extractor: returned buffer of size 32
    audio extractor: returned buffer for time 900000
D/VideoResolutionChanger: video decoder: returned output buffer: 5
    video decoder: returned buffer of size 1382400
    video decoder: returned buffer for time 4132500
D/VideoResolutionChanger: output surface: await new image
D/VideoResolutionChanger: output surface: draw image
D/VideoResolutionChanger: input surface: swap buffers
D/VideoResolutionChanger: video encoder: notified of new frame
    audio decoder: returned output buffer: 0
    audio decoder: returned buffer of size 320
D/VideoResolutionChanger: audio decoder: returned buffer for time 880000
    audio decoder: output buffer is now pending: -1
    audio decoder: attempting to process pending buffer: 0
D/VideoResolutionChanger: audio encoder: returned input buffer: 0
    audio decoder: processing pending buffer: 0
    audio decoder: pending buffer of size 320
    audio decoder: pending buffer for time 880000
D/VideoResolutionChanger: should have added track before processing output true
    video encoder: returned output buffer: 0
    video encoder: returned buffer of size 8234
    video encoder: returned buffer for time 3954177
D/VideoResolutionChanger: no audio encoder output buffer
D/VideoResolutionChanger: loop: V(true){extracted:50(done:false) decoded:46(done:false) encoded:44(done:false)} A(true){extracted:46(done:false) decoded:45(done:false) encoded:1(done:false) pending:-1} muxing:true(V:0,A:1)
D/VideoResolutionChanger: video decoder: returned input buffer: 4
    video extractor: returned buffer of size 30897
    video extractor: returned buffer for time 4519077
D/VideoResolutionChanger: video extractor: EOS
D/VideoResolutionChanger: releasing extractor, decoder, encoder, and muxer
D/SurfaceUtils: disconnecting from surface 0xc94d8008, reason disconnectFromSurface
D/MPEG4Writer: Video track stopping. Stop source
    Video track source stopping
    Video track source stopped
I/MPEG4Writer: Received total/0-length (44/0) buffers and encoded 44 frames. - Video
W/MPEG4Writer: 0-duration samples found: 1
I/MPEG4Writer: Received total/0-length (1/0) buffers and encoded 1 frames. - Audio
    Audio track drift time: 0 us
D/MPEG4Writer: Video track stopped. Stop source
D/MPEG4Writer: Audio track stopping. Stop source
    Audio track source stopping
    Audio track source stopped
    Audio track stopped. Stop source
    Duration from tracks range is [241451, 3994621] us
    Stopping writer thread
D/MPEG4Writer: 0 chunks are written in the last batch
D/MPEG4Writer: Writer thread stopped
I/MPEG4Writer: Ajust the moov start time from 0 us -> 0 us
D/MPEG4Writer: Video track stopping. Stop source
D/MPEG4Writer: Audio track stopping. Stop source
E/AndroidRuntime: FATAL EXCEPTION: Thread-20
    Process: com.myapp.myname, PID: 9189
    android.media.MediaCodec$CodecException: Error 0xfffffff3
        at android.media.MediaCodec.native_queueInputBuffer(Native Method)
        at android.media.MediaCodec.queueInputBuffer(MediaCodec.java:2450)
        at com.myapp.myname.utils.VideoResolutionChanger.doExtractDecodeEditEncodeMux(VideoResolutionChanger.java:543)

*Pixel 2 API 28* 工作日志

D/VideoResolutionChanger: no audio encoder output buffer
    loop: V(true){extracted:39(done:true) decoded:39(done:true) encoded:39(done:true)} A(true){extracted:147(done:false) decoded:146(done:false) encoded:5(done:false) pending:-1} muxing:true(V:0,A:1)
    audio decoder: returned input buffer: 3
    audio extractor: returned buffer of size 32
    audio extractor: returned buffer for time 2940000
D/VideoResolutionChanger: audio decoder: returned output buffer: 2
    audio decoder: returned buffer of size 320
    audio decoder: returned buffer for time 2920000
    audio decoder: output buffer is now pending: -1
    audio decoder: attempting to process pending buffer: 2
    audio encoder: returned input buffer: 2
    audio decoder: processing pending buffer: 2
    audio decoder: pending buffer of size 320
    audio decoder: pending buffer for time 2920000
D/VideoResolutionChanger: no audio encoder output buffer
D/VideoResolutionChanger: loop: V(true){extracted:39(done:true) decoded:39(done:true) encoded:39(done:true)} A(true){extracted:148(done:false) decoded:147(done:false) encoded:5(done:false) pending:-1} muxing:true(V:0,A:1)
D/VideoResolutionChanger: audio decoder: returned input buffer: 0
    audio extractor: returned buffer of size -1
    audio extractor: returned buffer for time -1
    audio extractor: EOS
D/VideoResolutionChanger: audio decoder: returned output buffer: 3
    audio decoder: returned buffer of size 320
    audio decoder: returned buffer for time 2940000
    audio decoder: output buffer is now pending: -1
    audio decoder: attempting to process pending buffer: 3
D/VideoResolutionChanger: audio encoder: returned input buffer: 3
    audio decoder: processing pending buffer: 3
    audio decoder: pending buffer of size 320
    audio decoder: pending buffer for time 2940000
D/VideoResolutionChanger: no audio encoder output buffer
D/VideoResolutionChanger: loop: V(true){extracted:39(done:true) decoded:39(done:true) encoded:39(done:true)} A(true){extracted:149(done:true) decoded:148(done:false) encoded:5(done:false) pending:-1} muxing:true(V:0,A:1)
    audio decoder: returned output buffer: 0
    audio decoder: returned buffer of size 0
    audio decoder: returned buffer for time 2880000
    audio decoder: output buffer is now pending: -1
    audio decoder: attempting to process pending buffer: 0
D/VideoResolutionChanger: audio encoder: returned input buffer: 0
    audio decoder: processing pending buffer: 0
    audio decoder: pending buffer of size 0
    audio decoder: pending buffer for time 2880000
D/VideoResolutionChanger: audio decoder: EOS
D/VideoResolutionChanger: should have added track before processing outputtrue
    audio encoder: returned output buffer: 0
    audio encoder: returned buffer of size 761
    audio encoder: returned buffer for time 2801451
    audio encoder: EOS
    encoded and decoded video frame counts should match39 39
    decoded frame count should be less than extracted frame count39 39
D/VideoResolutionChanger: no frame should be pending -1 -1
    releasing extractor, decoder, encoder, and muxer
D/SurfaceUtils: disconnecting from surface 0xd8b50808, reason disconnectFromSurface
D/MPEG4Writer: Video track stopping. Stop source
I/MPEG4Writer: Received total/0-length (6/0) buffers and encoded 6 frames. - Audio
D/MPEG4Writer: Video track source stopping
I/MPEG4Writer: Audio track drift time: 0 us
D/MPEG4Writer: Video track source stopped
I/MPEG4Writer: Received total/0-length (38/0) buffers and encoded 38 frames. - Video
D/MPEG4Writer: Video track stopped. Stop source
D/MPEG4Writer: Audio track stopping. Stop source
    Audio track source stopping
    Audio track source stopped
    Audio track stopped. Stop source
    Duration from tracks range is [3060067, 3302540] us
    Stopping writer thread
D/MPEG4Writer: 0 chunks are written in the last batch
D/MPEG4Writer: Writer thread stopped
I/MPEG4Writer: Ajust the moov start time from 0 us -> 0 us
D/MPEG4Writer: Video track stopping. Stop source
D/MPEG4Writer: Audio track stopping. Stop source

我认为正确的方法是让它再循环一次xxxxExtractor.advance()返回假。

我修改了我的代码,仅在返回的大小之后标记提取器已完成xxxxExtractor.readSampleData回报-1这样您就知道发送到queueInputBuffer 的缓冲区是空的。

So: xxxxExtractorDone = !xxxxExtractor.advance(); -> xxxxExtractorDone = !xxxxExtractor.advance() && size == -1;

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

为什么“queueInputBuffer”中的“MediaCodec CodecException”仅发生在 Android API 29 上? 的相关文章

随机推荐

  • Java 中的 Ruby 解析器

    我正在做的项目是用 Java 和解析器源代码文件编写的 到目前为止的 Java src 现在我也想启用解析 Ruby 代码 因此 我正在寻找一个可以解析 Ruby 源代码的 Java 解析器 到目前为止我唯一能找到的是 Ruby 中的 Ru
  • 从批处理文件运行 python 脚本时出现 ModuleNotFoundError

    我有一个简单的 python 脚本 名为sc py翻译一个词 这是我的代码 python3 from googletrans import Translator import sys translator Translator dest h
  • Excel VBA 创建文件夹、子文件夹和更多子文件夹

    我有一个问题与我在这里看到的其他一些问题非常相似 但它们并没有完全回答我需要的问题 或者当我尝试它们时 它导致了一个我不知道如何解决的错误 只有5级我无法发表评论来提问 在 Excel 中 我有一个用于引用文件夹的命名配置文件的文件 我尝试
  • kerascompute_output_shape不适用于自定义层

    我自定义了一个层 将batch size和第一个维度合并 其他维度不变 但是compute output shape好像没有效果 导致后面的层无法得到准确的形状信息 从而产生错误 如何使compute output shape工作 impo
  • C++ 函数返回字符串数组

    我是 C 新手 对于一个学校项目 我需要创建一个能够返回字符串数组的函数 目前我的标题中有这个 Config h string getVehicles void 配置文件 string Config getVehicles string t
  • docker-compose:删除容器名称的默认后缀?

    my yml version 3 services myservice image myimage 当我跑步时docker compose p myprefix f my yml up 它创建名为myprefix myservice 1 是
  • 如何在没有数据库锁的情况下并行执行线程并在sqlite数据库中插入相应的数据?

    我需要调用多个 api 每个 api 在单独的线程中执行 并将响应中的相应数据插入到 sqlite 数据库中 而不会导致锁定 任何人都可以在这方面帮助我提供一个我可以参考的工作示例 我需要调用多个 api 每个 api 在单独的线程中执行
  • 我应该在哪里存储外键?

    如果我在两个表之间存在关系 两个表都有自己的主键 那么什么应该指导我决定哪个表应该存储外键 我知道关系的性质可能很重要 一对一 一对多 多对多 单向 双向 并且访问模式可能也很重要 那么做出这个决定的系统方法是什么 关系中的子表是哪个表 回
  • 微服务架构松散耦合的复杂性

    我对整个微服务潮流相当陌生 我一直在研究良好的微服务环境背后的架构和原理 定义微服务的主要内容之一应该是每个服务的松散耦合性质 微服务A永远不应该打电话微服务B直接 或者您正在有效地创建一个整体系统 该系统失去了架构模式提供的可扩展性 问题
  • 如何获取由 vector::reserve() 分配的缓冲区的地址?

    我有一个 std vector 值 我知道其最大大小 但实际大小在使用过程中会有所不同 void setupBuffer const size t maxSize myVector reserve maxSize void addToBuf
  • 通过 hibernate 或连接池保证请求

    使用连接池的休眠是否需要重试来处理间歇性故障 例如网络问题 我的同事认为这不是使用连接池的必然原因 如果连接出现任何问题 那么连接池管理器会处理它 我不相信 因为连接可能是开放且有效的 但是当发出请求时 它可能会屈服于网络问题 由于正在做的
  • 异步和等待 - 处理对同一方法的多次调用 - 相互锁定/等待?

    我有一个复杂的基于任务 锁的混乱来执行 长 数据操作 并且我正在尝试用异步 等待替换它 我是异步等待的新手 所以我担心我犯了一些大错误 为了简化事情 我的 UI 有几个页面依赖于相同的数据 现在 我只需要获取这些数据一次 所以我缓存它 进一
  • 对字典中成员“下标”的引用不明确

    我正在尝试为类创建一个可失败的初始化程序 我的类将使用网络请求的输入进行初始化 网络不可靠 我想创建一个初始化程序来检查所有属性是否存在 否则会失败 我试图在这里使用守卫 所以请随时指出该方法中任何明显的错误 public class Jo
  • 特殊字符问题:MQ 消息 PUT 错误:java.nio.charset.UnmappableCharacterException

    我有一个设置 其中有 JMS 生产者和 JMS 接收器 发送者应用程序发送如下消息 source text abcdefg JMS 接收器收到消息后 使用纯 IBM MQ API 类将其放入 IBM MQ 队列 将此消息发送到 MQ 时 我
  • Go Web 应用程序的目录结构

    我已经按照编写网络应用程序 https golang org doc articles wiki Go 网站上的教程 我开始编写自己的网络应用程序 我也读过开头如何编写 Go 代码 https golang org doc code htm
  • 排除在 TypeScript 中监视的目录

    watch是开发过程中的一个巧妙的功能 但是 在我的应用程序中 我将文件上传到名为的目录tmp 每当文件上传到此目录时 我的应用程序都会重新编译 这会导致各种问题 我想排除tmp免遭监视 到目前为止我尝试过添加tmp to the excl
  • Python 在 Javascript / jQuery 中的部分等效

    Python 的等价物是什么functools partial https docs python org 2 library functools html functools partial在 JavaScript 或 jQuery 中
  • 未找到 IPython 命令 OSX 终端。点安装

    使用通过自制程序安装的 Python 2 7 然后我使用 pip 安装 IPython 因此 IPython 似乎安装在 usr local lib python2 7 site packages 我认为这是真的 因为有一个 IPython
  • 如何保护 ASP.NET_SessionId cookie 的安全?

    我已将 ASPXAUTH cookie 设置为仅 https 但我不确定如何有效地对 ASP NET SessionId 执行相同操作 整个站点使用 HTTPS 因此 cookie 无需同时适用于 http 和 https 要添加 secu
  • 为什么“queueInputBuffer”中的“MediaCodec CodecException”仅发生在 Android API 29 上?

    基本信息 目标SDK版本28 Goal 课程的目标是在发送到我的服务器之前调整视频大小 Problem 应用程序仅在 API 29 上崩溃 无论是使用真实设备还是使用 AVD 例如 该代码可以正常工作像素 2 API 28 但不是在像素 2