mpv icon indicating copy to clipboard operation
mpv copied to clipboard

mpv passthrough with Pipewire: "no target node available", ALSA works

Open Tatsh opened this issue 9 months ago • 15 comments

mpv Information

mpv 0.39.0 Copyright © 2000-2024 mpv/MPlayer/mplayer2 projects
libplacebo version: v7.349.0
FFmpeg version: 6.1.2
FFmpeg library versions:
   libavcodec      60.31.102
   libavdevice     60.3.100
   libavfilter     9.12.100
   libavformat     60.16.100
   libavutil       58.29.100
   libswresample   4.12.100
   libswscale      7.5.100

Other Information

- Linux version: Gentoo
- Kernel Version: Linux limelight 6.13.1-gentoo-limelight #1 SMP PREEMPT_DYNAMIC TKG Tue Feb  4 17:42:27 EST 2025 x86_64 11th Gen Intel(R) Core(TM) i9-11900K @ 3.50GHz GenuineIntel GNU/Linux
- GPU Model: 01:00.0 VGA compatible controller [0300]: NVIDIA Corporation AD102 [GeForce RTX 4090] [10de:2684] (rev a1)
- Mesa/GPU Driver Version: 570.86.16
- Window Manager and Version: Plasma 6.2.5
- Source of mpv: Gentoo ebuild
- Latest known working version: n/a

ALSA works after disabling pipewire: mpv --ao=alsa --audio-channels=5.1,stereo '--audio-device=alsa/hdmi:CARD=NVidia,DEV=1' --audio-exclusive=yes file.mkv.

Reproduction Steps

  1. Make sure AC3 is enabled: Image pw e NODE_ID Props | grep -F Codecs -A 3
  Prop: key Spa:Pod:Object:Param:Props:iec958Codecs (65553), flags 00000000
    Array: child.size 4, child.type Spa:Id
      Id 1        (Spa:Enum:AudioIEC958Codec:PCM)
      Id 3        (Spa:Enum:AudioIEC958Codec:AC3)
  1. Use this command line: mpv --ao=pipewire --audio-channels=5.1,stereo '--audio-device=pipewire/alsa_output.pci-0000_01_00.1.hdmi-surround-extra1' --audio-exclusive=yes --audio-spdif=ac3 file.mkv

Expected Behavior

Video should play. AC3 bitstream should be sent to receiver.

Actual Behavior

The video does not start. Error message:

[ao/pipewire] Stream in error state, trying to reload...
[ao/pipewire] Error during playback: No such file or directory, no target node available

Log File

output.txt.gz

Sample Files

No response

I carefully read all instruction and confirm that I did the following:

  • [x] I tested with the latest mpv version to validate that the issue is not already fixed.
  • [x] I provided all required information including system and mpv version.
  • [x] I produced the log file with the exact same set of files, parameters, and conditions used in "Reproduction Steps", with the addition of --log-file=output.txt.
  • [x] I produced the log file while the behaviors described in "Actual Behavior" were actively observed.
  • [x] I attached the full, untruncated log file.
  • [x] I attached the backtrace in the case of a crash.

Tatsh avatar Feb 05 '25 08:02 Tatsh

I'm facing exactly the same issue. And thank you @Tatsh for the trick, using alsa while specifying the device worked very well for me too! Though I also had to specify the option --audio=spdif=ac3 for it to work

avatar1024 avatar Feb 26 '25 16:02 avatar1024

Can you run mpv with the env variable PIPEWIRE_DEBUG=5 and post the output?

t-8ch avatar Mar 07 '25 06:03 t-8ch

What happens without --audio-channels=5.1,stereo '--audio-device=pipewire/alsa_output.pci-0000_01_00.1.hdmi-surround-extra1' --audio-exclusive=yes ?

t-8ch avatar Mar 07 '25 07:03 t-8ch

Can you run mpv with the env variable PIPEWIRE_DEBUG=5 and post the output?

Arguments at top of log.

With the arguments: pw-debug.log.gz

Without the arguments: pw-no-extra-args-debug.log.gz

What happens without --audio-channels=5.1,stereo '--audio-device=pipewire/alsa_output.pci-0000_01_00.1.hdmi-surround-extra1' --audio-exclusive=yes ?

Because I've set the HDMI device to default, basically the same thing.

Tatsh avatar Mar 07 '25 15:03 Tatsh

Can you also enable logs from wireplumber? wp-ctl set-log-level D? The logs will show up in journalctl --user --unit wireplumber

t-8ch avatar Mar 08 '25 12:03 t-8ch

I realised that PulseAudio Volume Control (pavucontrol-qt) really likes to grab all of the devices so I killed it, and I killed easyeffects just in case. With those not running, mpv stops on the first frame.

 $ mpv --audio-spdif=ac3 file.mkv
● Video  --vid=1  (hevc 1920x1080 29.97 fps) [default]
● Audio  --aid=1  (ac3 6ch 48000 Hz) [default]
File tags:
Failed to parse codec profile.
Using hardware decoding (nvdec).
AO: [pipewire] 48000Hz stereo 2ch spdif-ac3
VO: [gpu] 1920x1080 cuda[nv12]
[auto_profiles] Applying auto profile: fhd30
AV: 00:00:00.033 / 01:58:17.664 (0%) A-V:  0.000

I checked to make sure it wasn't my config and the same thing happens with --config=no. Adding --ao=alsa works (and I do not have to kill Pipewire).

The 'Failed to parse codec profile' message is from ad_spdif.c.

Here is the Wireplumber log: wireplumber.log.gz

Tatsh avatar Mar 09 '25 13:03 Tatsh

This looks better.

Could you provide pipewire/mpv/wireplumber logs without pavucontrol/easyeffects running for the command mpv --config=no --msg-level=ao/pipewire=trace --audio-spdif=ac3 file.mkv. I'd like to look at a consistent set of logs.

t-8ch avatar Mar 12 '25 20:03 t-8ch

And for journalctl use --output=short-iso-precise for high-res timestamps.

t-8ch avatar Mar 12 '25 20:03 t-8ch

Just for consistency in testing I am using the following commands:

To set up and run mpv (after receiver is turned on):

clear; wpctl set-log-level D; export PIPEWIRE_DEBUG=5; pw-cli s alsa_card.pci-0000_01_00.1 Profile '{ name = "output:hdmi-surround71" }' && sleep 1 && pw-cli s alsa_output.pci-0000_01_00.1.hdmi-surround71 Props '{ iec958Codecs : [ PCM DTS AC3 EAC3 TrueHD DTS-HD ] }' && systemd-cat -p info -t mpvtesting <<< 'mpv starts here' && mpv --config=no --msg-level=ao/pipewire=trace --audio-spdif=ac3 ~/Downloads/file.mkv &> ~/Downloads/mpv.log; systemd-cat -p info -t mpvtesting <<< 'mpv stops here'

mpv.log

To get the journal output:

journalctl --output=short-iso-precise -f --user _SYSTEMD_USER_UNIT=wireplumber.service + SYSLOG_IDENTIFIER=mpvtesting > ~/Downloads/wireplumber.log

wireplumber.log

In the journal log above, look for 'mpv starts here' and 'mpv stops here' text to see when mpv starts and stops.

Tatsh avatar Mar 13 '25 00:03 Tatsh

Did you manually stop mpv or did it do so automatically? It looks like playback has started "[ao/pipewire] queued 16 of 16 samples", but then got stopped from mpv. If it happened automatically we'll need some more debugging from mpv.

t-8ch avatar Mar 15 '25 13:03 t-8ch

I quit MPV. It just repeats the queued message forever.

Tatsh avatar Mar 15 '25 16:03 Tatsh

It logs one message per 16 samples. At a sample rate of 48k, it is expected to see the 3k logs per second. But 16 samples per queue does look a bit small. What does pw-top say?

t-8ch avatar Mar 15 '25 17:03 t-8ch

I will not be able to test this for a little while. The receiver is damaged from an attempted firmware update and no longer outputs video. It is going to be repaired.

Tatsh avatar Mar 16 '25 09:03 Tatsh

Same issue here, it just shows one frame and keeps spamming "[ao/pipewire] queued 16 of 16 samples". AC3/DTS works with ao=alsa or ao=pulse (but pulse gave me mistiming issues). pw-top shows something happening even tho playback is (nearly) frozen, but the ERR rate keeps increasing.

pw-top -b | grep -i iec:

S   62      0      0    ---     ---   ---   ---     0                  alsa_output.pci-0000_00_1f.3.iec958-stereo
R   62   1024  48000   3.5us   1.6us  0.00  0.00  5931  IEC958 DT 48000 alsa_output.pci-0000_00_1f.3.iec958-stereo
R   92      0  48000  14.4us   3.4us  0.00  0.00    0  IEC958 DT 48000  + mpv
R   62   1024  48000  44.2us   0.9us  0.00  0.00  5937  IEC958 DT 48000 alsa_output.pci-0000_00_1f.3.iec958-stereo
R   92      0  48000   9.3us  29.6us  0.00  0.00    0  IEC958 DT 48000  + mpv
R   62   1024  48000  31.5us   1.5us  0.00  0.00  5975  IEC958 DT 48000 alsa_output.pci-0000_00_1f.3.iec958-stereo
R   92      0  48000   9.0us  16.3us  0.00  0.00    0  IEC958 DT 48000  + mpv
R   62   1024  48000  28.9us   1.3us  0.00  0.00  6012  IEC958 DT 48000 alsa_output.pci-0000_00_1f.3.iec958-stereo
R   92      0  48000   5.3us  19.6us  0.00  0.00    0  IEC958 DT 48000  + mpv
R   62   1024  48000  16.4us   1.0us  0.00  0.00  6050  IEC958 DT 48000 alsa_output.pci-0000_00_1f.3.iec958-stereo
R   92      0  48000   4.9us   8.0us  0.00  0.00    0  IEC958 DT 48000  + mpv
I   92      0  48000  12.3us  49.2us  0.00  0.00    0  IEC958 DT 48000  + mpv
I   62   1024  48000  69.8us   1.8us  0.00  0.00  6065  IEC958 DT 48000 alsa_output.pci-0000_00_1f.3.iec958-stereo
R   62   1024  48000  66.5us   1.3us  0.00  0.00  6069  IEC958 DT 48000 alsa_output.pci-0000_00_1f.3.iec958-stereo
R   92      0  48000  10.5us  49.5us  0.00  0.00    0  IEC958 DT 48000  + mpv
R   62   1024  48000  35.9us   1.4us  0.00  0.00  6090  IEC958 DT 48000 alsa_output.pci-0000_00_1f.3.iec958-stereo
R   92      0  48000   9.9us  19.3us  0.00  0.00    0  IEC958 DT 48000  + mpv
R   62   1024  48000  45.2us   1.5us  0.00  0.00  6130  IEC958 DT 48000 alsa_output.pci-0000_00_1f.3.iec958-stereo
R   92      0  48000  12.3us  26.1us  0.00  0.00    0  IEC958 DT 48000  + mpv
R   62   1024  48000  47.7us   1.4us  0.00  0.00  6170  IEC958 DT 48000 alsa_output.pci-0000_00_1f.3.iec958-stereo
R   92      0  48000  12.0us  28.5us  0.00  0.00    0  IEC958 DT 48000  + mpv
R   62   1024  48000  57.0us   1.4us  0.00  0.00  6209  IEC958 DT 48000 alsa_output.pci-0000_00_1f.3.iec958-stereo
R   92      0  48000  13.6us  36.0us  0.00  0.00    0  IEC958 DT 48000  + mpv
R   62   1024  48000  59.0us   1.4us  0.00  0.00  6241  IEC958 DT 48000 alsa_output.pci-0000_00_1f.3.iec958-stereo
R   92      0  48000  15.4us  36.0us  0.00  0.00    0  IEC958 DT 48000  + mpv
R   62   1024  48000  47.9us   1.4us  0.00  0.00  6277  IEC958 DT 48000 alsa_output.pci-0000_00_1f.3.iec958-stereo
R   92      0  48000  11.0us  30.1us  0.00  0.00    0  IEC958 DT 48000  + mpv
R   62   1024  48000  56.6us   1.4us  0.00  0.00  6322  IEC958 DT 48000 alsa_output.pci-0000_00_1f.3.iec958-stereo
R   92      0  48000  13.6us  33.3us  0.00  0.00    0  IEC958 DT 48000  + mpv
R   62   1024  48000  28.7us   1.5us  0.00  0.00  6368  IEC958 DT 48000 alsa_output.pci-0000_00_1f.3.iec958-stereo
R   92      0  48000   7.5us  15.0us  0.00  0.00    0  IEC958 DT 48000  + mpv
R   62   1024  48000  30.8us   1.5us  0.00  0.00  6413  IEC958 DT 48000 alsa_output.pci-0000_00_1f.3.iec958-stereo
R   92      0  48000   8.1us  16.1us  0.00  0.00    0  IEC958 DT 48000  + mpv
R   62   1024  48000  33.1us   1.6us  0.00  0.00  6444  IEC958 DT 48000 alsa_output.pci-0000_00_1f.3.iec958-stereo
R   92      0  48000   9.4us  17.7us  0.00  0.00    0  IEC958 DT 48000  + mpv
R   62   1024  48000  32.8us   1.4us  0.00  0.00  6468  IEC958 DT 48000 alsa_output.pci-0000_00_1f.3.iec958-stereo
R   92      0  48000   9.7us  16.6us  0.00  0.00    0  IEC958 DT 48000  + mpv
R   62   1024  48000  49.7us   1.6us  0.00  0.00  6492  IEC958 DT 48000 alsa_output.pci-0000_00_1f.3.iec958-stereo
R   92      0  48000  12.2us  30.5us  0.00  0.00    0  IEC958 DT 48000  + mpv
R   62   1024  48000  52.9us   1.6us  0.00  0.00  6516  IEC958 DT 48000 alsa_output.pci-0000_00_1f.3.iec958-stereo
R   92      0  48000  11.8us  34.0us  0.00  0.00    0  IEC958 DT 48000  + mpv
R   62   1024  48000  39.5us   1.4us  0.00  0.00  6541  IEC958 DT 48000 alsa_output.pci-0000_00_1f.3.iec958-stereo
R   92      0  48000   9.2us  23.9us  0.00  0.00    0  IEC958 DT 48000  + mpv
R   62   1024  48000  41.7us   8.1us  0.00  0.00  6565  IEC958 DT 48000 alsa_output.pci-0000_00_1f.3.iec958-stereo
R   92      0  48000  10.3us  24.8us  0.00  0.00    0  IEC958 DT 48000  + mpv

lekzz avatar Apr 08 '25 20:04 lekzz

For me this is now working, probably after the pipewire 1.4.4 update a few days ago. Also no mistiming issues like with pulse, so seems to be working fine.

lekzz avatar Jun 03 '25 20:06 lekzz