原始问题:
用Python写一段视频切割代码
以下是一段使用Python进行视频切割的代码:
import cv2
Opens the Video file
cap= cv2.VideoCapture('input_video.mp4')
# Used as counter variable
count = 0;
while(cap.isOpened()):
# Capture frame-by-frame
ret, frame = cap.read()
if ret == True:
# Saves the frames with frame-count
name = './frames/frame' + str(count) + '.jpg'
print ('Creating...' + name)
# Write the results back to output location.
cv2.imwrite(name, frame)
count += 1;
else:
break # If there are no more frames left cap.release() cv2.destroyAllWindows()
Prev:风水学是怎么个科学原理