gpt4 book ai didi

python - 如何解决opencv中的 '[mov,mp4,m4a,3gp,3g2,mj2 @ 0000021c356d9e00] moov atom not found'

转载 作者:行者123 更新时间:2023-12-02 16:11:50 26 4
gpt4 key购买 nike

我正在尝试使用 OpenCV 在 kivy 应用程序中创建视频 uploader 。但是,当我尝试上传视频时,出现以下错误

[mov,mp4,m4a,3gp,3g2,mj2 @ 0000021c356d9e00] moov atom not found
[mov,mp4,m4a,3gp,3g2,mj2 @ 0000021c356d9e00] moov atom not found
[mov,mp4,m4a,3gp,3g2,mj2 @ 0000021c356d9e00] moov atom not found
[mov,mp4,m4a,3gp,3g2,mj2 @ 0000021c356d9e00] moov atom not found
...

在此期间屏幕变得无响应。我最近编辑了 save() 函数并添加了一个 uploadClass() 因为我遇到了另一个错误。

主.py

...

class SaveDialog(Screen):
save = ObjectProperty(None)
text_input = ObjectProperty(None)
cancel = ObjectProperty(None)

def save(self, path, filename):

for letter in os.path.join(path, filename):
print(letter)

def find(s, ch):
return [i for i, letter in enumerate(s) if letter == ch]

os_path_simpl = list(os.path.join(path, filename))

for t in range(len(find(os.path.join(path, filename), '\\'))):
os_path_simpl[find(os.path.join(path, filename), '\\')[t]] = '\\'

class uploadClass(object):
video = ''.join(os_path_simpl)

def __init__(self, src=video):
self.video_selected = cv2.VideoCapture(src)

self.vid_cod = cv2.VideoWriter_fourcc(*'mp4v')
self.out = cv2.VideoWriter('media/testOne.mp4', self.vid_cod, 20.0, (640,480))

self.thread = Thread(target=self.update, args=())
self.thread.daemon = True
self.thread.start()

def update(self):
while True:
if self.video_selected.isOpened():
(self.status, self.frame) = self.video_selected.read()

def show_frame(self):
if self.status:
cv2.imshow('uploading', self.frame)

if cv2.waitKey(10) & 0xFF == ord('q'):
self.video_selected.release()
self.out.release()
cv2.destroyAllWindows()
exit(1)

def save_frame(self):
self.out.write(self.frame)

rtsp_stream_link = 'media/testOne.mp4'
upload_Class = uploadClass(rtsp_stream_link)
while True:
try:
upload_Class.__init__()
upload_Class.show_frame()
upload_Class.save_frame()
except AttributeError:
pass

sm.current = "home"

...

最佳答案

Moov atom 包含播放视频所需的各种信息,您收到的错误表明此信息丢失或损坏。

例如,当您创建视频然后在创建过程仍在运行时尝试移动/上传文件时可能会发生这种情况。

在您的情况下,我认为您需要在尝试上传文件之前释放 cv2.VideoWriter/cv2.VideoCapture 对象。即

self.video_selected.release()
self.out.release()

需要在视频上传前调用。

关于python - 如何解决opencv中的 '[mov,mp4,m4a,3gp,3g2,mj2 @ 0000021c356d9e00] moov atom not found',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60672065/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com