pythonのpyavで音付き動画を再生したいです。
なんとか画像は出るようになりましたがこれに音をつける方法がわかりません。
(Windowsです)
python
1import av 2import cv2 3 4container = av.open("rtsp://192.168.100.142:8554/in.mp4") 5 6for frame in container.decode(video=0): 7 img = frame.to_ndarray(format='bgr24') 8 cv2.imshow("Test", img) 9 cv2.waitKey(1)
これで画像は出ていますが音声がいまのところ出ていません。
pyaudioでなんとかなるのか?とおもっていろいろ試したのですがうまくできませんでした。
もし知っていればお教えいただけるとありがたいです。
まだ考えています
python
1for frame in container.decode(video=0,audio=1): 2 print (type(frame)) 3 if type(frame) is av.video.frame.VideoFrame: 4 img = frame.to_ndarray(format='bgr24') 5 cv2.imshow("Test", img) 6 key=cv2.waitKey(1) 7 elif type(frame) is av.audio.frame.AudioFrame: 8 print ("is Audio") 9 audio=frame.to_ndarray(format='s16') 10 #ary=[frame] 11 stream.write(audio) 12 #print (frame.sample_rate) 13 #if packet.stream.type == 'video': 14 # print("is video ") 15 # img = frame.to_ndarray(format='bgr24') 16 # cv2.imshow("Test", img) 17 # key=cv2.waitKey(1) 18 #elif packet.stream.type == 'audio': 19 # print("is audio") 20 #print(packet.stream.type) 21 #print(frame) 22 #img = frame.to_ndarray(format='bgr24') 23 #cv2.imshow("Test", img) 24 #key=cv2.waitKey(1)
こう書き直しました。が依然として音はでません

バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2021/04/09 02:18
2021/04/09 02:22