Incorrect total frames read using FFMPEG (Bug #851)


Added by Troy Sobotka about 14 years ago. Updated over 12 years ago.


Status:Done Start date:
Priority:High Due date:
Assignee:- % Done:

0%

Category:highgui-video
Target version:-
Affected version: Operating System:
Difficulty: HW Platform:
Pull request:

Description

Summary: When using QueryFrame via Python, the total frames read before a None result is incorrect when compared with total frames in the file.


History

Updated by Andrey Morozov over 13 years ago

if 1:
   # c interface
   import cv

   cap = cv.CaptureFromFile('c:/1.avi') # total 100 frames

   print (cv.GetCaptureProperty(cap, cv.CV_CAP_PROP_FRAME_COUNT))

   for i in range(1, 1001):
     frame = cv.QueryFrame(cap)
     if not frame: break
     print i

   print "END" 
else:

   # c++ interface
   import cv2, cv

   cap = cv2.VideoCapture('c:/1.avi') # total 100 frames

   print (cap.get(cv.CV_CAP_PROP_FRAME_COUNT))

   for i in range(1, 1001):
     retval, frame = cap.read()

     if not retval: break
     print (i, frame.shape)

   print "END" 

### output ### 
97
98
99
100
END

working in the latest version

  • Status changed from Open to Done
  • (deleted custom field) set to obsolete

Updated by Andrey Kamaev over 12 years ago

  • Category changed from highgui-images to highgui-video

Also available in: Atom PDF