我尝试了以下代码:
import cv2
import numpy as np
from ffpyplayer.player import MediaPlayer
video_path="/home/xxx/Desktop/videoplayback.mp4"
def PlayVideo(video_path):
video=cv2.VideoCapture(video_path)
player = MediaPlayer(video_path)
while True:
grabbed, frame=video.read()
audio_frame, val = player.get_frame()
if not grabbed:
print("End of video")
break
if cv2.waitKey(28) & 0xFF == ord("q"):
break
cv2.imshow("Video", frame)
if val != 'eof' and audio_frame is not None:
#audio
img, t = audio_frame
video.release()
cv2.destroyAllWindows()
PlayVideo(video_path)
我遇到以下错误。
SDL_OpenAudio(2个通道,44100 Hz):没有这样的音频设备 SDL_OpenAudio(1通道,44100 Hz):没有这样的音频设备 没有更多的频道组合可以尝试,音频打开失败
答案 0 :(得分:0)
我根据项目的instructions在GitHub上安装了最新版本的ffpyplayer来解决此问题。
pip install https://github.com/matham/ffpyplayer/archive/master.zip