Hey!
I’m using gstreamer to pull frames from a RTSP stream where the last element in my gstreamer looks like:
GstCaps *capsfilter_caps =
gst_caps_new_simple("video/x-raw(NVMM)",
"format", G_TYPE_STRING, "NV12_ER",
NULL);
On a new sample, I extract the dmabuf_id and then pass It to VPI to convert from NV_12ER to BGR
static VPIContext _ctx = NULL;
static VPIStream _stream = NULL;
GstFlowReturn new_sample(GstAppSink *sink, struct App *app)
{
GstSample *sample = gst_app_sink_pull_sample(sink);
if (!sample)
{
return GST_FLOW_ERROR;
}
GstBuffer *buffer = gst_sample_get_buffer(sample);
if (!buffer)
{
return GST_FLOW_ERROR;
}
GstMapInfo map;
if (gst_buffer_map(buffer, &map, GST_MAP_READ))
{
int dmabuf_fd;
ExtractFdFromNvBuffer(map.data, &dmabuf_fd);
NvBufferParams par;
NvBufferGetParams(dmabuf_fd, &par);
printf("DMA %i\n", dmabuf_fd);
if(!_ctx)
{
// Create our context.
vpiContextCreate(0, &_ctx);
// Activate it. From now on all created objects will be owned by it.
vpiContextSetCurrent(_ctx);
// Create the stream for the given backend.
vpiStreamCreate(VPI_BACKEND_CUDA, &_stream);
}
VPIImage inDmaVpi = NULL;
vpiImageCreateNvBufferWrapper(dmabuf_fd, NULL, 0 | VPI_EXCLUSIVE_STREAM_ACCESS, &inDmaVpi);
VPIImage outBgrImage = NULL;
vpiImageCreate(1280, 720, VPI_IMAGE_FORMAT_BGR8, 0, &outBgrImage);
int failState = vpiSubmitConvertImageFormat(_stream, VPI_BACKEND_CUDA, inDmaVpi, outBgrImage, NULL);
printf("STATE: %i\n", failState);
}
gst_buffer_unref(buffer);
return GST_FLOW_OK;
}
The problem is that vpiSubmitConvertImageFormat
keeps returning VPI_ERROR_NOT_IMPLEMENTED
. I’ve tried (NV12,NV_12ER,BGRx)->(RGB8/RGBA8/BGR8/BGRA8) and I get the same output.
Is it possible to grab a dmabuf_id
from a gstreamer pipeline and use VPI to do color conversions on it? I’ve tested this same code with NvBufferCreate()
and it works fine. If not, how do I successfully do this? Grabbing the DmaBuffer data and giving it to VPI to do color conversions.