IOCTL_REQBUFS error when using deepstream

Hello.
I am developing an application that receives real-time camera video using NVMM memory and deepstream pipeline in jetson AGX orin.
Problem is that I encounter IOCTL_REQBUFS error message whenever I set the state to GST_STATE_PLAYING after setting up the pipeline with gst_parse_launch.
However, if I set sleep 1 seconds before playing, it operates normally.
When operating normally, the NvMMLiteOpen message is displayed.
The problem seems to occur if the video is started before the memory used in the pipeline is allocated.
So, it would be nice to be able to know when memory allocation is finished in the pipeline or to receive messages related to NVMM.
Is there a way for this?

Hi, could you please share snippets that show how you are creating the pipeline?

code is like bellow:

gst_init(0,0);
std::string cfg = 
"nvstreammux name=m batch-size=1 live-source=1 width=1920 height=1080 nvbuf-memory-type=4 ! nvstreamdemux name=demux nvv4l2camerasrc device=/dev/video0 ! video/x-raw(memory:NVMM), width=1920, height=1080, format=UYVY ! videorate ! video/x-raw(memory:NVMM),framerate=15/1 ! nvvideoconvert compute-hw=2 nvbuf-memory-type=4 ! video/x-raw(memory:NVMM), format=NV12, colorimetry=bt601 ! m.sink_0 demux.src_0 ! nvv4l2h264enc ! video/x-h264, stream-format=(string)byte-stream, alignment=(string)au ! appsink name=ffmpeg_0"
GError *error = 0; 
GstElement *pipeline_ = gst_parse_launch(cfg.c_str(), &error);
//
// set app sink
//
gst_element_set_state(pipeline_, GST_STATE_PAUSED);
//sleep(1);
gst_element_set_state(pipeline_, GST_STATE_PLAYING);

Please provide complete information as applicable to your setup.

• Hardware Platform (Jetson / GPU)
• DeepStream Version
• JetPack Version (valid for Jetson only)
• TensorRT Version
• NVIDIA GPU Driver Version (valid for GPU only)
• Issue Type( questions, new requirements, bugs)
• How to reproduce the issue ? (This is for bugs. Including which sample app is using, the configuration files content, the command line used and other details for reproducing)
• Requirement details( This is for new requirement. Including the module name-for which plugin or for which sample application, the function description)

Hardware: Jetson AGX Orin
Deepstream version: 6.3
Jetpack version: 5.1.2
Issutype: questions

I installed Jetpack 5.1.2 by SDK manager just before.

• How to reproduce the issue ? (This is for bugs. Including which sample app is using, the configuration files content, the command line used and other details for reproducing)

In above code, error always occur after gst_element_set_state(pipeline_, GST_STATE_PLAYING);

What will happen if you run the following pipeline?

gst-launch-1.0 nvstreammux name=m batch-size=1 live-source=1 width=1920 height=1080 nvbuf-memory-type=4 ! nvstreamdemux name=demux nvv4l2camerasrc device=/dev/video0 ! video/x-raw(memory:NVMM), width=1920, height=1080, format=UYVY ! videorate ! video/x-raw(memory:NVMM),framerate=15/1 ! nvvideoconvert compute-hw=2 nvbuf-memory-type=4 ! video/x-raw(memory:NVMM), format=NV12, colorimetry=bt601 ! m.sink_0 demux.src_0 ! nvv4l2h264enc ! video/x-h264,stream-format=(string)byte-stream, alignment=(string)au ! appsink name=ffmpeg_0

There was a mistake when I transfer pipeline to this post because it doesn’t have ‘queue’. (my original code contains ‘queue’ statement)
So I tested as below code:

gst-launch-1.0 nvstreammux name=m batch-size=1 live-source=1 width=1920 height=1080 nvbuf-memory-type=4 ! nvstreamdemux name=demux nvv4l2camerasrc device=/dev/video0 ! video/x-raw(memory:NVMM), width=1920, height=1080, format=UYVY ! videorate ! video/x-raw(memory:NVMM),framerate=15/1 ! nvvideoconvert compute-hw=2 nvbuf-memory-type=4 ! video/x-raw(memory:NVMM), format=NV12, colorimetry=bt601 ! m.sink_0 demux.src_0 ! queue ! nvv4l2h264enc ! video/x-h264,stream-format=(string)byte-stream, alignment=(string)au ! appsink name=ffmpeg_0

result is this:

Setting pipeline to PAUSED ...
Opening in BLOCKING MODE 
Pipeline is live and does not need PREROLL ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock
NvMMLiteOpen : Block : BlockType = 4 
Redistribute latency...
===== NvVideo: NVENC =====
NvMMLiteBlockCreate : Block : BlockType = 4 
H264: Profile = 66, Level = 0 
NVMEDIA: Need to set EMC bandwidth : 423000 
NvVideo: bBlitMode is set to TRUE

Why do you set the pipeline to “PAUSED” state at the beginning? If you want to change the pipeline state step by step, please follow the state machine sequence as description in States.

I don’t know why, but it started to work.

  1. I changed the state to “Ready” first, and “Pause” later, it didn’t work.
  2. I changed the state to “Play” without “Pause” or “Ready”, it didn’t work.
  3. I tried (2) way, and add gst_element_get_state(pipeline, state, NULL, -1); after changing the state to “Play”, it worked!

Thank you for your hint and do you have any idea why it worked?

Hi,
It looks like certain state transition may not work properly while using nvv4l2camerasrc in DeepStream SDK. Since the plugin is open source, if you would like to check further, please download the source code and check.

@choi_giryong

You did not post the code after “gst_element_set_state(pipeline_, GST_STATE_PLAYING);”, can you post the complete code?

It’s almost same as original code.
I just remove step to pause, and add gst_element_get_state. (Well, this is just for checking status, but it worked)

gst_init(0,0);
std::string cfg = 
"nvstreammux name=m batch-size=1 live-source=1 width=1920 height=1080 nvbuf-memory-type=4 ! nvstreamdemux name=demux nvv4l2camerasrc device=/dev/video0 ! video/x-raw(memory:NVMM), width=1920, height=1080, format=UYVY ! videorate ! video/x-raw(memory:NVMM),framerate=15/1 ! nvvideoconvert compute-hw=2 nvbuf-memory-type=4 ! video/x-raw(memory:NVMM), format=NV12, colorimetry=bt601 ! m.sink_0 demux.src_0 ! queue ! nvv4l2h264enc ! video/x-h264, stream-format=(string)byte-stream, alignment=(string)au ! appsink name=ffmpeg_0"
GError *error = 0; 
GstElement *pipeline_ = gst_parse_launch(cfg.c_str(), &error);
//
// set app sink
//
gst_element_set_state(pipeline_, GST_STATE_PLAYING);
GstState state;
gst_element_get_state(pipeline_, &state, NULL, -1)

“gst_element_set_state()” is an unblocking function, you mustn’t exit the process right after “gst_element_set_state()”. Please refer to GStreamer document Basic tutorial 1: Hello world! (gstreamer.freedesktop.org) for the basic knowledge of GStreamer concept and coding.

Surely, process doesn’t end after “gst_element_set_state(pipeline_, GST_STATE_PLAYING);”.
I am sorry about that I cannot attach entire code because of complexity of original code and security problem.
In real code, “pipeline_” is member variable, so it doesn’t exit process.

Since you can’t provide your code, we don’t know what you have done. You can’t do anything to the elements in the pipeline directly in the main tread after set_state", everything should be done in another thread. I think there is no issue with DeepStream components since gst-launch command can work.

We will close this topic.