to extract multiple of n images using open cv in python
You can use the modulo operator to identify multiples of count. Whenever it is a multiple of 5 save the image, otherwise just disregard it and move to the next iteration of the while loop.    

Make sure the counter is outside the if statement. It will count every iteration. That is how we will determine if the current image is a multiple of 5.

import cv2     
import os
os.chdir('D:/Python images/videofolder') 
cap = cv2.VideoCapture('D:/Python images/test_videos/testcutvideo1.avi')
cap.isOpened()

count = 0
success = True
while success:
    success,image = cap.read()
    if count % 5 == 0:
        cv2.imwrite("image%d.jpg" % count, image) # save frame as JPEG file
    count += 1