我一直在研究允许某人观看视频的东西,当您要保存为图像的部分出现时,按R并保存帧。
import cv2
input_filename = "test.mp4"
#file_name = "aaa.mp4"
record_flag = False
frames_per_second = 24.0
output_loc = 'frames'
VIDEO_TYPE = {
'avi': cv2.VideoWriter_fourcc(*'XVID'),
'mp4': cv2.VideoWriter_fourcc(*'XVID'),
}
cap = cv2.VideoCapture(input_filename)
# out = cv2.VideoWriter(file_name, VIDEO_TYPE['mp4'], 25, (1280, 720))
count_point = 0
while True:
ret, frame = cap.read()
count_point += 1
if ret:
cv2.imshow('frame', frame)
# if keyboard.is_pressed('r'):
if cv2.waitKey(1) & 0xFF == ord('r'):
cv2.imwrite(output_loc + "/%#05d.jpg" % (count_point + 1), frame)
# out.write(frame)
if cv2.waitKey(1) & 0xFF == ord('q'):
print("End: Record")
break
else:
break
cap.release()
out.release()
cv2.destroyAllWindows()
我的问题是它运行正常,给了我0号出口,却什么也没做。它确实可以在另一台PC上运行,但是由于某种原因,我无法使其在其他PC上运行。任何输入都会受到欢迎,谢谢。