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
Unfortunately, I am not allowed to upload the video publicly.
Do you know what causes the error shown in the terminal?
It occurs at cap = cv.VideoCapture('video.avi')
It seems to be a gstreamer problem, but Totem can play the video correctly.
well yes, the video has a weird horizontal resolution, and whatever decodes the video doesn’t handle that properly.
it’s definitely a bug, but you decide if you want to fix your video to have a size that’s divisible by a certain number (powers of two are popular), or if you want to dig into some source code.
if you want to submit it as an issue for others to deal with, you HAVE TO provide data to reproduce the issue. a screenshot is not enough.
Like crackwitz has pointed out rightly, the horizontal resolution (image width) is not correct. It must be divisible by 4 for OpenCV to process it correctly.