Plexamp headless on a Rpi 3b, no audio out over HDMI

I have a raspberry pi 3b behind a TV that primarily all it does is load a BlueIris ui3 page to monitor my security cameras. When I unmute this page, I hear audio from the TV from the cameras, so I know the pi can output audio over hdmi to the TV. I got this great idea of installing headless plexamp on this pi so I can use it to play music. I can’t seem to get the audio to play from plexamp! Any ideas?
I have selected hdmi as the playback device in plecamp’s web configuration, although I’ve also confirmed that in “sudo raspi-config” I’ve set the default audio out to HDMI, so I’ve tried “default” as the audio player as well. Nothing seems to be getting the audio out over HDMI

Again - the camera webpage is playing audio out over HDMI. Plexamp can’t seem to figure it out. Going to IPofPi:32500 and playing music, selecting the pi as the cast device, shows the music is playing but nothing audible. Casting from plexamp on my phone, the music is playing on my phone, I select the Pi as the cast device, the music stops on my phone, the timeline on plexamp continues as if the music is still playing on the pi device, but nothing audible

Please advise what else I can provide to help fix this issue

there might be other/better ways around this … but when i had similar issue, i found i had to run Plexamp as a systemd --user service (rather than the default setup as a system service) and select pulseaudio sound server as the audio output in Plexamp settings (rather than one of the alsa options)

selecting pulseaudio doesn’t seem to do anything, can you elaborate on systemd user service?

to switch to a user service, first stop/disable the current system service …

sudo systemctl stop plexamp.service
sudo systemctl disable plexamp.service

then modify/create a user service file …
(note, the following assumes pi for your username … change pi to a different username as needed in the steps below)

start with the plexamp.service file provided by Plex in the ~/plexamp directory, which should look something like this …

[Unit]
Description=Plexamp
After=network-online.target
Requires=network-online.target

[Service]
Type=simple
User=pi
WorkingDirectory=/home/pi/plexamp
ExecStart=/usr/bin/node /home/pi/plexamp/js/index.js
Restart=on-failure

[Install]
WantedBy=multi-user.target

create a copy of this file …
(create the destination directory first, if it doesn’t already exist)
cp ~/plexamp/plexamp.service ~/.config/systemd/user/plexamp.service

open the new file for editing …
nano ~/.config/systemd/user/plexamp.service

and after making changes, the file should look something like this …

[Unit]
Description=Plexamp
After=pulseaudio.service
Requires=pulseaudio.service

[Service]
Type=simple
WorkingDirectory=/home/pi/plexamp
ExecStart=/usr/bin/node /home/pi/plexamp/js/index.js
Restart=on-failure

[Install]
WantedBy=default.target

after editing, ctrl-X to save and exit the editor

now enable and start the user service …

systemctl --user daemon-reload
systemctl --user enable plexamp.service
systemctl --user start plexamp.service

Plexamp should now be running as a user service … sound should now work when you select pulseaudio server as the audio device in the web UI <hostname>:32500

2 Likes

can you confirm this part, please? I don’t have a ~/.config/systemd folder, and when I ran “sudo cp ~/plexamp/plexamp.service ~/.config/systemd/user/plexamp.service” I get the error “cp: cannot create regular file ‘/home/kitchen/.config/systemd/user/plexamp.service’: No such file or directory”

Thanks for your assistance

before creating a copy of the original plexamp.service file, you’ll need to use the mkdir command to create the directories that don’t yet exist (probably the following will work) …

mkdir -p ~/.config/systemd/user

It’s possible the HDMI output is not being activated at boot due to the TV not being detected. You can force HDMI and sound by adding, or uncommenting, the following lines in /boot/config.txt

hdmi_force_hotplug=1
hdmi_drive=2

as it happens, I do have both these things set, from my experimenting before posting here. But, as I said, a chromium website tab is able to put out audio over HDMI just fine.

kitchen@kitchenpi:~ $:  systemctl --user enable plexamp.service
Failed to enable unit: Unit file /home/kitchen/.config/systemd/user/default.target.wants/plexamp.service does not exist.

Ah - figured it out. Need to make the ~/.config/systemd/user folder as a regular user, not sudo.
It’s working! Thanks so much!

2 Likes

Can you elaborate how you did this? I believe I have the same issue, but haven’t had time to comb through my logs yet.

I primarily followed this guide: Install Headless Plexamp for your Raspberry Pi to create a Plex endpoint | How To Hi-Fi
Gotchas - First, you must be using 64 bit version of Raspios. Otherwise you get some generic errors when trying to run node.js and plexamp.
Then, step 8 of that tutorial is how to get the audio working once Plexamp is up and running, but no matter what I tried I wasn’t getting anywhere. Thanks to @tgp-2 I was finally able to get it working. As a regular user, not sudo, enter mkdir -p ~/.config/systemd/user and then follow this post: Plexamp headless on a Rpi 3b, no audio out over HDMI - #4 by tgp-2

1 Like

So far this process has worked! I need to tinker with the settings to properly output the right channels from the pi (2.0 vs. 5.1) to my preamp, but at least I have audio now!

1 Like

good to hear that the user service + pulseaudio method is working :slight_smile:

regarding what’s causing no hdmi audio out using alsa … I think it’s an issue with the current kernel graphics driver/firmware (affecting pi devices running raspberry pi OS … and maybe other derivative setups)

for folks who really want/need to use alsa (rather than pulseaudio), there is another workaround …

open /boot/config.txt for editing …

sudo nano /boot/config.txt

if you see the following uncommented line …

dtoverlay=vc4-kms-v3d

replace it with the following …

dtoverlay=vc4-fkms-v3d

then ctrl-X to save/exit the file, and sudo reboot to restart the pi

after reboot, the Plexamp settings for audio device should show a usable hdmi audio device (on the pi4, for example, it shows as bcm2834 HDMI 1)

NOTE, with this method, it is not necessary to run Plexamp as a --user service … you can use the system service configured by most Plexamp install guides/scripts.

1 Like

This solved my issue. The node command run from command line worked fine, but it was not working when running as a service.

Any ideas why it has to run as a user systemd instead of using the User=pi line?

i think it’s a combination of two things …

  1. current graphics driver (raspberry pi os) presents an hdmi audio output that can only be used with pulseaudio

  2. pulseaudio runs in user space, not accessible from a system service

So I am assuming we will need to do this with each update release? Just received 4.6.1 and now it’s broken. Need to look at the pi on settings.

depends how you updated to 4.6.2 …

most update scripts assume use of the system service, so they will try to restart it after updating … if you’ve switched to a --user service, you can either reboot or try the following to restart Plexamp …

systemctl --user restart plexamp

My script will use a user-service.

good clarification, thank you @odinb1 :slight_smile:

as I understand it, your script prepares the file for a system service, but it doesn’t enable/start it … so if a user already has an existing --user service prepared and enabled, it will still be there to start Plexamp after reboot

1 Like

Ok, the script now changes:

dtoverlay=vc4-kms-v3d

to

dtoverlay=vc4-fkms-v3d

As part of the “HDMI-audio setup”.

3 Likes