Android: MPEG4Writer fails to start when using OMXCodec as MediaSource

家住魔仙堡 提交于 2019-12-04 14:54:41

I just figured out my (dumb) issue: I was calling start() on mVideoEncoder (the OMXCodec instance) before calling start() on MPEG4Writer, and this was giving the UNKNOWN_ERROR.

I solved by calling start() only on MPEG4Writer instance.

There is an error that I think is important:

omxEncMeta->setInt32(kKeyBitRate, frameRate); // should set bitrate, 24 is too small

also

omxEncMeta->setInt32(kKeySampleRate, frameRate); // i don't think is of any use

Then: make sure your source returns this

virtual sp<MetaData> getFormat() {
    sp<MetaData> meta = new MetaData;
    meta->setInt32(kKeyWidth, mWidth);
    meta->setInt32(kKeyHeight, mHeight);
    meta->setInt32(kKeyColorFormat, mColorFormat);
    meta->setCString(kKeyMIMEType, MEDIA_MIMETYPE_VIDEO_RAW);
    return meta;
}

The MediaBuffer you return from source should be the right size: 480*360*4(i think that is the case).

You should provide the adb logcat output: adb.exe logcat OMXClient:V OMXCodec:V *:W

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!