用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()
免责声明:
以上内容除特别注明外均来源于网友提问,创作工场回答,未经许可,严谨转载。