NvMedia video encoder RGBA surface input

The documentation says that NvMedia video encoders can take RGB frames as input. However, when I try to create such an encoder instance it fails and “Invalid input format specified” is output.
How do I do this? Is there an example somewhere?

Example code:

#include <nvmedia_iep.h>
#include <cassert>

int main()
{
	NvMediaDevice* device = NvMediaDeviceCreate();

	NvMediaSurfFormatAttr attributes[7];
	NVM_SURF_FMT_SET_ATTR_RGBA(attributes, RGBA, UINT, 8, PL);
	uint32_t format = NvMediaSurfaceFormatGetType(attributes, 7);

	NvMediaEncodeInitializeParamsH264 params{};
	params.encodeWidth = 1920;
	params.encodeHeight = 1208;
	params.frameRateNum = 30;
	params.frameRateDen = 1;

	NvMediaIEP* handle = NvMediaIEPCreate(device, NVMEDIA_IMAGE_ENCODE_H264, &params, format, 2, 2, NVMEDIA_ENCODER_INSTANCE_AUTO);
	assert(handle);
}

Hi raul.tambre,

You can check NvMediaIEPCreate() API in the docs and only yuv formats are supported. Thanks!

Thanks for the clarification!

The documentation for “Video Encode” should be updated to remove RGB as an accepted input.
NvMediaIEPFeedFrame() also says that sourceRect is only valid for RGB inputs.
Seems really strange for there to be so many places in documentation that talk about RGB. Including parameters only applicable to it…

Thanks for pointing out the inconsistency! We will review these docs.

Hi @raul.tambre, we have improved the docs. It will be available along with the next release. Thanks!

1 Like

Great to hear. Thank you!
I’ve made another thread pointing out more problems in the NvMedia documentation.