【发布时间】:2015-02-04 08:48:46
【问题描述】:
我正在使用 stagefright videoencoder 在 android 4.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)?
【问题讨论】:
标签: android stagefright