Small circle ape achieve Python tutorial video frame skipping interception Detailed source

Today small circle apes share a Python Details skipping intercept the video frame, long time to intercept the video can be freely set by the measured results are satisfactory. A trouble encountered during my video files in the D: drive, you can not save the original video on the D drive image file directory interception, later renamed in C: saving on disk, normal, let's look at it.


import cv2

import os

def save_img():

video_path = r 'reads the video path'

videos = os.listdir(video_path)

for video_name in videos:

videopath=video_path+'\\'+video_name

print(videopath)

vc = cv2.VideoCapture (videopath) # read video files

c = 1

if vc.isOpened (): # determine whether the normal open

rval, frame = vc.read()

else:

Scrapped = False

timeF = 300 # video frame frequency counting interval

a=1

while rval: # loop to read the video frame

rval, frame = vc.read()

if (c% timeF == 0): # storage operation performed every frame TIMEF

print(video_path+'\\' + str(a) + '.jpg')

# Can not be in the D: save image files on the disk original video catalog, for unknown reasons

cv2.imwrite (r 'save image file path' + '\\' + str (a) + '.jpg', frame)

cv2.imshow('Video',frame)

a+=1

c = c + 1

m=cv2.waitKey(1)

vc.release ()

save_img()

Above is about the interpretation of small circle ape achieve the interception of the entire contents of the video frame skipping Detailed source, and finally want to learn more about Python and small partners artificial intelligence content, please pay attention to the small circle official website ape , ape small circle their best to provide you more comprehensive and more competitive video python self exchange: 242 719 133, I hope for your help.


Reproduced in: https: //juejin.im/post/5cf4d8a35188253be10950f9

Guess you like

Origin blog.csdn.net/weixin_33882452/article/details/91475806