Video frames problem

asked 2020-05-10 10:30:21 -0600

trsh gravatar image

updated 2020-05-10 11:53:28 -0600

I'm going trough frames like this:

cap = cv2.VideoCapture(instance.video_file.path)
while(cap.isOpened()):
        # Capture frame-by-frame
        ret, frame = cap.read()
        if ret == True:
            # some logic
        else: 
            break

what gives me 168 frames. But the when inspecting the video in players it has 173 frames (06.933 sec, 25 FPS). Where could this difference come from? Its messing up my work :(

Edit:

Even more stranger - video.get(cv2.CAP_PROP_FRAME_COUNT) shows 172 frames. So it shows 172 frames, but can read further then 168. Why?

Edit 2

I reported a bug. Any workarounds greatly appreciated!!!

edit retag flag offensive close merge delete