anrayliu / pyvidplayer2

Reliable, easy, and fast video playing in Python
MIT License
35 stars 10 forks source link

wave.Error: not a WAVE file #23

Closed happyleibniz closed 7 months ago

happyleibniz commented 7 months ago

yup, i'm trying with this code(the code in the pypi main project):

import pygame
from pyvidplayer2 import Video

# create video object

vid = Video("1020212.mp4")

win = pygame.display.set_mode(vid.current_size)
pygame.display.set_caption(vid.name)

while vid.active:
    key = None
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            vid.stop()
        elif event.type == pygame.KEYDOWN:
            key = pygame.key.name(event.key)

    if key == "r":
        vid.restart()           #rewind video to beginning
    elif key == "p":
        vid.toggle_pause()      #pause/plays video
    elif key == "m":
        vid.toggle_mute()       #mutes/unmutes video
    elif key == "right":
        vid.seek(15)            #skip 15 seconds in video
    elif key == "left":
        vid.seek(-15)           #rewind 15 seconds in video
    elif key == "up":
        vid.set_volume(1.0)     #max volume
    elif key == "down":
        vid.set_volume(0.0)     #min volume
    elif key == "1":
        vid.set_speed(1.0)      #regular playback speed
    elif key == "2":
        vid.set_speed(2.0)      #doubles video speed

    # only draw new frames, and only update the screen if something is drawn

    if vid.draw(win, (0, 0), force_draw=False):
        pygame.display.update()

    pygame.time.wait(16) # around 60 fps

# close video when done

vid.close()
pygame.quit()

and i'm getting these errors:

Warning (from warnings module):
  File "C:\Users\Spinoza\AppData\Local\Programs\Python\Python310\lib\site-packages\pyglet\libs\win32\__init__.py", line 318
    warnings.warn("Could not set COM MTA mode. Unexpected behavior may occur.")
UserWarning: Could not set COM MTA mode. Unexpected behavior may occur.

Warning (from warnings module):
  File "C:\Users\Spinoza\AppData\Local\Programs\Python\Python310\lib\site-packages\pyglet\image\codecs\wic.py", line 405
    warnings.warn(str(err))
UserWarning: [WinError -2147417850] Cannot change thread mode after it is set
Traceback (most recent call last):
  File "C:/Users/Spinoza/AppData/Local/Programs/Python/Python310/python_project/somethingtodowidthvideos/vidtestar.py", line 42, in <module>
    if vid.draw(win, (0, 0), force_draw=False):
  File "C:\Users\Spinoza\AppData\Local\Programs\Python\Python310\lib\site-packages\pyvidplayer2\video.py", line 287, in draw
    if (self._update() or force_draw) and self.frame_surf is not None:
  File "C:\Users\Spinoza\AppData\Local\Programs\Python\Python310\lib\site-packages\pyvidplayer2\video.py", line 182, in _update
    self._audio.load(self._chunks.pop(0))
  File "C:\Users\Spinoza\AppData\Local\Programs\Python\Python310\lib\site-packages\pyvidplayer2\pyaudio_handler.py", line 37, in load
    self.wave = wave.open(BytesIO(bytes), "rb")
  File "C:\Users\Spinoza\AppData\Local\Programs\Python\Python310\lib\wave.py", line 509, in open
    return Wave_read(f)
  File "C:\Users\Spinoza\AppData\Local\Programs\Python\Python310\lib\wave.py", line 163, in __init__
    self.initfp(f)
  File "C:\Users\Spinoza\AppData\Local\Programs\Python\Python310\lib\wave.py", line 132, in initfp
    raise Error('not a WAVE file')
wave.Error: not a WAVE file
anrayliu commented 7 months ago

Hello, are you sure ffmpeg is properly installed and working? Are you sure your video is also not corrupted and works fine in other video players?

happyleibniz commented 7 months ago

yeah i just found out that ffmpeg is not properly working fixed