27 lines
675 B
Python
27 lines
675 B
Python
|
|
import cv2
|
|
import numpy as np
|
|
|
|
# 定义编码器并创建VideoWriter对象
|
|
#fourcc = cv2.VideoWriter_fourcc(*'acv1')
|
|
fourcc = cv2.VideoWriter_fourcc(*'avc1')
|
|
output_video = 'output.mp4'
|
|
frame_width = 1920
|
|
frame_height = 1080
|
|
fps = 30
|
|
out = cv2.VideoWriter(output_video, fourcc, fps, (frame_width, frame_height))
|
|
|
|
# 创建视频帧(使用黑色作为示例)
|
|
frame = np.zeros((frame_height, frame_width, 3), np.uint8)
|
|
|
|
# 写入视频帧
|
|
for i in range(60): # 假设我们只写入60帧
|
|
# 这里可以替换为你的处理过程,比如添加文本或者处理帧
|
|
# ...
|
|
|
|
# 将帧写入视频
|
|
out.write(frame)
|
|
|
|
# 释放VideoWriter对象
|
|
out.release()
|