我正在尝试使用OpenCV将视频写入媒体文件。视频播放良好,mp4文件写入媒体文件。然而,当我打开书面视频时,我收到了这条信息
This file isn't playable. That might be because the file type is unsupported, the file extension is incorrect, or the file is corrupt
我已将VideoWriter_fourcc()
更改为*“X264”、“H264”、“MP4V”、“MP4V”和*“MPEG”。所有这些都没有解决这个问题
import cv2
path = "C:/Users/gri_o/Desktop/opencvProjects/ProjectOne/testVideos/myvideo.mp4"
video_selected = cv2.VideoCapture(path)
vid_cod = cv2.VideoWriter_fourcc(*'mp4v')
out = cv2.VideoWriter('media/testOne.mp4', vid_cod, 20.0, (640,480))
while(True):
ret,frame = video_selected.read()
if ret == True:
out.write(frame)
cv2.imshow('frame', frame)
# Press Q on keyboard to exit
if cv2.waitKey(10) & 0xFF == ord('q'):
break
else:
break
video_selected.release()
out.release()
误差可能是由于中提到的宽度和高度引起的
获取框架的宽度和高度,如下所示
相关问题 更多 >
编程相关推荐