Hi, I am trying to read a mp4 file via gstreamer in opencv 3.3.1 using python 3.6.8. With JetPack 4.2.1 I was able to successfully read the file using the following code, with 4.2.2 it no longer works.
Is the pipeline meant to change?? What could be wrong?
from imutils.video import FPS
import imutils
import time
import cv2
# Read mp4 via gstreamer pipeline
cap = cv2.VideoCapture('filesrc location=Calibration_footage.mp4 ! qtdemux ! queue ! h264parse ! omxh264dec ! nvvidconv ! video/x-raw,format=BGRx ! queue ! videoconvert ! queue ! video/x-raw, format=BGR ! appsink', cv2.CAP_GSTREAMER)
fps = FPS().start()
while cap.isOpened():
ret_val, img = cap.read()
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
cv2.imshow('CSI Camera',img)
cv2.imshow('Gray', gray)
fps.update()
if cv2.waitKey(1) & 0xFF == ord('q'):
break
fps.stop()
print("[INFO] elapsed time: {:.2f}".format(fps.elapsed()))
print("[INFO] approx. FPS: {:.2f}".format(fps.fps()))
cap.release()
cv2.destroyAllWindows()
This is the error i get
OpenCV Error: Unspecified error (GStreamer: unable to start pipeline
) in cvCaptureFromCAM_GStreamer, file /home/nvidia/build_opencv/opencv/modules/videoio/src/cap_gstreamer.cpp, line 887
VIDEOIO(cvCreateCapture_GStreamer (CV_CAP_GSTREAMER_FILE, filename)): raised OpenCV exception:
/home/nvidia/build_opencv/opencv/modules/videoio/src/cap_gstreamer.cpp:887: error: (-2) GStreamer: unable to start pipeline
in function cvCaptureFromCAM_GStreamer
[INFO] elapsed time: 0.00
[INFO] approx. FPS: 0.00
Segmentation fault (core dumped)