-
Notifications
You must be signed in to change notification settings - Fork 22
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
dev-next branch Music Assistant group player issue #47
Comments
I haven't looked into the speaker groups capability of MA yet, it seems MA creates a url in that case that is not recognisable by the http client. Can you copy paste the stream URL from the log and try playing it in your browser? |
@gnumpi Hey, thanks for the reply. Just give me a couple of minutes to recompile the firmware with logging enabled and i will update this message once i will have results.
And here is when i try to play another track:
Basically, the URL for the playback always starts with - Where This URL is the same for both speakers (i have two devices in one group), just the And no, i am unable to play the audio in the browser as it seems to expect something else rather than just URL from me. |
I was not aware that the arduino media player does play flac streams. Is it possible that the url is only valid for playing once? Because the esphome_audio media player streams the url silently for a bit to detect the necessary audio settings and then finally plays the url again in a second step after all settings are made. |
I seriously doubt that the stream is in Reasons why i don't actually believe that stream is in
On another note, when trying to play the audio to a group which is using
As for the
It is not, MA creates a static group id upon the creation of the group, so it is always the same, from my observations, it just starts to stream audio on this URL whenever the |
Ok, thanks for all the useful information. I will need to try to reproduce the error on my setup. It will probably take a few days though. |
Sure, no problem, as i said, i am aware that this is a dev-next branch which should not be used without expecting some issues ) |
@darki73 side question: do you connect the player to MA over HA? P.S. I'm asking because for me these media players never worked in Music Assistant. Probably, there's direct way to add them, instead of connecting from Home Assistant? |
@formatBCE hey, yes, players flashed from esphome ui in homeassistant, then added to homeassistant under esphome integration, then enabled in the Home Asisstant players in MA. Standalone players work just fine with |
@darki73 that's interesting. I tried it once more, same result - doesn't play.. I tried with YouTube, Spotify and Jellyfin music providers - everything gets translated into MA flac HTTP url, and then I see 0 bytes stream in esp logs.. |
@gnumpi it's even more interesting, that i actually can play music directly from Home Assistant (one by one, apparently, but it shouldn't matter), but not from Music Assistant... The URL from HA is mp3, while from MA it's always flac, regardless of the source library. Could this be the issue? Should i create the ticket? |
Here are some more findings:
They do indeed just straight up slap the Thing is, i have tried the YouTube streams with P.S. After actually paying attention to what is written on the line 298: # register dynamic routes for the ugp stream (both flac and mp3)
for fmt in ("mp3", "flac"):
route_path = f"/ugp/{group_player_id}.{fmt}"
self.mass.streams.register_dynamic_route(route_path, self._serve_ugp_stream)
self._registered_routes.add(route_path)
return player It registers URLs for both P.P.S. The official MA integration also has the following issue music-assistant/hass-music-assistant#2508. The issue that person describes happened to me as well, the fix was the |
In my understanding there are two different issues here, the first one is that MA ignores the enforce mp3 setting since its last update, as it was already reported here: music-assistant/hass-music-assistant#2508. @darki73 how do you run MA? Is it possible that MA has installed its own ffmpeg? Because I assume that MA depends on ffmepg and it always recodes the stream into either flac or mp3. |
@gnumpi MA is installed as an addon from the Home Assistant (i run Home Assistant OS). The reason i doubt that it makes the UGP decode FLAC as i am not noticing any CPU usage increase during the playback (assuming it resamples the m4a/ogg to flac), and the machine is using mobile Ryzen 6800H CPU, while only 4 cores dedicated to a VM, so there should be at least a small spike during the playback initialization, but there is none. Also, they are making 2 URLs for the UGP stream, one Funny thing is, if you click "enough" on the play/pause button, the sound will actually come live and i can either hear it from first / seconds / both of the speakers, BUT, from the logs, it is still the One more thing:
So, from this observation, there is no way MA is doing the FLAC stream. P.S. firmware is compiled with the following settings: esphome:
name: ${device_name}
friendly_name: ${device_friendly_name}
comment: ${device_comment}
area: ${device_area}
name_add_mac_suffix: false
includes:
- /config/smart_speaker/scripts/light_diymall_7x_ws2812.h
platformio_options:
board_build.arduino.memory_type: qio_opi
board_build.flash_mode: dio
board_upload.maximum_ram_size: 524288
esp32:
board: esp32-s3-devkitc-1
variant: esp32s3
flash_size: 16MB
partitions: /config/smart_speaker/boards/N16R8.csv
framework:
type: esp-idf
version: recommended
sdkconfig_options:
CONFIG_ESP32S3_DEFAULT_CPU_FREQ_240: "y"
CONFIG_ESP32S3_DATA_CACHE_64KB: "y"
CONFIG_ESP32S3_DATA_CACHE_LINE_64B: "y"
CONFIG_ESP32_S3_BOX_BOARD: "y"
COMPILER_OPTIMIZATION_SIZE: "y"
CONFIG_ESP32_WIFI_STATIC_RX_BUFFER_NUM: "16"
CONFIG_ESP32_WIFI_DYNAMIC_RX_BUFFER_NUM: "512"
CONFIG_TCPIP_RECVMBOX_SIZE: "512"
CONFIG_TCP_SND_BUF_DEFAULT: "65535"
CONFIG_TCP_WND_DEFAULT: "512000"
CONFIG_TCP_RECVMBOX_SIZE: "512"
psram:
mode: octal
speed: 80MHz |
@darki73 lossless FLAC is a bit different from MP3/AAC/OGG, converted to FLAC, where all lossy bytes will be replaced with 0. Also it might be that MA is "presenting" FLAC stream, and actually is showing MP3 data inside - but headers to stream are FLAC, so MP3 codec can't read the stream. This might be a stretch, but it aligns with what we see on practice. P.S. Which ESP32-S3-WROOM-1-N16R8 board did you use? I got 2 different N16R8 boards from different manufacturers, and they both give strange noise on right channel with different external DACs... Also tried to adopt SEEED XIAO S3, but it fails to boot with seemingly good firmware... |
@formatBCE I have a board of my custom design with all the necessary components for playback and voltage management being placed as close to the ESP as possible. With the off the shelf boards I had many issues with sound quality both in recording and outputting. |
@darki73 just for clarification, the HA addon is based on the MA server docker image, hence ffmpeg is installed and runs inside the MA docker container on your system: |
BTW, i also found that with |
Yeah unfortunately the MA support for native HA media players is not very good in the moment. They prefer providers that speak directly from MA to the devices instead of taking the route through HA. Unfortunately I don't have the time at the moment to also implement a direct route to MA. |
You mean the provider for ESPHome? That would be a longshot! :) |
Small update, with d628b97 even the real FLAC can be played with no issues. ESP32-S3 is such a powerhouse! P.S. Forgot to mention, for some reason, with Spotify (ogg files) provider there is no issue with playing on group of players, but with YouTube Music (m4a files) experience is hit or miss. |
Hey, first of all, thank you for the great work you have done!
Issue
While using a single speaker to play anything from Music Assistant, stream goes file, everything works.
The only missing piece to make formats other than
mp3
to work was addingcodec: auto
to the media player configuration block.However, upon the creating a group of speakers, any time i try to play the audio, it results in the following errors on the device (each of them)
Log output from the device
Confuguration
I am using the following configuration:
Additional Information
I am fully aware that code from the
dev-next
is not intended to be used on a "daily basis", so i can't really say that there is an issue with the project itself.Just want to throw out there the issue i had, better to say it early than to refactor a lot of code later.
The text was updated successfully, but these errors were encountered: