Unable to record video from CSI camera using nvv4l2h265enc

I’m trying to record a video from my CSI camera using the following pipeline:

gst-launch-1.0 -e nvarguscamerasrc sensor-id=0 ! 'video/x-raw(memory:NVMM), width=(int)4032, height=(int)3040, framerate=10/1, format=(string)NV12' ! nvv4l2h265enc ! h265parse ! qtmux ! filesink location=demo.mp4

I get the following error:

Setting pipeline to PAUSED ...
ERROR: Pipeline doesn't want to pause.
ERROR: from element /GstPipeline:pipeline0/nvv4l2h265enc:nvv4l2h265enc0: Could not open device '/dev/nvhost-msenc' for reading and writing.
Additional debug info:
/dvs/git/dirty/git-master_linux/3rdparty/gst/gst-v4l2/gst-v4l2/v4l2_calls.c(651): gst_v4l2_open (): /GstPipeline:pipeline0/nvv4l2h265enc:nvv4l2h265enc0:
system error: No such file or directory
Setting pipeline to NULL ...
Freeing pipeline ...

Here is some info about the devices:

orin@orin:~$ ls -lah /dev/nvhost-*
crw-rw---- 1 root video 504,  0 Aug 23 09:56 /dev/nvhost-as-gpu
crw-rw---- 1 root video 508,  0 Mar 27 19:54 /dev/nvhost-ctrl
crw-rw---- 1 root video 504,  2 Aug 23 09:56 /dev/nvhost-ctrl-gpu
crw-rw---- 1 root video 508, 54 Mar 27 19:54 /dev/nvhost-ctrl-isp
crw-rw---- 1 root video 508, 22 Mar 27 19:54 /dev/nvhost-ctrl-nvdec
crw-rw---- 1 root video 508, 50 Mar 27 19:54 /dev/nvhost-ctrl-nvdla0
crw-rw---- 1 root video 508, 46 Mar 27 19:54 /dev/nvhost-ctrl-pva0
crw-rw---- 1 root debug 504,  3 Aug 23 09:56 /dev/nvhost-ctxsw-gpu
crw-rw---- 1 root debug 504,  4 Aug 23 09:56 /dev/nvhost-dbg-gpu
crw-rw---- 1 root video 504,  1 Aug 23 09:56 /dev/nvhost-gpu
crw-rw---- 1 root video 508, 53 Mar 27 19:54 /dev/nvhost-isp
crw-rw---- 1 root video 508, 41 Mar 27 19:54 /dev/nvhost-isp-thi
crw-rw---- 1 root video 508, 13 Mar 27 19:54 /dev/nvhost-msenc
crw-rw---- 1 root video 508, 29 Mar 27 19:54 /dev/nvhost-nvcsi
crw-rw---- 1 root video 508, 21 Mar 27 19:54 /dev/nvhost-nvdec
crw-rw---- 1 root video 508, 49 Mar 27 19:54 /dev/nvhost-nvdla0
crw-rw---- 1 root video 508,  5 Mar 27 19:54 /dev/nvhost-nvjpg
crw-rw---- 1 root video 508,  9 Mar 27 19:54 /dev/nvhost-nvjpg1
crw-rw---- 1 root video 504,  9 Aug 23 09:56 /dev/nvhost-nvsched-gpu
crw-rw---- 1 root video 508, 17 Mar 27 19:54 /dev/nvhost-ofa
crw-rw---- 1 root video 507,  0 Mar 27 19:54 /dev/nvhost-power-gpu
crw-rw---- 1 root debug 504,  6 Aug 23 09:56 /dev/nvhost-prof-ctx-gpu
crw-rw---- 1 root debug 504,  7 Aug 23 09:56 /dev/nvhost-prof-dev-gpu
crw-rw---- 1 root debug 504,  5 Aug 23 09:56 /dev/nvhost-prof-gpu
crw-rw---- 1 root video 508, 45 Mar 27 19:54 /dev/nvhost-pva0
crw-rw---- 1 root root  504,  8 Aug 23 09:56 /dev/nvhost-sched-gpu
crw-rw---- 1 root video 508, 25 Mar 27 19:54 /dev/nvhost-tsec
crw-rw---- 1 root video 504, 10 Aug 23 09:56 /dev/nvhost-tsg-gpu
crw-rw---- 1 root video 508, 57 Mar 27 19:54 /dev/nvhost-vi0
crw-rw---- 1 root video 508, 33 Mar 27 19:54 /dev/nvhost-vi0-thi
crw-rw---- 1 root video 508, 61 Mar 27 19:54 /dev/nvhost-vi1
crw-rw---- 1 root video 508, 37 Mar 27 19:54 /dev/nvhost-vi1-thi
crw-rw---- 1 root video 508,  1 Mar 27 19:54 /dev/nvhost-vic

I can confirm that the camera is working and I get valid frames, but when I try to use the nvv4l2h265enc encoder I get this error.

I tried to fall back to using x265enc instead but there are incompatible caps with that one and the nvarguscamerasrc component.

EDIT: The same launch string works on the Xavier NX board. However, I’ve been using omxh265enc on that platform but since this encoder has been removed from the JP version the Orin is running, I’m trying to use the other encoder.

Hi,
We don’t hit the issue on Orin NX/Jetpack 5.1.2. Please clean the cache and try again:

$ rm .cache/gstreamer-1.0/registry.aarch64.bin

And may try with videotestsrc:

$ gst-launch-1.0 -e videotestsrc is-live=1 ! nvvidconv ! nvv4l2h265enc ! h265parse ! qtmux ! filesink location=a.mp4

If the issue is still present, we would suggest reflash the system through SDKManager.

Hello,

Thank you for your suggestions.

I had JP 5.1.1 where the issue was present. I upgraded to 5.1.2 and tried your proposed pipeline, but I still get the same error related to the /dev/nvhost-msenc device.

I will try reflashing the Jetson with JP 5.1.2 and report back.

Be sure you have an Orin NX, not an Orin Nano. The latter doesn’t have NVENC.
You may check with:

cat /sys/devices/soc0/soc_id

# Or
sudo dmesg | grep "Machine model"

Reflashing the Orin fixed the problem. Not sure what it was originally, but now it works.

Sorry for everyone who has the same issue. Try reflashing your device ;-)