When opening a video in Python with OpenCV, the video is shown incorrectly.
Wrong result in OpenCV:
The face in above picture is covered because of privacy.
import numpy as np
import cv2 as cv
cap = cv.VideoCapture('video.avi')
while cap.isOpened():
ret, frame = cap.read()
# gray = cv.cvtColor(frame, cv.COLOR_BGR2GRAY)
cv.imshow('frame', frame)
if cv.waitKey(1) & 0xFF == ord('q'):
break
cap.release()
cv.destroyAllWindows()
Terminal shows the following error
(python:xxxx): GStreamer-CRITICAL **: xx:xx:xx.xxx: gst_query_set_position: assertion 'format == g_value_get_enum (gst_structure_id_get_value (s, GST_QUARK (FORMAT)))' failed
[ WARN:0] global /builddir/build/BUILD/opencv-4.3.0/modules/videoio/src/cap_gstreamer.cpp (935) open OpenCV | GStreamer warning: Cannot query video position: status=1, value=-1, duration=3000
QSocketNotifier: Can only be used with threads started with QThread
OS: Fedora 33
Python: 3.9.1
OpenCV: 4.3.0
Gstreamer: 1.18.2