|
opencv读视频并操作图片后存成视频文件
- import cv2
- # opencv读视频并操作图片后存成视频文件
- # 视频文件加载
- videoCapture = cv2.VideoCapture("./video/my.mp4")
- # 视频的属性
- fps = videoCapture.get(cv2.CAP_PROP_FPS)
- size = (int(videoCapture.get(cv2.CAP_PROP_FRAME_WIDTH)), int(videoCapture.get(cv2.CAP_PROP_FRAME_HEIGHT)))
- print("fps:", fps, "size宽高:", size)
- # 写入视频文件
- videoWriter = cv2.VideoWriter("./video/my2.avi", cv2.VideoWriter_fourcc('X', 'V', 'I', 'D'), fps, size)
- success, img = videoCapture.read()
- while success:
- cv2.putText(img, f"dfy[weixin]:dfy_88888", (30, 150), cv2.FONT_HERSHEY_COMPLEX_SMALL, 1, (0, 0, 255), 2)
- videoWriter.write(img)
- success, img = videoCapture.read()
复制代码
|
|