00:00 / 00:00
![import cv2
import numpy as np
# 参数设置
input_img = "input.jpg" # 输入图片路径
output_video = "output.mp4"
fps = 30
degrees = 360 # 旋转角度范围
duration = 5 # 视频时长(秒)
# 读取图片并获取尺寸
img = cv2.imread(input_img)
height, width = img.shape[:2]
# 创建视频写入对象
fourcc = cv2.VideoWriter_fourcc(*'mp4v')
video = cv2.VideoWriter(output_video, fourcc, fps, (width, height))
# 生成旋转帧序列
for frame in range(int(fps*duration)):
angle = frame * degrees / (fps*duration)
# 计算旋转矩阵
M = cv2.getRotationMatrix2D((width/2, height/2), angle, 1)
# 执行仿射变换(添加透视变换可增强3D感)
rotated = cv2.warpAffine(img, M, (width, height), borderMode=cv2.BORDER_REPLICATE)
video.write(rotated)
video.release() by Hailuo AI Video Generator](https://cdn.hailuoai.com/prod/2025-02-26-19/video_cover/1740570098293125705-cover_62072cf5337ff017b6de21aed36ed583.jpeg?x-oss-process=image/resize,w_540/format,webp)

创意描述
复制
import cv2
import numpy as np
# 参数设置
input_img = "input.jpg" # 输入图片路径
output_video = "output.mp4"
fps = 30
degrees = 360 # 旋转角度范围
duration = 5 # 视频时长(秒)
# 读取图片并获取尺寸
img = cv2.imread(input_img)
height, width = img.shape[:2]
# 创建视频写入对象
fourcc = cv2.VideoWriter_fourcc(*'mp4v')
video = cv2.VideoWriter(output_video, fourcc, fps, (width, height))
# 生成旋转帧序列
for frame in range(int(fps*duration)):
angle = frame * degrees / (fps*duration)
# 计算旋转矩阵
M = cv2.getRotationMatrix2D((width/2, height/2), angle, 1)
# 执行仿射变换(添加透视变换可增强3D感)
rotated = cv2.warpAffine(img, M, (width, height), borderMode=cv2.BORDER_REPLICATE)
video.write(rotated)
video.release()

Hailuo 01-Director
提示词优化
图生视频
720p
内容由AI生成