我一直在尝试使用OpenCV在python中编写MP4视频文件。
当我使用两者时,AVI创建在linux和windows上都能正常工作:
out = cv2.VideoWriter('x.avi', 0, 30, (640, 480))
和
fourcc = cv2.VideoWriter_fourcc(*"XVID")
out = cv2.VideoWriter('x.avi', fourcc, 30, (640, 480))
甚至
fourcc = cv2.VideoWriter_fourcc(*"XVID")
out = cv2.VideoWriter('x', fourcc, 30, (640, 480))
当我尝试保存MP4但是没有任何保存 - 使用:
fourcc = cv2.VideoWriter_fourcc(*"H264")
out = cv2.VideoWriter('x.mp4', fourcc, 30, (640, 480))
和
fourcc = cv2.VideoWriter_fourcc(*"AVC1")
out = cv2.VideoWriter('x.mp4', fourcc, 30, (640, 480))
不会发生任何错误,只会保存任何内容。
过去几天我尝试了所有的东西,尽一切努力避免创建AVI,然后使用ffmpeg将其转换为MP4,因为我发现这是一种可怕的做法。
答案 0 :(得分:-3)
给出帧的高和宽的正确值:
ERROR 1064 (42000) at line 1 in file: 'q7.sql': You have an error in your
SQL syntax; check the manual that corresponds to your MySQL server version
for the right syntax to use near 'x' at line 5
此代码适用于我。