The idea is the following, the script needs to recognize all DAV files recursively in the folder, and apply the conversion to JPEG of 5 seconds using OPENCV. So far everything working. However the script is listing the AVI files but converts only 1 file, and not all that were listed.
import os
import cv2
path = 'C:\\Users\\coleta 1\\Desktop\\SNAPSHOT'
files = []
for r, d, f in os.walk(path):
for file in f:
if '.avi' in file:
files.append(os.path.join(r, file))
for f in files:
print(f)
vidcap = cv2.VideoCapture(f)
def Printar(sec):
vidcap.set(cv2.CAP_PROP_POS_MSEC,sec*10000)
hasFrames,image = vidcap.read()
if hasFrames:
cv2.imwrite("image"+str(count)+".jpg", image)
return hasFrames
sec = 0
frameRate = 0.5
count=1
success = Printar(sec)
while success:
count = count + 1
sec = sec + frameRate
sec = round(sec, 2)
success = Printar(sec)
continue