本文介绍了编码上的Xperia Z1媒体codeC相机preVIEW帧时不一致的视频质量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我编码 NV21 帧从相机preVIEW来了。出于某种原因,该架构是工作的罚款中的其他设备工作不正确的索尼Xperia Z1 安卓4.3 。它发回的连接codeD架不正确的(低)的质量。

媒体codeC 的格式为: COLOR_FormatYUV420SemiPlanar NV12 (我转换 NV21 NV12 通过交换U和V分量)。输出缓冲器发回给我的媒体codeC 与不对应的分辨率非常低的尺寸( 1280×720 )和比特率(百万)我使用。前几帧来了一个良好的品质,但它的显著下降:

  INT EN coderStatus = MMEDIA codec.dequeueOutputBuffer(mBufferInfo,TIMEOUT_USEC);
//几个连接coderStatus检查跳过
ByteBuffer的EN codedData = outputBuffers [CN coderStatus]。
Log.i(Constants.TAG,缓冲区大小+ mBufferInfo.size);
 

这给了我以下日志上的Xperia Z1:

 缓冲区大小26
缓冲区大小52172
缓冲区大小23650
缓冲区大小14394
缓冲区大小3591
缓冲区大小1849年
缓冲区大小3908

...

缓冲区大小1043
缓冲区大小248
缓冲区大小836
缓冲区大小518
缓冲区大小1112
 

例如,从索尼Xperia ZR 在此正常工作日志

 缓冲区大小21
缓冲区大小51048
缓冲区大小21063
缓冲区大小24228
缓冲区大小28040
...
缓冲区大小44959
缓冲区大小44972
缓冲区大小44957
缓冲区大小45004
缓冲区大小44999
缓冲区大小44957
 

任何意见将是AP preciated。

解决方案

你确定你传递时间戳在正确的单元(微秒) - 并且它设置一个合理的帧率?

  • 部分带codeRS可能会忽略时间戳,只设置每帧的固定比特率预算的基础上,帧率。

  • 其他人可能会试图计算他们有多少位允许每个基于时间戳架使用。

如果该时间戳例如给予以毫秒为单位,而不是,这可能导致连接codeR减少连接codeD架至零的大小。

I am encoding NV21 frames coming from camera preview. For some reason schema which is working fine on other devices works incorrectly on Sony Xperia Z1 with Android 4.3. It sends back encoded frames with incorrect (low) quality.

MediaCodec's format is COLOR_FormatYUV420SemiPlanar which is NV12 (I convert NV21 to NV12 by swapping U and V components). Output buffers sent back to me by MediaCodec are with very low size which don't correspond to resolution (1280x720) and bitrate (1000000) I am using. First few frames are coming with a good quality, but then it's dropping significantly:

int encoderStatus = mMediaCodec.dequeueOutputBuffer(mBufferInfo, TIMEOUT_USEC);
// a few encoderStatus checks skipped
ByteBuffer encodedData = outputBuffers[encoderStatus];
Log.i(Constants.TAG, "Buffer size " + mBufferInfo.size);

Which gives me the following log on Xperia Z1:

Buffer size 26
Buffer size 52172
Buffer size 23650
Buffer size 14394
Buffer size 3591
Buffer size 1849
Buffer size 3908

...

Buffer size 1043
Buffer size 248
Buffer size 836
Buffer size 518
Buffer size 1112

Example log from Sony Xperia ZR on which this works properly:

Buffer size 21
Buffer size 51048
Buffer size 21063
Buffer size 24228
Buffer size 28040
...
Buffer size 44959
Buffer size 44972
Buffer size 44957
Buffer size 45004
Buffer size 44999
Buffer size 44957

Any advice would be appreciated.

解决方案

Are you sure you pass timestamps in the right unit (microseconds) - and that it has set a sensible framerate?

  • Some encoders might ignore the timestamps and only set a fixed bitrate budget per frame, based on the framerate.

  • Others might try to calculate how many bits they're allowed to use per frame based on the timestamp.

If the timestamps are given e.g. in milliseconds instead, this could lead to the encoder reducing the size of encoded frames down towards zero.

这篇关于编码上的Xperia Z1媒体codeC相机preVIEW帧时不一致的视频质量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-24 09:00