简体   繁体   English

Gstreamer 管道仅适用于 sudo

[英]Gstreamer pipeline only works with sudo

I am running the following Gstreamer pipeline on a headless Ubuntu 20.04 LTS:我在无头 Ubuntu 20.04 LTS 上运行以下 Gstreamer 管道:

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.当我在它之前使用sudo时,相机开始成功录制视频。 However, without `sudo, I get the following error:但是,如果没有`sudo,我会收到以下错误:

====== 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我使用gst-inspect-1.0 | grep -i vpu gst-inspect-1.0 | grep -i vpu and I got the following: gst-inspect-1.0 | grep -i vpu我得到以下信息:

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 ?没有sudo可以做到吗?

The reason why this happens is that the VPU devices are owned by root.发生这种情况的原因是 VPU 设备归 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.我将当前用户添加到一个新组并将VPU设备的组更改为新组,然后更改该组的读写权限。

# 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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM