title: How to add a delay when saving video frames as images
body: <p>I have a series of videos and I want to save frames from them as images. This is my code:</p>
  <pre><code>import os, cv2
  
  current_dir = os.getcwd()
  training_videos = '../../Videos/training_videos/'
  
  if not os.path.exists(current_dir + '/training_images/'):
      os.mkdir(current_dir + '/training_images/')
  
  for i in os.listdir(training_videos):
  
      video = cv2.VideoCapture('../../Videos/training_videos/' + i)
  
      currentFrame = 0
  
      while (True):
          # Capture frame-by-frame
          ret, frame = video.read()
  
          # Saves image of the current frame in jpg file
          name = current_dir + '/training_images/frame' + str(currentFrame) + '.png'
          print('Creating...' + name)
          cv2.imwrite(name, frame)
  
          # To stop duplicate images
          currentFrame += 1
  </code></pre>
  <p>This code works but unfortunately, it takes a frame at every millisecond. This is not something I want. Instead, I want to save a frame at every 5 or 10 seconds. I thought about adding a time delay but that wouldn't really work because the videos are not live streams so after 5 seconds, it'll just take the screenshot right after the previous millisecond.</p>