#frame rate finder...........
import cv2
video = cv2.VideoCapture("v1.mp4");
# Find OpenCV version
# (major_ver, minor_ver, subminor_ver) = (cv2.__version__).split('.')
# if int(major_ver) < 3 :
# fps = video.get(cv2.cv.CV_CAP_PROP_FPS)
# print ("Frames per second using video.get(cv2.cv.CV_CAP_PROP_FPS): {0}".format(fps))
# else :
fps = int(video.get(cv2.CAP_PROP_FPS))
# print ("Frames per second using video.get(cv2.CAP_PROP_FPS) : {0}".format(fps))
print ("Frames per second : {0}".format(fps))
video.release();
import cv2
import numpy as np
import os
# set video file path of input video with name and extension
vid = cv2.VideoCapture('6.mp4')
if not os.path.exists('images'):
os.makedirs('images')
#for frame identity
index = 0
while(True):
# Extract images
ret, frame = vid.read()
# end of frames
if not ret:
break
# Saves images
name = './images/frame' + str(index) + '.jpg'
print ('Creating...' + name)
cv2.imwrite(name, frame)
# next frame
index += 1
# its working code of frame jump
import cv2
import numpy as np
# imporelse:
# t time
cap = cv2.VideoCapture("6.mp4")
# here "6.mp4" used as a video reference..................
# time.sleep(2)
# fps = int(cap.get(cv2.CAP_PROP_FPS))
frameCount = int(cap.get(cv2.CAP_PROP_FRAME_COUNT))
# step=20
desired_frames = np.arange(frameCount,step=20)
if cap.isOpened() is False:
print("Error opening video stream or file")
# while cap.isOpened():
while True :
for i in desired_frames:
cap.set(1,i-1)
success,image = cap.read(1)
# if success==True:
frameId = cap.get(1)
cv2.imshow('Test', image)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
# else:
# break
# cv2.waitKey(25)
cap.release()
cv2.destroyAllWindows()