i.mx8mp - Use Gstreamer vpuenc_h264 without root

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

i.mx8mp - Use Gstreamer vpuenc_h264 without root

Jump to solution
895 Views
dh84
Contributor III

Hi, 

I have problems to run a Gstreamer pipeline including vpuenc_h264 as a "normal" user without root rights. With the root user the following pipeline runs without any problems:

 

GST_DEBUG=3 gst-launch-1.0 v4l2src device=/dev/video1 ! video/x-raw,width=1920,height=1080,format=YUY2,framerate=30/1 ! imxvideoconvert_g2d ! vpuenc_h264 ! fakesink

 

If I run the same pipeline as normal user I get the following error message:

 

Setting pipeline to PAUSED ...
====== VPUENC: 4.7.0 build on May 20 2022 06:51:21. ======
	wrapper: 3.0.0 (VPUWRAPPER_ARM64_LINUX Build on Jun  2 2022 08:51:59)
	vpulib: 1.1.1
	firmware: 1.1.1.43690
0:00:00.304720500   624 0xaaaabebc3c90 ERROR                default gstallocatorphymem.c:150:base_alloc: Allocate phymem 10485776 failed.

0:00:00.304755125   624 0xaaaabebc3c90 ERROR                default gstvpu.c:90:gst_vpu_allocate_internal_mem: Could not allocate memory using VPU allocator
0:00:00.304808250   624 0xaaaabebc3c90 ERROR                 vpuenc gstvpuenc.c:556:gst_vpu_enc_start:<vpuenc_h264-0> gst_vpu_allocate_internal_mem fail
0:00:00.304836375   624 0xaaaabebc3c90 WARN            videoencoder gstvideoencoder.c:1804:gst_video_encoder_change_state:<vpuenc_h264-0> error: Failed to start encoder
ERROR: from element /GstPipeline:pipeline0/vpuenc_h264:vpuenc_h264-0: Could not initialize supporting library.
Additional debug info:
../git/gst-libs/gst/video/gstvideoencoder.c(1804): gst_video_encoder_change_state (): /GstPipeline:pipeline0/vpuenc_h264:vpuenc_h264-0:
Failed to start encoder
ERROR: pipeline doesn't want to preroll.
Failed to set pipeline to PAUSED.
Setting pipeline to NULL ...
Freeing pipeline ...

 

I think the user is missing the rights to allocate memory. 

What I tried so far is to add the user to the video and kmem group. I also changed the group of /dev/mxc_hantro and /dev/mxc_hantro_vc8000e into video. But nothing helps.

Does anyone have an idea what the problem could be and what rights are necessary to get it running?

Thanks in advance!

Best regards,

Daniel

P.S. I'm using Yocto Kirkstone with Kernel 5.15.60

 

Labels (3)
0 Kudos
Reply
1 Solution
851 Views
dh84
Contributor III

Ok, now it's working. Additionally to the mxc_hantro devices I had to set user write permissions for linux,cma.

chgrp video /dev/dma_heap/linux,cma
chmod 660 /dev/dma_heap/linux,cma
chgrp video /dev/dma_heap/linux,cma-uncached
chmod 660 /dev/dma_heap/linux,cma-uncached

 

Best regards,

Daniel

View solution in original post

0 Kudos
Reply
3 Replies
858 Views
dh84
Contributor III

Hi @Dhruvit ,

thanks for your reply.

Please check the permissions of the device nodes for the VPU encoder. make sure it is set to rw to owner & group and nothing to others.

As I've written in my first post, I already tried to change the group of the vpu encoder device nodes into video, but it still doesn't work.

chgrp video /dev/mxc_hantro
chgrp video /dev/mxc_hantro_vc8000e
chmod 660 /dev/mxc_hantro
chmod 660 /dev/mxc_hantro_vc8000e
usermod -a -G video user

Are there any additional devices related to the encoder I need to consider?

Please try to run the pipeline with the v4l2src element instead of the imxv4l2src element.
The v4l2src element is a more generic video source element that may not have the same permissions requirements as the imxv4l2src element.

I'm already using the v4lsrc element (I don't have another one) and I have the same issue if I replace the v4l2src with the videotestsrc element.

One can also try to run the GStreamer using the sudo command which will give it all permission

Unfortunately this isn't really an option, because the user must be restricted in his permissions. Furthermore in the next step the user won't user gst-launch. Instead the gstreamer pipeline is built in python using the appropriate libs.

Any further suggestions?

Thank and best regards,

Daniel

0 Kudos
Reply
852 Views
dh84
Contributor III

Ok, now it's working. Additionally to the mxc_hantro devices I had to set user write permissions for linux,cma.

chgrp video /dev/dma_heap/linux,cma
chmod 660 /dev/dma_heap/linux,cma
chgrp video /dev/dma_heap/linux,cma-uncached
chmod 660 /dev/dma_heap/linux,cma-uncached

 

Best regards,

Daniel

0 Kudos
Reply
875 Views
Dhruvit
NXP TechSupport
NXP TechSupport

Hi @dh84,

I hope you are doing well.

from the logs, it is seen that gpu couldn't allocate memory to vpu.
Please check the permissions of the device nodes for the VPU encoder. make sure it is set to rw to owner & group and nothing to others.

Please try to run the pipeline with the v4l2src element instead of the imxv4l2src element.
The v4l2src element is a more generic video source element that may not have the same permissions requirements as the imxv4l2src element.

One can also try to run the GStreamer using the sudo command which will give it all permission.

Thanks & Regards,
Dhruvit Vasavada

0 Kudos
Reply