import cv2
filepath = “/home/nvidia/guoxiaolu/testvideo/v5_10.39.241.47.avi”
cap = cv2.VideoCapture(‘filesrc location={} ! qtdemux ! queue ! mpeg4videoparse ! omxmpeg4videodec ! nvvidconv ! video/x-raw,format=BGRx ! queue ! videoconvert ! queue ! video/x-raw, format=BGR ! appsink’.format(filepath), cv2.CAP_GSTREAMER)
print(cap.isOpened())
while True:
ret, frame = cap.read()
if not ret:
break
and it returns:
OpenCV(3.4.1-dev) Error: Unspecified error (GStreamer: unable to start pipeline
) in cvCaptureFromCAM_GStreamer, file /home/nvidia/opencv/modules/videoio/src/cap_gstreamer.cpp, line 890
VIDEOIO(cvCreateCapture_GStreamer (CV_CAP_GSTREAMER_FILE, filename)): raised OpenCV exception:
OpenCV(3.4.1-dev) /home/nvidia/opencv/modules/videoio/src/cap_gstreamer.cpp:890: error: (-2) GStreamer: unable to start pipeline
in function cvCaptureFromCAM_GStreamer
If I use command:
gst-launch-1.0 filesrc location=/home/nvidia/guoxiaolu/testvideo/v5_10.39.241.47.avi ! qtdemux ! queue ! mpeg4videoparse ! omxmpeg4videodec ! nvvidconv ! video/x-raw,format=BGRx ! queue ! videoconvert ! queue ! video/x-raw, format=BGR ! appsink
it returns:
Setting pipeline to PAUSED …
Pipeline is PREROLLING …
ERROR: from element /GstPipeline:pipeline0/GstQTDemux:qtdemux0: This file is invalid and cannot be played.
Additional debug info:
qtdemux.c(747): gst_qtdemux_pull_atom (): /GstPipeline:pipeline0/GstQTDemux:qtdemux0:
atom has bogus size 1380533830
ERROR: pipeline doesn’t want to preroll.
Setting pipeline to NULL …
Freeing pipeline …
This command is right:
gst-launch-1.0 playbin uri=file:///home/nvidia/guoxiaolu/testvideo/v5_10.39.241.47.avi
I used in Xavier agx, and compile opencv with gstreamer support
Video I/O:
DC1394: NO
FFMPEG: NO
avcodec: NO
avformat: NO
avutil: NO
swscale: NO
avresample: NO
GStreamer:
base: YES (ver 1.14.5)
video: YES (ver 1.14.5)
app: YES (ver 1.14.5)
riff: YES (ver 1.14.5)
pbutils: YES (ver 1.14.5)