英文:
0xC00D36C4 Error Opening CV2 VideoWriter-Generated MP4 Video
问题
import cv2
import numpy as np
fourcc = cv2.VideoWriter_fourcc(*'mp4v')
shape = cv2.imread('data/temp/enhanced/1.png')
shape = shape.shape
shape = (shape[1], shape[0])
writer = cv2.VideoWriter('output.mp4', fourcc, 30, shape)
for i in range(50):
img = cv2.imread(f'data/temp/enhanced/{i + 1}.png')
writer.write(img)
print(i+1)
writer.release()
我有一个生成视频文件的脚本,但是当我尝试打开生成的视频时,出现了0xC00D36C4错误,无法播放。可能导致这个问题的原因是什么?有什么解决方法吗?
所有位于'data/temp/enhanced/'目录中的图像都具有一致的大小,为17080 x 9600像素。
我尝试将视频文件的扩展名更改为AVI,并使用了适用于AVI文件的适当编解码器。然而,尽管这些更改,问题仍然存在,视频仍然无法播放。
英文:
import cv2
import numpy as np
fourcc = cv2.VideoWriter_fourcc(*'mp4v')
shape = cv2.imread('data/temp/enhanced/1.png')
shape = shape.shape
shape = (shape[1], shape[0])
writer = cv2.VideoWriter('output.mp4', fourcc, 30, shape)
for i in range(50):
img = cv2.imread(f'data/temp/enhanced/{i + 1}.png')
writer.write(img)
print(i+1)
writer.release()
I have a script that generates a video file, but when I try to open the generated video, I encounter the 0xC00D36C4 error and it refuses to play. What could be causing this issue? Any suggestions for resolving it?
All the images in the 'data/temp/enhanced/' directory have a consistent size of 17080 x 9600 pixels.
I attempted to change the file extension of the video to AVI and used the appropriate codec for AVI files. However, despite these changes, the issue persists and the video still cannot be played.
答案1
得分: 2
已修复,通过调整输入图像的大小。
英文:
import cv2
import numpy as np
fourcc = cv2.VideoWriter_fourcc(*'mp4v')
shape = cv2.imread('data/temp/enhanced/1.png')
shape = shape.shape
shape = (1920, 1080)
print(shape)
writer = cv2.VideoWriter('output.mp4', fourcc, 30, shape)
for i in range(50):
img = cv2.imread(f'data/temp/enhanced/{i + 1}.png')
img = cv2.resize(img, shape)
writer.write(img)
print(i+1)
writer.release()
Fixed it by resizing the input image sizes
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论