navidrome / navidrome

🎧☁️ Modern Music Server and Streamer compatible with Subsonic/Airsonic
https://www.navidrome.org
GNU General Public License v3.0
10.16k stars 783 forks source link

[Bug]: mpv missing in docker image and no mention in documentation #2910

Closed michaelkrieger closed 3 weeks ago

michaelkrieger commented 2 months ago

I confirm that:

Version

0.51.1

Current Behavior

$ docker exec -ti navidrome sh
/app $ mpv --audio-device=help
sh: mpv: not found

Expected Behavior

Docker container should have mpv to enable jukebox mode for architectures where it is supported. Alpine mpv packages exist.

Steps To Reproduce

We can use jukebox mode in docker by either passing /dev/snd to the container (for exclusive use by navidrome) or ideally passing the pulseaudio socket at /run/user/1000/pulse (for non-exclusive use of the audio output which is more friendly to other system applications).

The dockerfile should be updated to add the mpv package to the container by default.

Environment

- OS: Docker running on Debian Stable
- Browser: Chrome
- Client: N/A

How Navidrome is installed?

Docker

Configuration

relevant excerpt

  navidrome:
    user: 1000:1000
    devices:
      - /dev/snd
    environment:
      ND_JUKEBOX_ENABLED: "true"
    volumes:
      - /run/user/1000/pulse/:/run/user/1000/pulse/

Relevant log output

Version: 0.51.1 (6d253225)
...
time="2024-03-16T18:48:46Z" level=info msg="Starting playback server"
time="2024-03-16T18:48:46Z" level=info msg="1 audio devices found"
time="2024-03-16T18:48:46Z" level=info msg="Using audio device: auto"
...
time="2024-03-16T18:48:46Z" level=info msg="----> Navidrome server is ready!" address="0.0.0.0:4533" startupTime=18.9ms tlsEnabled=false

Anything else?

# docker exec -ti --user root navidrome sh
/app # apk add mpv
...
OK: 202 MiB in 179 packages

/app # mpv --audio-device=help
List of detected audio devices:
  'auto' (Autoselect device)
  'alsa' (Default (alsa))
  'alsa/default:CARD=PCH' (HDA Intel PCH, ALC233 Analog/Default Audio Device)
  'alsa/sysdefault:CARD=PCH' (HDA Intel PCH, ALC233 Analog/Default Audio Device)
  'alsa/front:CARD=PCH,DEV=0' (HDA Intel PCH, ALC233 Analog/Front output / input)
  'alsa/surround21:CARD=PCH,DEV=0' (HDA Intel PCH, ALC233 Analog/2.1 Surround output to Front and Subwoofer speakers)
  'alsa/surround40:CARD=PCH,DEV=0' (HDA Intel PCH, ALC233 Analog/4.0 Surround output to Front and Rear speakers)
  'alsa/surround41:CARD=PCH,DEV=0' (HDA Intel PCH, ALC233 Analog/4.1 Surround output to Front, Rear and Subwoofer speakers)
  'alsa/surround50:CARD=PCH,DEV=0' (HDA Intel PCH, ALC233 Analog/5.0 Surround output to Front, Center and Rear speakers)
  'alsa/surround51:CARD=PCH,DEV=0' (HDA Intel PCH, ALC233 Analog/5.1 Surround output to Front, Center, Rear and Subwoofer speakers)
  'alsa/surround71:CARD=PCH,DEV=0' (HDA Intel PCH, ALC233 Analog/7.1 Surround output to Front, Center, Side, Rear and Woofer speakers)
  'alsa/hdmi:CARD=PCH,DEV=0' (HDA Intel PCH, HDMI 0/HDMI Audio Output)
  'alsa/hdmi:CARD=PCH,DEV=1' (HDA Intel PCH, HDMI 1/HDMI Audio Output)
  'alsa/hdmi:CARD=PCH,DEV=2' (HDA Intel PCH, HDMI 2/HDMI Audio Output)
  'jack' (Default (jack))
  'sndio' (Default (sndio))

Once this is done, mpv exists and can see all of the sound devices on the system, though navidrome has already tried to enumerate devices and doesn't show any in the web interface.

Alternately, the documentation should be updated to advise whether this is not supported in a docker configuration. Right now, jukebox mode doesn't work in docker, but there is no mention of this or why.

Code of Conduct

MRodneyMcKay commented 3 weeks ago

Hope that this bugreport will be more successfull, than my feature request. I would like to use jukebox mode on a truenas app, and their support says thatonce mpv is present at the docker, they can experiment with sound devices, playback modes, but until then, they cannot do anything

deluan commented 3 weeks ago

Adding MPV to the image increases its size considerably: Current:

deluan/navidrome                     develop              4a7c5af5cb83   6 minutes ago   173MB

With MPV:

deluan/navidrome                     develop              c1dda16003ca   7 seconds ago   246MB

I don't think it is worthy adding it by default, as most users don't use the Jukebox mode.

Ideally we would have to change the pipeline/release process to add a new Docker image variant, including MPV. Contributions are most welcome :)

In the meantime, you could create your own image, by using this simple Dockerfile:

FROM deluan/navidrome:latest
RUN apk add --no-cache mpv
michaelkrieger commented 3 weeks ago

Adding MPV to the image increases its size considerably I do wonder if all the dependencies are required for this purpose, as MPV isn’t huge in itself. I’ll have a look at what is required.

Ideally we would have to change the pipeline/release process to add a new Docker image variant, including MPV. Agreed. A new tag with MPV is helpful.

Also, I’m not sure disk size is a huge consideration for most folks on container size, but I understand wanting a small core container.

MRodneyMcKay commented 3 weeks ago

I don't think it is worthy adding it by default, as most users don't use the Jukebox mode.

Right now, the app has a feature, which, ideally, should be supported on all platforms.

Adding MPV to the image increases its size considerably:

I understand your consertn about needlessly increase the image size, with, arguably bloat. However, there are certain usecases, (like on TrueNAS), where you cannot really edit the docker. Would it really be that hard and resource intensive, to publish another docker train, with jukebox support? So itnot only contains MPV, but all relevant config to make it actually work (a simple direct strem to an ALSA device, no need to play with pulse sockets/pipes). How can I contribute to the release proccess, so it would work?

deluan commented 3 weeks ago

where you cannot really edit the docker.

I'm not suggesting editing an image, but to create your own using the Dockerfile mentioned above.

Would it really be that hard and resource intensive, to publish another docker train, with jukebox support?

Is not that hard, but it is also not free. Remember, this is an open source project that I work on in my spare time...

So itnot only contains MPV, but all relevant config to make it actually work (a simple direct strem to an ALSA device, no need to play with pulse sockets/pipes). How can I contribute to the release proccess, so it would work?

I decided to add mpv to the image, as you can see in ca005f6457fcd57f5fb8abb731fc947d44b880. In the end, using Alpine 3.18, it only added ~20MB uncompressed (~10%). But I don't have any means to test it on TrueNAS, so feel free to contribute with changes required to make it work.

MRodneyMcKay commented 3 weeks ago

Thank you, this works great in a docker in arch! From now on, we will need to work on the Truenas app release/config. This commit solved our issue, this can get merged, if it is alright