我正在尝试使用OpenCV在一个kivy应用程序中创建一个视频上传器。但是,当我试图上传视频时,会出现以下错误
[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(),因为我收到了另一个错误。
main.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"
...
发布于 2020-03-22 12:27:34
Moov原子包含播放视频所需的各种信息,而您所得到的错误表明该信息要么丢失,要么损坏。
这可能发生,例如,当您创建一个视频,然后尝试移动/上传文件,而创建过程仍在运行。
在您的例子中,我认为您需要在试图上传文件之前释放cv2.VideoWriter/cv2.VideoCapture对象。即
self.video_selected.release()
self.out.release()
需要在视频上传之前被调用。
https://stackoverflow.com/questions/60672065
复制相似问题