title: How do i find the fps of a video (even if i pause) in python & opencv?
body: <p>I'm processing a video in opencv&amp;python and i want to find the current fps in each frame but sometimes i need to stop the video and continue after few seconds, the problem is that everytime i stop the video the fps decreases.
  Where is the problem?</p>
  
  <pre><code>import cv2
  import time
  
  frame_id = 0
  starting_time = time.time()
  elapsed_time_pause = 0
  cap = cv2.VideoCapture(0)
  while True:    
      _, frame = cap.read()    
      frame_id += 1
  
      #... some processing ...
  
      elapsed_time = time.time() - starting_time - elapsed_time_pause
      fps = frame_id / elapsed_time
  
      cv2.putText(frame, "FPS: " + str(round(fps, 2)), (10, 15), cv2.FONT_HERSHEY_SIMPLEX, 0.5, (255, 255, 0), 2) #print del FPS
      cv2.putText(frame, "frame id: " + str(frame_id), (10, 30), cv2.FONT_HERSHEY_SIMPLEX, 0.5, (255, 255, 0), 2)
      elapsed_time_pause = 0
  
      cv2.imshow('frame', frame)
      key = cv2.waitKey(1)
      if key == ord('p'):    
          starting_time_pause = time.time()
          cv2.waitKey(0)
          elapsed_time_pause = time.time() - starting_time_pause 
      elif key == ord('q'): break
  
  cap.release()   
  cv2.destroyAllWindows() 
  </code></pre>