【发布时间】:2021-02-18 18:14:57
【问题描述】:
截图:
基本上,我正在尝试创建一个包含视频所有帧的文件夹,并稍后在代码中对其进行编辑,但是,我遇到了保存时 img/frame 的文件大小过高的问题我一直在尝试调查,但到目前为止我没有运气。
我们将不胜感激!
VideoCap = cv2.VideoCapture("./Path/Path.mp4");
FolderPath = "./Path/Path";
if not os.path.exists(FolderPath):
print(f"{FolderPath} doesn't exists. Creating...");
os.makedirs(FolderPath);
Success, Frame = VideoCap.read();
Count = 0;
while Success:
cv2.imwrite(FolderPath+"/Frame%d.png" % Count, Frame); # The size is way too much! Literally 1/15th of the video just in a frame.
print("Frame %d has been written" % Count);
Count+=1;
Success, Frame = VideoCap.read();
if cv2.waitKey(1) & 0xFF == ord('q'):
break
else:
print(f"{FolderPath} already exists. Moving on...");
【问题讨论】:
标签: python opencv cv2 opencv-python