为什么在 pyglet 中尝试播放视频时出现错误?

时间:2021-04-06 01:09:27

标签: python mp4 pyglet

我正在开发一个程序,该程序旨在使用 Piglet 播放 MP4 视频,但每当我运行它时,它都会在视频加载之前崩溃。这是我的代码:

import pyglet
from AppKit import NSScreen
from pyglet import image
from pyglet.window import Window, key

#Configure Video Settings
bWidth = (((NSScreen.mainScreen().frame().size.width) - 2560) / 2)
bHeight = (((NSScreen.mainScreen().frame().size.height) - 1600) / 2)

window=pyglet.window.Window(fullscreen=True) 

video = 'proposal.mp4'
player = pyglet.media.Player()
source = pyglet.media.StreamingSource()
MediaLoad = pyglet.media.load(video)

player.queue(MediaLoad)
player.play()

@window.event
def on_draw():
  if player.source and player.source.video_format:
    player.get_texture().blit(bWidth, bHeight)

pyglet.app.run()

这是我得到的错误:

Traceback (most recent call last):
  File "/Users/myuser/Library/Python/3.8/lib/python/site-packages/pyglet/media/codecs/wave.py", line 58, in __init__
    self._wave = wave.open(file)
  File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/wave.py", line 510, in open
    return Wave_read(f)
  File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/wave.py", line 164, in __init__
    self.initfp(f)
  File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/wave.py", line 131, in initfp
    raise Error('file does not start with RIFF id')
wave.Error: file does not start with RIFF id

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "proposal.py", line 67, in <module>
    MediaLoad = media.load(video)
  File "/Users/myuser/Library/Python/3.8/lib/python/site-packages/pyglet/media/__init__.py", line 140, in load
    raise first_exception
  File "/Users/myuser/Library/Python/3.8/lib/python/site-packages/pyglet/media/__init__.py", line 130, in load
    loaded_source = decoder.decode(file, filename, streaming)
  File "/Users/myuser/Library/Python/3.8/lib/python/site-packages/pyglet/media/codecs/wave.py", line 105, in decode
    return WaveSource(filename, file)
  File "/Users/myuser/Library/Python/3.8/lib/python/site-packages/pyglet/media/codecs/wave.py", line 60, in __init__
    raise WAVEDecodeException(e)
pyglet.media.codecs.wave.WAVEDecodeException: file does not start with RIFF id

如果您能帮我弄清楚为什么会出现此错误,我将不胜感激。我已经研究了一段时间,不知道为什么它开始这样做。谢谢:)

0 个答案:

没有答案