Nexus 7 2013 Mediacodec视频编码器输出乱码 [英] Nexus 7 2013 mediacodec video encoder garbled output

查看:244
本文介绍了Nexus 7 2013 Mediacodec视频编码器输出乱码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个应用程序,该应用程序使用h.264编码器将电影编码为画廊和其他目标.此应用在输出时支持可变的宽高比(1:1、2:3、3:2、16:9、3:4、4:3).我将表面输入用于4.3 API的输入/输出.

I'm working on an app which encodes a movie using h.264 encoder to gallery and other targets. This app supports variable aspect ratios at output (1:1, 2:3, 3:2, 16:9, 3:4, 4:3). I'm using surface inputs for input/output from the 4.3 API.

该应用程序可以在许多设备上正常运行(在S3,Motorola G,Nexus 7 2012和Motorola X上进行了测试),但是,在Nexus 7 2013上运行时,我碰到了麻烦.

The app works ok on many devices (tested on S3, Motorola G, Nexus 7 2012, Motorola X), however, I've hit a wall when running it on Nexus 7 2013.

基本上,有些输出分辨率有效,有些则不能. 3:4(720x960),2:3(720x1080)和16:9(1280x720)正常工作,但其余(1:1(960x960),3:2(1080x720)和4:3(960x720))产生这样的输出:

Basically, some output resolutions work, some do not. 3:4 (720x960), 2:3 (720x1080) and 16:9 (1280x720) work as intended, but the rest (1:1 (960x960), 3:2 (1080x720) and 4:3 (960x720)) produce an output like this:

http://imageshack.com/a/img811/7984/dtgh.png

我的猜测是,编码器中存在一些硬编码的值,该值会将其输入表面的宽度与实际宽度不同-像素线似乎未正确对齐".但是,我不知该怎么办,如何解决它.

My guess is that there is some value hard coded in the encoder which treats its input surface as having a different width than it actually has - the pixel lines seem to "not line up correctly". However, I am at a loss at what can cause this and how to work around it.

日志中没有错误,并且视频编码器编解码器在输出媒体格式时在日志中输出了正确的表面宽度和高度.

There are no errors in the log and the video encoder codec outputs in the log the correct surface width and height when outputing the media format.

更新:使用360、720或1280宽度编码时似乎没有问题,而高度没有影响.我还没有发现其他低于1280的宽度有效.

update: seems there are no issues when encoding with 360, 720 or 1280 width, with height having no impact. I haven't found any other widths below 1280 that work.

update2:似乎还有更多可用的宽度:180、240、640、700.找不到它们之间的任何关联.

update2: seems there are more widths that work: 180, 240, 640, 700. Couldn't find any correlation between them.

推荐答案

我认为它与设备的芯片组有关. 我对旧的Motorola XT1058遇到了完全相同的问题,它使用的是Qualcomm Snapdragon S4 Pro,该芯片组与Nexus 7相同.

I believe it has something to do with the device's chipset. I have the exact same problem with an old Motorola XT1058, which uses a Qualcomm Snapdragon S4 Pro, the same chipset as the Nexus 7.

做一些研究后,我发现另一个答案是,在较旧的Qualcomm设备中,YUV数据需要在2K边界处对齐,但是我不明白如何使用输入表面而不是YUV缓冲区来修复它.

Doing some research I discovered through another answer that in older Qualcomm devices YUV data needs to be aligned at a 2K boundary, yet I can't understand how to fix it when using a input surface instead of YUV buffers.

请参阅下一个可接受的答案,以获取有关Qualcomm对齐要求的声明:

See the next accepted answer for the statement about the Qualcomm alignment requirements:

如何获得大步走MediaCodec编码器的Y平面对齐值

我的解决方法是,对于较旧的设备,我将使用已知的分辨率,这些分辨率可以通过使用CamcorderProfile API查询视频配置文件来获得.

My workaround is that for older devices I will use resolutions which I know will work, these are the ones that I can obtain by querying video profiles with the CamcorderProfile API.

主要问题是如何检测设备是否受到影响,因为MediaCodec API只能提供编解码器名称,而不能给出其版本.

The main problem is how to detect if a device is affected or not, as the MediaCodec API can give only the codec name but not its version.

这篇关于Nexus 7 2013 Mediacodec视频编码器输出乱码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆