我正在使用新的API MediaCodec。我想获得解码的视频帧并在某个调度时间在表面上渲染它们。现在,我可以在模拟器上正确运行我的代码,并获得如下视频帧格式:
{height=192, what=1869968451, color-format=19, slice-height=192, crop-left=0, width=320, crop-bottom=179, crop-top=0, mime=video/raw, stride=320, crop-right=319}
但是当我在nexus 4上运行代码时,视频帧格式变为
{height=180, what=1869968451, color-format=2141391875, slice-height=192, crop-left=0, width=320, crop-bottom=179, crop-top=0, mime=video/raw, stride=384, crop-right=319}
我无法找出颜色格式2141391875是什么以及为什么高度不是192.一个有趣的问题是当我将配置函数从codec.configure(format, surface /* surface */, null /* crypto */, 0 /* flags */)
修改为codec.configure(format, null/* surface */, null /* crypto */, 0 /* flags */)
时,输出缓冲区长度将从0更改为114688.但实际上,如果帧格式为YUV420p(320 * 192 * 1.5),则正确的缓冲区长度应为92160。我在模拟器上运行时发现输出格式改变之前输出缓冲区已更改。但是当我在nexus 4上运行时没有改变。日志显示如下,
在模拟器上:
03-26 14:42:38.466: I/VideoPlayTAG(1212): count=0
03-26 14:42:38.476: I/VideoPlayTAG(1212): sampleSize:700
03-26 14:42:38.496: D/VideoPlayTAG(1212): next:true
03-26 14:42:38.496: I/VideoPlayTAG(1212): output index:-3
03-26 14:42:38.566: D/VideoPlayTAG(1212): output buffers have changed.
03-26 14:42:38.566: I/VideoPlayTAG(1212): count=1
03-26 14:42:38.566: I/VideoPlayTAG(1212): sampleSize:140
03-26 14:42:38.596: D/VideoPlayTAG(1212): next:true
03-26 14:42:38.596: I/VideoPlayTAG(1212): output index:-2
03-26 14:42:38.686: D/VideoPlayTAG(1212): color=19 width=320 height=192
03-26 14:42:38.686: I/JNI(1212): begin setRender 1734
03-26 14:42:38.686: I/JNI(1212): setRender
03-26 14:42:38.716: D/VideoPlayTAG(1212): output format has changed to {height=192, what=1869968451, color-format=19, slice-height=192, crop-left=0, width=320, crop-bottom=179, crop-top=0, mime=video/raw, stride=320, crop-right=319}
03-26 14:42:38.716: I/VideoPlayTAG(1212): count=2
关于nexus 4:
03-26 10:17:59.674: I/VideoPlayTAG(29899): count=0
03-26 10:17:59.684: I/VideoPlayTAG(29899): sampleSize:700
03-26 10:17:59.684: D/VideoPlayTAG(29899): next:true
03-26 10:17:59.694: I/VideoPlayTAG(29899): output index:-1
03-26 10:17:59.694: I/VideoPlayTAG(29899): count=1
03-26 10:17:59.704: I/VideoPlayTAG(29899): sampleSize:140
03-26 10:17:59.704: D/VideoPlayTAG(29899): next:true
03-26 10:17:59.704: I/VideoPlayTAG(29899): output index:-1
03-26 10:17:59.714: I/VideoPlayTAG(29899): count=2
03-26 10:17:59.714: I/VideoPlayTAG(29899): sampleSize:131
03-26 10:17:59.714: D/VideoPlayTAG(29899): next:true
03-26 10:17:59.724: I/VideoPlayTAG(29899): output index:-1
03-26 10:17:59.724: I/VideoPlayTAG(29899): count=3
03-26 10:17:59.724: I/VideoPlayTAG(29899): sampleSize:59
03-26 10:17:59.724: D/VideoPlayTAG(29899): next:true
03-26 10:17:59.724: I/VideoPlayTAG(29899): output index:-2
03-26 10:17:59.744: D/VideoPlayTAG(29899): color=2141391875 width=320 height=180
03-26 10:17:59.744: I/JNI(29899): begin setRender 1734
03-26 10:17:59.744: I/JNI(29899): setRender
03-26 10:17:59.744: D/VideoPlayTAG(29899): output format has changed to {height=180, what=1869968451, color-format=2141391875, slice-height=192, crop-left=0, width=320, crop-bottom=179, crop-top=0, mime=video/raw, stride=384, crop-right=319}
03-26 10:17:59.744: I/VideoPlayTAG(29899): count=4
任何人都可以帮助我吗? 我发现问题可能是由软件渲染和硬件渲染的差异造成的。
答案 0 :(得分:1)
仍然看不出问题,一切看起来都不错。