Duplicate frames in saved file from cv2.VideoWriter

asked 2020-12-02 09:38:34 -0600

amateurpirate gravatar image

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

edit retag flag offensive close merge delete

Comments

if you have a 150fps video, try to use cv2.waitKey(15000) Does this help?

supra56 gravatar imagesupra56 ( 2020-12-02 10:06:10 -0600 )edit

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.

crackwitz gravatar imagecrackwitz ( 2020-12-02 14:14:48 -0600 )edit

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.

crackwitz gravatar imagecrackwitz ( 2020-12-02 14:15:53 -0600 )edit