简体   繁体   English

VideoCapture 发布 - 无法分配缓冲区 (V4l2src) Jetson NX

[英]VideoCapture Release - Failed to Allocate Buffers (V4l2src) Jetson NX

I'm using a v4l2sink in gstreamer to tee a video stream that I can access in OpenCV.我在 gstreamer 中使用 v4l2sink 来播放可以在 OpenCV 中访问的视频流。 This works when I open the videocapture device and get frames, however at some point I want to release the capture device and reopen it later in the program.这在我打开视频捕获设备并获取帧时有效,但是在某些时候我想释放捕获设备并稍后在程序中重新打开它。 When I release the device, I get the following errors:当我释放设备时,我收到以下错误:

[ WARN:7] global /tmp/build_opencv/opencv/modules/videoio/src/cap_gstreamer.cpp (488) isPipelinePlaying OpenCV | GStreamer warning: unable to query pipeline state
[ WARN:7] global /tmp/build_opencv/opencv/modules/videoio/src/cap_gstreamer.cpp (1761) handleMessage OpenCV | GStreamer warning: Embedded video playback halted; module v4l2src0 reported: Failed to allocate a buffer

I open the capture device like so:我像这样打开捕获设备:

cap = cv2.VideoCapture("v4l2src device=/dev/video3 ! nvvidconv ! video/x-raw(memory:NVMM) ! nvvidconv ! video/x-raw,format=BGRx ! videoconvert ! video/x-raw,format=BGR ! appsink drop=1 max-buffers=2")

release it like by using cap.release() and my gstreamer pipeline is:使用cap.release()释放它,我的 gstreamer 管道是:

"gst-launch-1.0 v4l2src device=/dev/video2 ! video/x-raw,format=YUY2,width=2560,height=720,framerate=60/1 ! tee name=t ! queue ! xvimagesink sync=0 brightness=50 t. ! queue ! v4l2sink device=/dev/video3"

I create the v4l2loopback device using:我使用以下方法创建 v4l2loopback 设备:

sudo modprobe v4l2loopback video_nr=3 max_buffers=2

I had to specify max_buffers=2 because I was facing the same issue as this post: Gstreamer v4l2src failed to allocate buffer when run on a Jetson Nano where I got the failed to allocate buffers error at the start.我必须指定 max_buffers=2 因为我遇到了与这篇文章相同的问题: Gstreamer v4l2src 在 Jetson Nano 上运行时无法分配缓冲区,在开始时我遇到了无法分配缓冲区的错误。

The main issue arises when I try to reopen the pipeline and capture device, because gstreamer gives me a reason not negotiated error.当我尝试重新打开管道和捕获设备时出现主要问题,因为 gstreamer 给了我一个未协商错误的原因。

不确定您的情况,但我会尝试在 v4l2sink 之前为 v4l2loopback 节点添加identity drop-allocation=1

gst-launch-1.0 v4l2src device=/dev/video2 ! video/x-raw,format=YUY2,width=2560,height=720,framerate=60/1 ! tee name=t ! queue ! xvimagesink sync=0 brightness=50   t. ! queue ! identity drop-allocation=1 ! v4l2sink device=/dev/video3

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

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