Duplicate frames in saved file from cv2.VideoWriter
Setup specs can be found below.
My VideoWriter writes @120fps, but the written video file has a repeated frame in it every 6 frames or so. This makes the true fps of the written video file closer to 100fps. When I use AmCap to record video there are no skipped frames.
I was wondering if anyone has any ideas as to how I could get those last 20 frames using OpenCV.
Additional notes: - Using Python - I had to set cv2.CAP_PROP_FPS to 150 to get the VideoWriter to write at 120. When I set it at 120 the file would not write. - I'm writing grayscale images and doing the conversion to gray in my main while loop. - I'm using a multithreaded approach
Windows 10, 64 bit Intel i5 3rd gen (circa 2012) $25 cheap USB webcam from Chinese manufacturer 1280*720@120fps
if you have a 150fps video, try to use
cv2.waitKey(15000)
Does this help?post your code, or the pieces that could be relevant. the VideoWriter is likely not at fault, but something else is going on. I suspect errors in how multithreading is used.
setting CAP_PROP_FPS on a VideoWriter object is purely metadata. the VideoWriter always writes as fast as possible, which depends on the complexity of the video codec and your computer's computing power.