0xC00D36C4 错误打开由CV2 VideoWriter生成的MP4视频

huangapple go评论228阅读模式
英文:

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

huangapple
  • 本文由 发表于 2023年7月3日 22:16:09
  • 转载请务必保留本文链接:https://go.coder-hub.com/76605610.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定