title: Convert Video to Frames in Python - 1 FPS
body: <p>I have a video that is 30 fps.
  <strong>I need to extract frames from the video at 1 FPS.</strong> How is this possible in Python?</p>
  <p>I have the below code I got from online but I am not sure if its extracting frames in 1 FPS.
  Please help!</p>
  <pre><code># Importing all necessary libraries 
  import cv2 
  import os 
    
  # Read the video from specified path 
  cam = cv2.VideoCapture(&quot;C:\\Users\\Admin\\PycharmProjects\\project_1\\openCV.mp4&quot;) 
    
  try: 
        
      # creating a folder named data 
      if not os.path.exists('data'): 
          os.makedirs('data') 
    
  # if not created then raise error 
  except OSError: 
      print ('Error: Creating directory of data') 
    
  # frame 
  currentframe = 0
    
  while(True): 
        
      # reading from frame 
      ret,frame = cam.read() 
    
      if ret: 
          # if video is still left continue creating images 
          name = './data/frame' + str(currentframe) + '.jpg'
          print ('Creating...' + name) 
    
          # writing the extracted images 
          cv2.imwrite(name, frame) 
    
          # increasing counter so that it will 
          # show how many frames are created 
          currentframe += 1
      else: 
          break
    
  # Release all space and windows once done 
  cam.release() 
  cv2.destroyAllWindows()
  </code></pre>