Reputation: 342
I am running the following Gstreamer pipeline on a headless Ubuntu 20.04 LTS:
gst-launch-1.0 v4l2src ! video/x-raw,width=640,height=480,framerate=30/1 ! vpuenc_h264 bitrate=500 ! avimux ! filesink location='vid.avi'
When I use sudo
before it, the camera starts recording the video successfully. However, without `sudo, I get the following error:
====== VPUENC: 4.5.5 build on Aug 4 2020 21:46:19. ====== wrapper: 3.0.0 (VPUWRAPPER_ARM64_LINUX Build on Aug 4 2020 21:45:37) vpulib: 1.1.1 firmware: 1.1.1.43690 0:00:00.054172250 1474 0xaaaac8897000 ERROR default gstallocatorphymem.c:149:base_alloc: Allocate phymem 4194320 failed. 0:00:00.054212750 1474 0xaaaac8897000 ERROR default gstvpu.c:90:gst_vpu_allocate_internal_mem: Could not allocate memory using VPU allocator 0:00:00.054236000 1474 0xaaaac8897000 ERROR vpuenc gstvpuenc.c:543:gst_vpu_enc_start:<vpuenc_h264-0> gst_vpu_allocate_internal_mem fail 0:00:00.054260875 1474 0xaaaac8897000 WARN videoencoder gstvideoencoder.c:1643:gst_video_encoder_change_state:<vpuenc_h264-0> error: Failed to start encoder 0:00:00.054321250 1474 0xaaaac8897000 INFO GST_ERROR_SYSTEM gstelement.c:2140:gst_element_message_full_with_details:<vpuenc_h264-0> posting message: Could not initialize supporting library. 0:00:00.054391000 1474 0xaaaac8897000 INFO GST_ERROR_SYSTEM gstelement.c:2167:gst_element_message_full_with_details:<vpuenc_h264-0> posted error message: Could not initialize supporting library. 0:00:00.054416250 1474 0xaaaac8897000 INFO GST_STATES gstelement.c:2960:gst_element_change_state:<vpuenc_h264-0> have FAILURE change_state return 0:00:00.054438375 1474 0xaaaac8897000 INFO GST_STATES gstelement.c:2547:gst_element_abort_state:<vpuenc_h264-0> aborting state from READY to PAUSED 0:00:00.054464625 1474 0xaaaac8897000 INFO GST_STATES gstbin.c:2968:gst_bin_change_state_func:<pipeline0> child 'vpuenc_h264-0' failed to go to state 3(PAUSED)
I inspected the plugins using gst-inspect-1.0 | grep -i vpu
and I got the following:
vpu: vpuenc_h264: IMX VPU-based AVC/H264 video encoder
vpu: vpuenc_vp8: IMX VPU-based VP8 video encoder
vpu: vpudec: IMX VPU-based video decoder
Is is possible to do it without sudo
?
Upvotes: 2
Views: 1663
Reputation: 342
The reason why this happens is that the VPU devices are owned by root. I added the current user to a new group and changed the group of the VPU devices to the new group then I changed the permission of the group to read and write.
# change the VPU devices group to a group called video
sudo chgrp video /dev/mxc_*
sudo chgrp video /dev/ion
# grant read and write permissions to the group
sudo chmod 660 /dev/mxc_*
sudo chmod 660 /dev/ion
Upvotes: 2