1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
| import os import time import cv2 import matplotlib.pyplot as plt
ss = 'c:/users/xxxx/ffmpeg/ffmpeg.exe ' + '-ss {} -i xxx.mp4 -t 0.01 -f image2 d:{}.jpg -y'
for sec in range(60): cmd = ss.format(str(sec), str(sec)) print(cmd) os.popen(cmd) time.sleep(0.5)
for i in range(60): img = cv2.imread('d:{}.jpg'.format(str(i)), 0)
cut = img[803:835, 533:595] cv2.imwrite('d:/cuts/{}.jpg'.format(str(i)), cut)
plt.subplot(6, 10, i+1) plt.imshow(cut) plt.xticks([]), plt.yticks([])
plt.show()
|