Streaming mp3, aac, etc. with atvremote/pyatv to my soundbar works but I can't hear anything
helgek opened this issue · 14 comments
Describe the bug
Hi,
I have the Samsung HW-S801B soundbar which only supports Airplay as input source besides HDMI. Chromecast is also not supported so I ended up trying to find an Airplay capable audio player solution for linux.
After successful installation of pyatv I use the following command which successfully establishes a connection to the soundbar and atvremote stays connected for the time of the length of the audio file:
atvremote --id 80:8A:BD:16:B9:BB stream_file=sample-file-2.mp3
The Samsung SmartLife app the status states that the soundbar is playing audio over WiFi while this command is running. But unfortunately I can't hear any audio. Of I checked volume settings and playing from my iOS or MacOS devices works fine.
I also tried Apple TV Home Assistant integration with the same outcome.
I hope the log file attached can be of help.
logfile.txt
Thank you,
Helge
Error log
please see the logfile attached, no error(s) though as far as I can see.
logfile.txt
How to reproduce the bug?
Possibly with other Airplay based (Samsung) soundbars (?)
What is expected behavior?
hear audio instead of silence from the soundbar.
Operating System
Debian 12.4
Python
Other
pyatv
0.14.5
Device
Samsung Soundbar HW-S801B
Additional context
When I tested with Apple TV integration I used Home Assistant OS installation.
additional finding today with the same outcome (the soundbar would act in the SmartThings app as if it was playing, but I can't hear any sound). After installing pipewire I ran these commands:
~$ pactl list sinks
which would return:
Sink #95
State: SUSPENDED
Name: raop-sink-507-15
Description: Samsung Soundbar S801B
Driver: PipeWire
Sample Specification: s16le 2ch 44100Hz
Channel Map: front-left,front-right
Owner Module: 4294967295
Mute: no
Volume: front-left: 65536 / 100% / 0.00 dB, front-right: 65536 / 100% / 0.00 dB
balance 0.00
Base Volume: 65536 / 100% / 0.00 dB
Monitor Source: raop-sink-507-15.monitor
Latency: 0 usec, configured 0 usec
Flags: DECIBEL_VOLUME LATENCY
Properties:
node.name = "raop-sink-507-15"
device.description = "Samsung Soundbar S801B"
node.latency = "352/44100"
node.virtual = "true"
media.class = "Audio/Sink"
media.name = "RAOP sink"
stream.is-live = "true"
node.want-driver = "true"
adapt.follower.spa-node = ""
object.register = "false"
factory.id = "6"
clock.quantum-limit = "8192"
factory.mode = "merge"
audio.adapt.follower = ""
library.name = "audioconvert/libspa-audioconvert"
client.id = "52"
object.id = "56"
object.serial = "95"
Formats:
pcm
Then I did
~$ pactl upload-sample CantinaBand3.wav testfile_Wav
and eventually
~$ pactl play-sample testfile_Wav raop-sink-507-15
-> the file is being streamed to the soundbar but I can't hear anything.
One more thought: I think to recall that I found one comment during my search for a solution that stated that modifying latency helped in a similar setup. Unfortunately I can't find it anymore but I thought it's maybe worth mentioning as well. Thank you again for any additional input that might help in my case.
Adding a cross-reference to home-assistant/core#95993 (comment) since they might be related
Adding Home Assistant Apple TV integration debug log as well:
Maybe this is an explanation why it doesn't work: https://community.roonlabs.com/t/implementation-of-airplay-2/229509/5 . Since the Samsung Soundbars are probably not backwards compatible to Airplay 1 and there might not be any working third party implementation to stream AirPlay2 audio to AirPlay2 receivers anytime soon this issue will possibly remain unsolved for now.
Same issue also here: owntone/owntone-server#1465
pyatv supports streaming via AirPlay 2 and does so if the receiver supports it. It's possible to force a specific version via a setting (https://pyatv.dev/api/settings/#pyatv.settings.RaopSettings.protocol_version).
But you are likely right that it does not support AirPlay 1. Problem with sound not working is a bug that I haven't managed to figure out.
Thank you for the follow-up. I had also tried forcing the protocol version I think, with the same outcome.
Just adding this thread where latency settings could potentially play a role regarding successful sound output (though my understanding of all this is really shallow): https://gitlab.freedesktop.org/pipewire/pipewire/-/issues/3804
Can you try if release 0.15.1 (just released) works? I found an issue with sequence numbering being incorrectly set for audio packets. Apple devices doesn't seem to care, but third party vendors might do. No guarantee, worth trying though.
@postlund , thanks for posting. So I'm new to using pyatv outside of the Home Assistant integrations. I've just installed 0.15.1.
I have some music playing on my Samsung Soundbar via AirPlay, but seeing a Device state of "idle" from the command-line.
Should I be seeing that proper playing status? Also, please let me know if you want me to try testing something from the command line, or via a Python script:
@rofy007 Nah, for third party speakers you won't see anything as of now. It's technically possible to see that a receiver is playing (via Zeroconf), but not what it actually id playing. At least that's what I know as of today.
So you mean that you are steaming music via AirPlay from pyatv or from another device? I'm mainly interested in if streaming from pyatv is solved.
@postlund ok, got it. So I tried to stream an MP3 to my Samsung soundbars. I'm not getting errors, but still no sound is coming out. This does work on my Yamaha receivers.
D:\Google Drive\Development\Python\pyatv>python StreamMP3.py "192.168.0.21" "0
3 Dammit.mp3"
D:\Google Drive\Development\Python\pyatv\StreamMP3.py:12: DeprecationWarning: There is no current event loop
LOOP = asyncio.get_event_loop()
* Discovering device on network...
* Connecting to 192.168.0.21
* Starting to stream 03 Dammit.mp3
------------------------------
Media type: Unknown
Device state: Idle
------------------------------
Media type: Music
Device state: Playing
Title: Dammit
Artist: Blink 182
Album: Greatest Hits
Position: 0/166s (0.0%)
@postlund thank you for the update! Because I don't have a separate instance at hand right now I'd test with the next HA Core release. The latest 2024.9.0 release has pyatv 0.15.0 release in the changelog, so I assume with 2024.9.1 the latest 0.15.1 should be included in a couple of days.