PyeIQ OpenCV Issue: GStreamer warning: unable to query duration of stream

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

PyeIQ OpenCV Issue: GStreamer warning: unable to query duration of stream

8,333 Views
nxf50230
NXP Employee
NXP Employee

Hi,

i want to test the PyeIQ framework with a custom video/webcam but OpenCV returns a warning and the video with the inference results is not displayed. Here is the console output:

INFO: Created TensorFlow Lite delegate for NNAPI.
Applied NNAPI delegate.
====== VPUDEC: 4.5.5 build on Jul 17 2020 18:09:12. ======
wrapper: 3.0.0 (VPUWRAPPER_ARM64_LINUX Build on Jul 17 2020 16:50:14)
vpulib: 1.1.1
firmware: 1.1.1.0
[ WARN:0] global /usr/src/debug/opencv/4.2.0.imx-r0/git/modules/videoio/src/cap_gstreamer.cpp (898) open OpenCV | GStreamer warning: unable to query duration of stream
[ WARN:0] global /usr/src/debug/opencv/4.2.0.imx-r0/git/modules/videoio/src/cap_gstreamer.cpp (935) open OpenCV | GStreamer warning: Cannot query video position: status=1, value=27, duration=-1
Your video device could not capture any image.

The same warnings also appear when i run the switch_video app but the video with the object detection frames is displayed correctly. 

I also tested just OpenCV in python with a USB webcam and video file. It returns the same warnings and doesn't display the stream. 

When i use the following GStreamer command, the video file and webcam stream are displayed correctly:

gst-launch-1.0 filesrc location=<my filepath> typefind=true ! video/quicktime ! aiurdemux ! queue max-size-time=0 ! vpudec ! autovideosink

I am using the PyeIQ framework on an i.MX8M Plus with the Zeus Yocto version 5.4.24-2.1.0. The OpenCV Version is 4.2.0

Any ideas what the problem could be?

0 Kudos
3 Replies

8,157 Views
hiep_nguyen
Contributor III

Hi @nxf50230 ,

I could capture webcam and video using OpenCV VideoCapture with BSP 5.4.47-2.2.0 and BSP 5.4.24-2.1.0 finally.

By adding some opencv debug : export OPENCV_VIDEOIO_DEBUG=1 and OPENCV_LOG_LEVEL=DEBUG, the OpenCV VideoCapture use FFMPEG by default but FFMPEG doesn't exist on this BSP.

```
[ INFO:0] global /usr/src/debug/opencv/4.2.0.imx-r0/git/modules/videoio/src/backend_plugin.cpp (342) getPluginCandidates VideoIO pluigin (FFMPEG): glob is 'libopencv_videoio_ffmpeg*.so', 1 location(s)
[ INFO:0] global /usr/src/debug/opencv/4.2.0.imx-r0/git/modules/videoio/src/backend_plugin.cpp (349) getPluginCandidates - /usr/lib: 0
[ INFO:0] global /usr/src/debug/opencv/4.2.0.imx-r0/git/modules/videoio/src/backend_plugin.cpp (353) getPluginCandidates Found 0 plugin(s) for FFMPEG
[ WARN:0] global /usr/src/debug/opencv/4.2.0.imx-r0/git/modules/videoio/src/cap.cpp (128) open VIDEOIO(FFMPEG): backend is not available (plugin is missing, or can't be loaded due dependencies or it is not compatible)

```


So just change the cv::VideoCapture backend to Gstreamer, I could open video and webcam.

```
cv::VideoCapture cap(1, cv::CAP_GSTREAMER);

```

However, the VideoCapture took huge time, up to 50ms to grab a 1280x720 frame. I don't know why they need lots of time to grab a frame, and don't think it is normal. Suspecting it could be a bug.

 

8,236 Views
hiep_nguyen
Contributor III

Hi @nxf50230 ,

I met the same issue like you with IMX.8 Plus, Yocto package : bsp-5_4_24-2_1_0. Tried to change VideoCapture backend to V4L but it couldn't open camera as well.

Did you solve the issue ? Do you have any ideas ?

 

0 Kudos

8,199 Views
nxf50230
NXP Employee
NXP Employee

Hi @hiep_nguyen,

no, so far i haven't further investigated this issue. My suspicion was that the gstreamer pipeline was not configured correctly for my camera/video file. Please let me know if you find out more. 

0 Kudos