Gstreamer h.264 encoding failed when mipi csi-2 camera driver using use_sensor_mode_id mode


I have a csi-2 camera that does not support continuous frame rate adjustment, only a few specific modes.
After some research, I used the use_sensor_mode_id method to set the camera’s working mode directly, and it works fine in PREVIEW.

v4l2-ctl -d /dev/video0 --set-ctrl sensor_mode=0
v4l2-ctl -d /dev/video0 --set-ctrl preferred_stride=5376
gst-launch-1.0 nvv4l2camerasrc device=/dev/video0 ! "video/x-raw(memory:NVMM),format=(string)UYVY,width=(int)2592,height=(int)1944" ! nvvidconv ! "video/x-raw(memory:NVMM),format=(string)I420" ! fpsdisplaysink video-sink=fakesink -v

However, it failed when I tried to do h.264 encoded recording with the following command:

gst-launch-1.0 nvv4l2camerasrc num-buffers=300 ! "video/x-raw(memory:NVMM),format=(string)UYVY, width=(int)2592, height=(int)1944" ! nvvidconv ! "video/x-raw(memory:NVMM),format=(string)I420" ! omxh264enc qp-range=20,20:20,20:-1,-1 ! matroskamux ! queue ! filesink location=videoname.mkv

The error message as follow:

(gst-launch-1.0:9313): GStreamer-CRITICAL **: 15:08:25.848: gst_element_make_from_uri: assertion 'gst_uri_is_valid (uri)' failed
WARNING: erroneous pipeline: could not set property "num-buffers" in element "nvv4l2camerasrc0" to "300 !"

Are there any ideas to solve the problem? Any help or suggestions are appreciated.
PS: I use Jetpack4.6 on Xavier NX dev board.

We have deprecated omx plugins. Please try v4l2 plugins such as nvv4l2h264enc or nvv4l2h265enc.