我正在使用stagefright视频编码器在Android4.4中编码视频;
sp<AMessage> format = new AMessage;
format->setInt32("width", 1080);
format->setInt32("height", 1920);
format->setString("mime", "video/avc");
format->setInt32("color-format", OMX_COLOR_FormatYUV420Planar);
format->setInt32("bitrate", 1000000);
format->setFloat("frame-rate", 25);
format->setInt32("i-frame-interval", 5);
sp<MediaCodec> videoEncoder = MediaCodec::CreateByType(looper, "video/avc", true);
videoEncoder->configure(format, NULL, NULL,MediaCodec::CONFIGURE_FLAG_ENCODE);
videoEncoder->start();但当我打电话时:
status_t err = gSpVideoEncoder->dequeueOutputBuffer(&bufIndex, &offset, &size, &ptsUsec, &flags, kTimeout);我得到了:
err === INFO_FORMAT_CHANGED下一步,我打电话给:
sp<AMessage> newFormat;
videoEncoder->getOutputFormat(&newFormat);
uint32_t width = 0, height = 0;
newFormat->findInt32("width", (int32_t *)(&width));
newFormat->findInt32("height", (int32_t *)(&height));
fprintf(stderr, "new width: %d, height: %d\n", width, height)我得到了结果:
new width: 1088, height: 1920我很困惑(不是1080x1920),我是否应该向videoEncoder提供新的输入帧(1088x1920)?
发布于 2015-02-04 00:33:52
视频编码要求帧尺寸与16的倍数对齐,即宏块尺寸。高清分辨率,即1920年x 1080是一个特例,因为1080是而不是,是16的倍数。底层编码器期望客户端提供对齐的边界。
在这种情况下,您可以提供如下所示的数据。对于Luma,您必须对齐到16的倍数,对于Chroma,您必须对齐到8的倍数。剩下的像素可以预先填充零。
请注意:如果编码器能够作为编码分辨率处理1920年x 1080,则输出应该是很好的。如果编码器用1920 x 1088编码,您将在生成的比特流中观察到由于零填充而在图片底部的绿色带。
---------------------------------------------
| |
| |
| |
| Luma |
| 1920 x 1080 |
| filled into |
| a buffer of |
| 1920 x 1088 |
| |
| Last 8 lines could |
| be filled with zeroes |
| |
---------------------------------------------
-----------------------
| Cb |
| 960 x 540 |
| filled into |
| a buffer of |
| 960 x 544 |
| |
-----------------------
-----------------------
| Cr |
| 960 x 540 |
| filled into |
| a buffer of |
| 960 x 544 |
| |
-----------------------https://stackoverflow.com/questions/28291204
复制相似问题