#python 如何修改视频的帧高和帧宽,并保存为新视频文件
本文的目的是将该视频信息1154, 970转化为固定想要的视频大小,例如转为384, 288大小的
转换前:
转化后:
import cv2
videoCapture = cv2.VideoCapture('20201228151843.avi')
fps = 25 # 保存视频的帧率
size = (384, 288) # 保存视频的大小
videoWriter = cv2.VideoWriter('resizex1.avi', cv2.VideoWriter_fourcc('X', 'V', 'I', 'D'), fps, size)
i = 0
while True:
success, frame = videoCapture.read()
if success:
i += 1
if (i >= 1 and i <= 8000):
frame = cv2.resize(frame, (384, 288))
videoWriter.write(frame)
if (i > 8000):
print("success resize")
break
else:
print('end')
break
参考作者:https://blog.csdn.net/weixin_45875199/article/details/108045482
感谢该作者的分享