我试过代码:
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 channels, 44100 Hz): No such audio device SDL_OpenAudio (1 channels, 44100 Hz): No such audio device No more channel combinations to try, audio open failed
最佳答案
我根据项目的 instructions 在 GitHub 上安装了最新版本的 ffpyplayer 来解决这个问题.
pip install https://github.com/matham/ffpyplayer/archive/master.zip
关于python - 如何解决错误 :SDL_OpenAudio (2 channels, 44100 Hz):没有这样的音频设备,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56127549/