Server Version#: 1.32.7.7621-871adbd44
Player Version#: Plex HTPC for Mac 1.51.1.4020-26074e51
We run Plex (server and client) on a Mac Mini M1. It’s connected via HDMI to a splitter. The splitter has an optical out, which connects to a Sonos Beam gen 1 (via optical adapter on HDMI).
This setup wouldn’t play surround sound properly until I went to the Plex HTPC audio settings and set the audio device explicitly, then set “Audio Device Type” to “Optical S/PDIF” and then checked “Dolby Digital (AC3)” and “DTS (DCA)”.
My joy at getting the surround sound working soon ended when I noticed that Plex will no longer play movies with stereo audio (tried one with “Stereo MP3” and another with “Stereo AAC”). The video just freezes, silently. If I check “Exclusive Audio”, I also get a hum when this happens.
Is there a way for me to get surround sound for compatible movies while still being able to watch stereo movies?
If I set VLC to “Audio > Audio Device > NameOfMyDevice (Encoded Output)”, it will happily play both surround sound and stereo movies – so it does not have the same issue as Plex here.
Yes, i confirm this is not fixed and could be a mpv issue as it is reproducible on both the HTPC and desktop client at least on windows and I tested it on 2 different PCs, but i see Mac is also impacted.
To reproduce this issue it’s quite simple:
Set output type as optical in the audio settings and try to play any video with Stereo AAC or MP3 sound track: the playback just freezes.
Other AC3 or AAC 5.1 is either passed through or transcoded correctly to AC3.
Here’s a workaround you can use in Plex desktop client and Plex HTPC:
Since you can modify mpv configuration, here’s a mpv.conf file you can create and add in the following directories (you can overwrite the existing one, its empty by default)
Also make sure you are in default sound configuration in Plex/Plex HTPC especially the device (autoselect).
On Windows: Plex Desktop Client: %LocalAppData%\Plex
This will passthrough native ac3 & dts tracks and transcode every other tracks that have 3 channels or more (AAC, FLAC…), this leaves AAC, FLAC, MP3 stereo… untouched and converted to PCM 2.0 as usual.
You can adapt the audio-spdif value by adding or removing formats according to your receiver support (ac3, dts, dts-hd, eac3, truehd)
Note: if you’re mpv-savy and ask yourself why a profile instead of relying on ninch option of lavcac3enc, well… that doesn’t work here: i think the issue is between some stereo codecs like AAC or MP3 not handled correctly by lavcac3enc or mpv and ninch option not working correctly in the first place.
That’s a perfect solution to this problem from Dec 2022.
In macOS using the menubar I chose my external SPDIF interface as my sound ouput.
I copied the code you gave and pasted it into /Users/nibbles/Library/Application Support/Plex HTPC/mpv.conf
I started HTPC and made the choice you described: Settings > Audio > Audio Device > Autoselect
If anyone else comes across this and it doesn’t quite work,
you might have to turn things off and on again, because
some SPDIF interfaces get confused when experimenting.
Thank you for that! It half works for me. After making the suggested changes, I can reproduce this behaviour:
First I play a bit of a “Stereo AAC” movie, which works
Then I play a bit of a “5.1 AAC” movie, which also works
Then I try to play the same stereo movie again (or any other stereo movie, seemingly) and it just freezes
If I try to play the 5.1 movie again (or any other 5.1 movie, seemingly), it still works
If I restart Plex HTPC, I can play (part of) multiple stereo movies in a row without issue. But as soon as I play a 5.1 movie, it breaks stereo movies until I restart Plex HTPC.
I had a look at mpv.conf.md and it mentions that non-absolute directives sort of stack and can apply multiple times, so I wonder if this is something similar. That the “profile-cond” isn’t properly reset or something?
This… kind of fixes the issue but introduces another.
Now, if I play a stereo movie (even as the first thing after restarting Plex HTPC) that has some progress, it opens to a freeze frame. If I hit space, it shows as though it’s paused. If I hit space again, it shows as though it’s playing. But it stays on a freeze frame. But if I skip forward and then play, it works fine. And then I can skip back to where it was and it still plays fine.
And if I play a stereo movie that does not have progress (is fully watched or unwatched), it plays fine. Or if I choose “Play from start”, that plays fine too.
It no longer has the issue I mentioned above – now I can play a 5.1 movie, then a stereo movie, and neither of them freezes/stutters aside from the “frozen until I skip” issue.
So one step forward and one step back.
Updated to note that this only happens when resuming stereo movies, not playing them from the start.
The only change from what I wrote previously is that I removed audio-channels=stereo from the stereo profile, assuming that the channels setting further up would be good enough, and that all we needed to do was to unset the af value
(There is still one remaining minor quirk that I can live with:
While Plex has a 5.1 movie open, even paused, any other computer audio will use the tinny built-in Mac speakers. So if I pause a movie and try to play YouTube in a browser, this will happen. But if I exit into the Plex menu or quit Plex, it’s back to normal.
I assume this is because Plex connects directly to the Sonos, rather than the Mac doing so on a system level.)
Glad you’ve been able to fix your issue, indeed the lavcac3enc module seems to have some issues and different ones from one OS to another as i can see.
Maybe the following is missing on Mac OS, not sure, worth a try (to be placed at the begining of mpv.conf):
reset-on-next-file=all
It resets all applied specific configuration on mpv before playing the next file and should behave as if you relaunched plex.
Also yes it’s normal other applications try to use another sound source (or no sound at all) if the spdif/hdmi passthrough is used, it becomes exclusive to the plex app in that case.
Small update: I got that freezing-until-I-skip issue on a movie with DTS-HD. Apparently the Sonos Beam does not support that. I just removed it from the passthrough list of the config; that fixed it.
(This is OP. Apparently I’m logged into another account on my phone.)