OpenCV does not read Logitech C920 .wmv files
System used:
OpenCV = 4.1.1 (through opencv-python)
Operating System / Platform => Windows 10 64 Bit and Linux Mint 19.1
Detailed description:
Properties and frame indexes from videos recorded by the Logitech Webcam C920 are not properly read by OpenCV:
cv2.CAP_PROP_POS_MSEC returns 0.0 for a video that lasts 10.14 minutes.
cv2.CAP_PROP_FOURCC returns code 844516695.
cv2.CAP_PROP_FPS returns 1000 fps for videos that were recorded at 30 fps.
cv2.CAP_PROP_FRAME_COUNT returns 614126 frames. When decoding and counting them one by one gives 18416, a value that agrees with expected number of frames for a video of 10 minutes recorded at 30 fps.
Moreover, indexing frames by frame number results in wrong frame: for example, using this code you can display the frame number 60000, which doesnt exist:
import cv2
stream = cv2.VideoCapture('video.wmv')
frame_number = 60000
stream.set(0, frame_number)
ret, frame = stream.read()
cv2.imshow('', frame)
cv2.waitKey()
stream.release()
cv2.destroyAllWindows()
So in summary, apparently metadata from wmv videos recorded by Logitech webcam C920 cannot properly read (if it exists) by OpenCV.
Use following code and file to reproduce:
import cv2
stream = cv2.VideoCapture('video.wmv')
fps = stream.get(cv2.CAP_PROP_FPS)
total_frames = int(stream.get(cv2.CAP_PROP_FRAME_COUNT))
duration = stream.get(cv2.CAP_PROP_POS_MSEC)
fourcc = int(stream.get(cv2.CAP_PROP_FOURCC))
count = 0
while(True):
ret, frame = stream.read()
if not ret:
break
count += 1
stream.release()
cv2.destroyAllWindows()
Any ideas how to solve this?