Bug - Plex htpc outputting unsupported sample rate

Latest version of htpc is outputting at sample rates that are unticked in the windows settings.

My DAC only supports 44.1 kHz and 48 kHs, so I have all other rates unticked for my spdif output.

This has been fine up until now. E.g. a 96 kHz file would be downsampled to 48.

But in the latest version of htpc, Plex is outputting at the file sample rate regardless.

Which type of audio interface is selected in the settings of Plex HTPC? (it should be “optical”)

Hi. It makes no difference if I set it to SPDIF or leave it on auto.

SPDIF is my only enabled output sound device anyway (and as such, the default playback device).

It works fine with 44.1 kHz and 48 kHz sources. It used to work fine with other sample rates, so would have been downsampling to fit the criteria set in windows, per the compliant way wasapi exclusive should work.

I didn’t mean the actual (name of the) device but the kind of device.

Mine comes up as audio device type. But it’s besides the point unfortunately. If I set audio device to SPDIF I get no sound at all. I have to set audio device to autoselect device.

That’s off topic and I think there’s another thread on this. My problem is Plex is outputting at sample rates I’ve explicitly said are unsupported by my device.

I see you’re using a UCX. Although the RME asio driver is the best usb driver bar none, their wasapi support sucks. No source sample rate switching so you have no hope of recreating my issue. Total mix (or the RME driver) will sit there at whatever sample rate you’ve set.

What you are bringing up is really in MPV and their audio drivers. There does appear to be some MPV options to set this such as mpv.io.

If it’s related to MPV what would have changed to stop this working vs previous versions of HTPC? Has the MPV binary Plex is using changed recently?

maybe grab the Plex HTPC.log from the current version and compare it to the log from the previous HTPC when your are demonstrating the issue?

you could zip and attach them. I’ll try some 24/96 if I get a minute.

I was wrong about things working on previous versions.

Also, when I try to set the audio device as spdif I get a playback error. The log is full of possibly unrelated debug, but fundamentally seems to fail around here (see below). It’s very odd. Why is is trying to load the ac3 decoder when the filetype is FLAC? Why does setting the audio device type lead to this string of errors whereas setting to default does not?

Jul 09, 2022 18:36:35.034 [8232] DEBUG - [MPVEngine/mpv] ad: Codec list:
Jul 09, 2022 18:36:35.034 [8232] DEBUG - [MPVEngine/mpv] ad: flac - FLAC (Free Lossless Audio Codec)
Jul 09, 2022 18:36:35.034 [8232] DEBUG - [MPVEngine/mpv] ad: Opening decoder flac
Jul 09, 2022 18:36:35.034 [8232] DEBUG - [MPVEngine/mpv] ad: Requesting 1 threads for decoding.
Jul 09, 2022 18:36:35.034 [8232] DEBUG - [MPVEngine/mpv] ad: Selected codec: flac (FLAC (Free Lossless Audio Codec))
Jul 09, 2022 18:36:35.034 [8232] ERROR - [MPVEngine/mpv] lavcac3enc: Couldn’t find encoder ac3.
Jul 09, 2022 18:36:35.034 [8232] ERROR - [MPVEngine/mpv] user_filter_wrapper: Creating filter ‘lavcac3enc’ failed.
Jul 09, 2022 18:36:35.034 [8232] ERROR - [MPVEngine/mpv] cplayer: Audio filter initialized failed!
Jul 09, 2022 18:36:35.034 [8232] DEBUG - [MPVEngine/mpv] lavf: deselect track 0
Jul 09, 2022 18:36:35.034 [8232] INFO - [MPVEngine/mpv] cplayer: Audio: no audio
Jul 09, 2022 18:36:35.034 [8232] ERROR - [MPVEngine/mpv] cplayer: No video or audio streams selected.
Jul 09, 2022 18:36:35.035 [8232] ERROR - [MPVEngine] no audio or video data played.
Jul 09, 2022 18:36:35.035 [8232] DEBUG - [MPVEngine/mpv] cplayer: finished playback, no audio or video data played (reason 4)

Going back to the original problem…

When mpv queries the device for supported formats the ones disabled in control panel are not excluded so it goes ahead and uses 96 kHz :roll_eyes:

Jul 09, 2022 22:42:33.623 [9020] DEBUG - [MPVEngine/mpv] af: [in] 96000Hz stereo 2ch s32
Jul 09, 2022 22:42:33.623 [9020] DEBUG - [MPVEngine/mpv] af: [userspeed] 96000Hz stereo 2ch s32
Jul 09, 2022 22:42:33.623 [9020] DEBUG - [MPVEngine/mpv] af: [userspeed] (disabled)
Jul 09, 2022 22:42:33.623 [9020] DEBUG - [MPVEngine/mpv] af: [convert] 96000Hz stereo 2ch s32
Jul 09, 2022 22:42:33.623 [9020] DEBUG - [MPVEngine/mpv] ao: Trying audio driver ‘wasapi’
Jul 09, 2022 22:42:33.623 [9020] DEBUG - [MPVEngine/mpv] ao: Using preferred device ‘{d519a900-a796-43bc-9af9-98f142e8e9f7}’
Jul 09, 2022 22:42:33.623 [9020] DEBUG - [MPVEngine/mpv] ao/wasapi: requested format: 96000 Hz, stereo channels, s32
Jul 09, 2022 22:42:33.624 [9020] DEBUG - [MPVEngine/mpv] ao/wasapi: Selecting device by id: ‘{d519a900-a796-43bc-9af9-98f142e8e9f7}’
Jul 09, 2022 22:42:33.624 [9020] DEBUG - [MPVEngine/mpv] ao/wasapi: Selecting device ‘{d519a900-a796-43bc-9af9-98f142e8e9f7}’ (Digital Audio (S/PDIF) (High Definition Audio Device))
Jul 09, 2022 22:42:33.624 [9020] DEBUG - [MPVEngine/mpv] ao/wasapi: Monitoring changes in device {0.0.0.00000000}.{d519a900-a796-43bc-9af9-98f142e8e9f7}
Jul 09, 2022 22:42:33.625 [9020] DEBUG - [MPVEngine/mpv] ao/wasapi: Trying stereo s32 (32/32 bits) @ 96000hz (exclusive) → unsupported
Jul 09, 2022 22:42:33.625 [9020] DEBUG - [MPVEngine/mpv] ao/wasapi: Trying stereo s32 (32/32 bits) @ 48000hz (exclusive) → unsupported
Jul 09, 2022 22:42:33.626 [9020] DEBUG - [MPVEngine/mpv] ao/wasapi: Trying stereo s32 (32/24 bits) @ 48000hz (exclusive) → ok
Jul 09, 2022 22:42:33.626 [9020] DEBUG - [MPVEngine/mpv] ao/wasapi: Trying stereo s32 (32/24 bits) @ 44100hz (exclusive) → ok
Jul 09, 2022 22:42:33.626 [9020] DEBUG - [MPVEngine/mpv] ao/wasapi: Trying stereo s32 (32/24 bits) @ 96000hz (exclusive) → ok
Jul 09, 2022 22:42:33.626 [9020] DEBUG - [MPVEngine/mpv] ao/wasapi: Trying stereo s32 (32/24 bits) @ 88200hz (exclusive) → ok
Jul 09, 2022 22:42:33.626 [9020] DEBUG - [MPVEngine/mpv] ao/wasapi: Trying stereo s32 (32/24 bits) @ 192000hz (exclusive) → ok
Jul 09, 2022 22:42:33.626 [9020] DEBUG - [MPVEngine/mpv] ao/wasapi: Trying stereo s32 (32/24 bits) @ 176400hz (exclusive) → unsupported
Jul 09, 2022 22:42:33.626 [9020] DEBUG - [MPVEngine/mpv] ao/wasapi: Trying stereo s32 (32/24 bits) @ 32000hz (exclusive) → ok
Jul 09, 2022 22:42:33.626 [9020] DEBUG - [MPVEngine/mpv] ao/wasapi: Trying stereo s32 (32/24 bits) @ 22050hz (exclusive) → unsupported
Jul 09, 2022 22:42:33.627 [9020] DEBUG - [MPVEngine/mpv] ao/wasapi: Trying stereo s32 (32/24 bits) @ 11025hz (exclusive) → unsupported
Jul 09, 2022 22:42:33.627 [9020] DEBUG - [MPVEngine/mpv] ao/wasapi: Trying stereo s32 (32/24 bits) @ 8000hz (exclusive) → unsupported
Jul 09, 2022 22:42:33.627 [9020] DEBUG - [MPVEngine/mpv] ao/wasapi: Trying stereo s32 (32/24 bits) @ 16000hz (exclusive) → unsupported
Jul 09, 2022 22:42:33.627 [9020] DEBUG - [MPVEngine/mpv] ao/wasapi: Trying stereo s32 (32/24 bits) @ 352800hz (exclusive) → unsupported
Jul 09, 2022 22:42:33.627 [9020] DEBUG - [MPVEngine/mpv] ao/wasapi: Trying stereo s32 (32/24 bits) @ 384000hz (exclusive) → unsupported
Jul 09, 2022 22:42:33.627 [9020] DEBUG - [MPVEngine/mpv] ao/wasapi: Trying 5.1 s32 (32/24 bits) @ 96000hz (exclusive) → unsupported
Jul 09, 2022 22:42:33.627 [9020] DEBUG - [MPVEngine/mpv] ao/wasapi: Trying 7.1 s32 (32/24 bits) @ 96000hz (exclusive) → unsupported
Jul 09, 2022 22:42:33.627 [9020] DEBUG - [MPVEngine/mpv] ao/wasapi: Trying 6.1 s32 (32/24 bits) @ 96000hz (exclusive) → unsupported
Jul 09, 2022 22:42:33.627 [9020] DEBUG - [MPVEngine/mpv] ao/wasapi: Trying mono s32 (32/24 bits) @ 96000hz (exclusive) → unsupported
Jul 09, 2022 22:42:33.627 [9020] DEBUG - [MPVEngine/mpv] ao/wasapi: Trying 2.1 s32 (32/24 bits) @ 96000hz (exclusive) → unsupported
Jul 09, 2022 22:42:33.628 [9020] DEBUG - [MPVEngine/mpv] ao/wasapi: Trying 4.0 s32 (32/24 bits) @ 96000hz (exclusive) → unsupported
Jul 09, 2022 22:42:33.628 [9020] DEBUG - [MPVEngine/mpv] ao/wasapi: Trying 5.0 s32 (32/24 bits) @ 96000hz (exclusive) → unsupported
Jul 09, 2022 22:42:33.628 [9020] DEBUG - [MPVEngine/mpv] ao/wasapi: Trying 3.0 s32 (32/24 bits) @ 96000hz (exclusive) → unsupported
Jul 09, 2022 22:42:33.628 [9020] DEBUG - [MPVEngine/mpv] ao/wasapi: Trying 3.0(back) s32 (32/24 bits) @ 96000hz (exclusive) → unsupported
Jul 09, 2022 22:42:33.628 [9020] DEBUG - [MPVEngine/mpv] ao/wasapi: Trying quad s32 (32/24 bits) @ 96000hz (exclusive) → unsupported
Jul 09, 2022 22:42:33.628 [9020] DEBUG - [MPVEngine/mpv] ao/wasapi: Trying quad(side) s32 (32/24 bits) @ 96000hz (exclusive) → unsupported
Jul 09, 2022 22:42:33.628 [9020] DEBUG - [MPVEngine/mpv] ao/wasapi: Trying 3.1 s32 (32/24 bits) @ 96000hz (exclusive) → unsupported
Jul 09, 2022 22:42:33.629 [9020] DEBUG - [MPVEngine/mpv] ao/wasapi: Trying 5.0(side) s32 (32/24 bits) @ 96000hz (exclusive) → unsupported
Jul 09, 2022 22:42:33.629 [9020] DEBUG - [MPVEngine/mpv] ao/wasapi: Trying 4.1 s32 (32/24 bits) @ 96000hz (exclusive) → unsupported
Jul 09, 2022 22:42:33.629 [9020] DEBUG - [MPVEngine/mpv] ao/wasapi: Trying 5.1(side) s32 (32/24 bits) @ 96000hz (exclusive) → unsupported
Jul 09, 2022 22:42:33.629 [9020] DEBUG - [MPVEngine/mpv] ao/wasapi: Trying 6.0 s32 (32/24 bits) @ 96000hz (exclusive) → unsupported
Jul 09, 2022 22:42:33.629 [9020] DEBUG - [MPVEngine/mpv] ao/wasapi: Trying 6.0(front) s32 (32/24 bits) @ 96000hz (exclusive) → unsupported
Jul 09, 2022 22:42:33.629 [9020] DEBUG - [MPVEngine/mpv] ao/wasapi: Trying 6.0(front) s32 (32/24 bits) @ 96000hz (exclusive) → unsupported
Jul 09, 2022 22:42:33.629 [9020] DEBUG - [MPVEngine/mpv] ao/wasapi: Trying 6.1(front) s32 (32/24 bits) @ 96000hz (exclusive) → unsupported
Jul 09, 2022 22:42:33.629 [9020] DEBUG - [MPVEngine/mpv] ao/wasapi: Trying 7.0 s32 (32/24 bits) @ 96000hz (exclusive) → unsupported
Jul 09, 2022 22:42:33.629 [9020] DEBUG - [MPVEngine/mpv] ao/wasapi: Trying 7.0(front) s32 (32/24 bits) @ 96000hz (exclusive) → unsupported
Jul 09, 2022 22:42:33.629 [9020] DEBUG - [MPVEngine/mpv] ao/wasapi: Trying 7.1(wide) s32 (32/24 bits) @ 96000hz (exclusive) → unsupported
Jul 09, 2022 22:42:33.630 [9020] DEBUG - [MPVEngine/mpv] ao/wasapi: Trying 7.1(wide-side) s32 (32/24 bits) @ 96000hz (exclusive) → unsupported
Jul 09, 2022 22:42:33.630 [9020] DEBUG - [MPVEngine/mpv] ao/wasapi: Trying empty s32 (32/24 bits) @ 96000hz (exclusive) → unsupported
Jul 09, 2022 22:42:33.630 [9020] DEBUG - [MPVEngine/mpv] ao/wasapi: Trying octagonal s32 (32/24 bits) @ 96000hz (exclusive) → unsupported
Jul 09, 2022 22:42:33.630 [9020] DEBUG - [MPVEngine/mpv] ao/wasapi: Channel layouts:
Jul 09, 2022 22:42:33.630 [9020] DEBUG - [MPVEngine/mpv] ao/wasapi: - stereo
Jul 09, 2022 22:42:33.630 [9020] DEBUG - [MPVEngine/mpv] ao/wasapi: result: stereo
Jul 09, 2022 22:42:33.630 [9020] DEBUG - [MPVEngine/mpv] ao/wasapi: Accepted as stereo s32 @ 96000hz → stereo s32 (32/24 bits) @ 96000hz (exclusive)

Really interesting how your log shows MPV checking a lot of formats.

I joined another thread about Optical output failing, and ran my own tests of a film with 5.1 AC3.

I didn’t get any sound, and I found that the player was trying to load an ac3 encoder into the chain instead of Direct Playing what it agreed to Direct Play, just like you found.

As far as your MPV decision goes, if you have direct stream setup, your server is allowed to send you the flac files unchanged. On the player if you have Direct Play set up, then the player has to decide whether it can output those flacs directly to your device. The decision looks to be in the hands of MPV, at first glance.

So you might try the standalone MPV or the one in the HTPC client if it’s accessible, ran in verbose mode . That’s what I did to isolate a playback issue I had.

I can’t send FLAC to my DAC. So I can’t help as much as I’d like.

Thanks Nibbles…

I think you’re right. Ideally I would need Plex HTPC to allow me to set a ‘max sample rate’ in the settings and then use a bit of logic to tell MPV what to do when the sample rate of the file exceeds the max I set (e.g. 88.2 kHz, use 44.1 kHz; 96 kHz use 48 kHz etc.). Kodi has such a feature.

I’ve looked at what MPV can do and it’s basically limited to setting one single sample rate. This is not what I want to do - most of my files are either 44.1 kHz or 48 kHz and my DAC supports both. It’s only the odd 88.2 and 96 kHz file I need to be downsampled.

I think MPV can work with scripts (Lua?) but don’t know if the sort of logic I need here could be added to the conf?

Oh yes, and the whole ac3 thing is weird. I just gave up on this and set the audio device to ‘Basic’.

I’m testing separate libraries for my hi-res audio, surround, 48orLESS, and live recordings.

I’m keeping multiple copies of the same album in 48 and 96 for example.
I let all the Plex scanning and new features loose on the 48orless library.
In the Hi-Res and Surround libraries, I only let Plex match the album.
And in Live Recordings everything is local and tagged.

Even if you can’t find enough options in MPV, we won’t be able to isolate the unexpected behavior until you test the standalone version in your hardware chain, which I realize isn’t trivial. I think we can see the command Plex sends to MPV, but I’m not there yet.

On my end, I finally got through setting up bit-perfect playback on my HiFi Berry DAC that I have attached to the top of a Raspberry Pi 4B. I have yet to connect that to Plex though. Still working on the method. AirPlay isn’t an option because AirPlay2 is capped at 48kHz afaik. I’m gong to try DLNA today.

If I get that working or a direct USB link, I will start sending FLACs to my DAC that are out of spec using mpv

Hi nibbles. In the end I just ran a high quality downsampler on my >48 kHz files.

It was either that or buy something like a Topping DAC but my old Meridian is perfectly adequate.

Oh nice workaround. Which Topping did you consider? I’ve been reading how my DAC suffers from a fair bit of jitter.

I did start on getting Plex → rPi working for music, but no fun so far. DLNA is messy, but then I found I should be able to run PlexAmp on the rPi. I just have to figure how to crowbar it into HiFiBerry OS.

Also there’s a new Plex HTPC version that’s been pushed out. Some of have found it works correctly now when set to Optical S/PDIF (rather than Basic or HDMI). How does this one work?

Think it was the d30pro but was put off by too low cutoff frequency on most of the filters, which will result in aliasing, and their steeper filters which ripple badly.

It’s my main gripe with the audioscience forum. They spend all that time making a decent set of measurements but sometimes the results look suspect and then they don’t check aliasing, hmmmmm.

Anyway, sorry, drifting way off topic :slight_smile:

@PlexJB Another user named Stevenha made an interesting discovery about MPV trying channels and sample rates. Maybe you can get a chance to test his theory on your files too.

Always hard to figure out other people’s setups without specifics, but sounds to me like they’re not in Exclusive Mode.

I don’t really have a leg to stand on with my issue unfortunately. It’s entirely up to the playback app to interpret unsupported formats and work accordingly. The mindset of the Plex devs just doesn’t seem to work like that of the Kodi or JRiver or Foobar (etc.) guys and they tend not to budge on certain things like this. Maybe it’s a lack of ocd traits - I guess some people are born lucky :slight_smile:

When you said you get no sound at all when you choose SPDIF, does that mean

  • You get no sound for 16/44.1 normal wave tracks?
  • You get no sound for 24/96 hi-res wave tracks?

If the problem is more or less that Plex used to convert the 24/96 down to 16/48 and output that supported depth/rate on the fly but doesn’t now, then I think I failed to understand “no sound at all.”

The issue of exclusive let’s table for now.