-
-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Delayed audio output with apple music #3470
Comments
Include the log as per the issue template. When did this start happening? If after an update have you rolled back and confirmed it doesn’t occur? |
Hi @OzGav, thanks for your quick response. I've updated the issue request accordingly.
The issue is always the same. The log does not show anything relevant to me. How can I enable debug logging ? Is there a way to test playback from cmdline with
|
Interesting, you're the first one to report this issue. A few seconds of delay is expected, since there is no official apple music api. I had to reverse engineer the api along with obtaining decryption keys , so that takes a 1-2 seconds. Do you have more stuff running on that hardware besides HA? Have you checked your hardware utilization? Also see you are not running HA OS, so I'd definitely look into available cpu / memory for MA. |
@MarvinSchenkel First let me say that I'm really impressed by the apple music integration! Thanks for your work! Memory and CPU should not be an issue. I did a simple test playing to a directly attached output using
NOTE: I've disabled the loudnorm plugin since this increases ffmpeg's CPU usage from 2% to 15%. Next I'm trying to send it to airplay. The shairport sync instances I have are running in Airplay 1 mode only are working very well with our zoo of apple devices. |
That is only the first time you stream a track to collect the measurement while streaming. Next time it will have a measurement and it can do a simple gain correction. See docs about this.
Does this issue also occur on actual Apple hardware or only on shairport sync instances ?
No that will be near to impossible as its a whole chain of logic in python, pipes and processes. |
I would also be interested to see where the delay is actually happening. I can think of two places:
Can you enable debug logging on both the apple music provider AND the stream server to figure this out? If you see an ffmpeg log message like "Start streaming queue track xxxx" after 2-3 sec (indicating the ffmpeg process starts playing) and it still takes another 10+ sec for the music to start player, then it might be a buffer issue like @marcelveldt suggested: |
I've already tested ffmpeg playback from apple music to local speaker output which works properly.
No I do not have any issues with the shairport-sync instances. Airplay works fine from any other devices and the output always starts at the beginning of the track.
But it should be possible to let ffmpeg pipe sampled output directly to cliraop-linux-x86_64 ? I'll try that in the evening. I'll enable debugging in the apple music provider and send you the log output. |
That is not exactly what I asked. I asked if you tested Apple Music from Music Assistant to another airplay device (so not the shairport sync).
You do not have to test that because that will work and you already confirmed that by playing local files so save yourself the trouble. I guess this is a combination of Apple Music where it takes a tad longer to get the initial stream and shairport sync. |
Ah that didnt take long - I just tried shairport sync and could immediately reproduce the issue. |
Ah ok. No I didn't. I have no other speaker with airplay support - but I think I can test this with my macbook as receiver this evening.
I've compiled shairport-sync without airplay 2 support:
You can take a look at the attached Dockerfile - but it will not run without additional config files because it is customized for my environment. |
I'll try playback with |
Well there is no more need for you to do more tests, I have reproduced the issue and I'll let you know later when I found the cause and solution |
What version of Music Assistant has the issue?
2.4.0b16
What version of the Home Assistant Integration have you got installed?
No response
Have you tried everything in the Troubleshooting FAQ and reviewed the Open and Closed Issues and Discussions to resolve this yourself?
The problem
Audio output is delayed when music provider is apple music. The track is playing but there is no audio output for some time (often 5s to 30s).
This happens when the first track is played, after skipping to the next track and after seeking.
How to reproduce
Play files from apple music.
Music Providers
The music provider is apple music.
When playing local files the playbacks starts immediately.
Player Providers
The player provider is airplay (shairport-sync)
Full log output
music-assisant-log.txt
Additional information
No response
What version of Home Assistant Core are your running
2025.1.2
What type of installation are you running?
Home Assistant OSContainer (podman)
On what type of hardware are you running?
Raspberry PiDell Optiplex 7040 Micro ( Intel(R) Core(TM) i5-6500T CPU )
The text was updated successfully, but these errors were encountered: