The len() of class av.audio.frame.AudioFrame
Closed this issue · 6 comments
The problem
I create a new Anaconda environment with python3.7, and install the dependencies following the guidance.
But as pipwin
has the SSL problem, I install the pyaudio
by conda
rather than the pipwin
in the guidance.
And run this to start the service:
python .\ap2-receiver.py -m "myap2" -n "{C7454699-5CBC-436B-9279-71EE595128A0}"
Before the client start playing, everything is fine. But once audio streaming start, this exception is raised:
[AudioRealtime]: TypeError("object of type 'av.audio.frame.AudioFrame' has no len()")
And I try to locate it, the detail of the exception is:
Exception in thread Thread-2:
Traceback (most recent call last):
File "C:\Users\hra20\Anaconda3\envs\airplay\lib\threading.py", line 926, in _bootstrap_inner
self.run()
File "C:\Users\hra20\Anaconda3\envs\airplay\lib\threading.py", line 870, in run
self._target(*self._args, **self._kwargs)
File "C:\Users\hra20\Downloads\airplay2-receiver-master\ap2\connections\audio.py", line 795, in play
raise e
File "C:\Users\hra20\Downloads\airplay2-receiver-master\ap2\connections\audio.py", line 777, in play
audio = self.process(rtp)
File "C:\Users\hra20\Downloads\airplay2-receiver-master\ap2\connections\audio.py", line 572, in process
if len(frame) == 1: # if no resampling was needed, resample returns [frame]
TypeError: object of type 'av.audio.frame.AudioFrame' has no len()
I view the latest commit of ap2/connections/audio.py and find a new commit(2af912c) just to change the line 572-574, and I simply comment these lines below:
572 | if len(frame) == 1: # if no resampling was needed, resample returns [frame]
573 | frame = frame[0]
and it works.
Maybe it is just not working propery on Windows.
What commit exhibits the issue?
Was there a last known working commit?
What type of installation are you running?
virtualenv
With which python3 version do you run Receiver?
Python 3.7.15
OS the receiver runs on
Windows 11 21H2(22000.1455)
OS the sender runs
iPadOS 15.5
Which sender client was used
NetEase Cloud Music
Command invocation
python .\ap2-receiver.py -m "myap2" -n "{C7454699-5CBC-436B-9279-71EE595128A0}"
Please include --debug output which helps to illustrate the problem
log.txt
This log is from the original project codes.
Additional information
No response
I think you also need to comment out the third line (#574)
Here are all three lines in audio.py:
572 | if len(frame) == 1: # if no resampling was needed, resample returns [frame]
573 | frame = frame[0]
574 | return bytes(frame.planes[0])
Yes, commenting these 3 out worked for me (I had the same error)
Unfortunately, I've got another issue - All seems to be working, but there is no audio output. Unfortunately - since all SEEMS to be working OK - there is no default logging, or usuable debugging output. I suspect it has something to do with PyAudio...
If you remove the return statement, which passes the (ffmpeg) decoded frame data, you'll hear nothing :)
If you remove the return statement, which passes the (ffmpeg) decoded frame data, you'll hear nothing :)
Thanks, this obviously worked...
You might do well to try the latest commit, and see whether it really fixes your issue