IrosTheBeggar / mStream

The easiest music streaming server available
http://mstream.io
GNU General Public License v3.0
2.22k stars 188 forks source link

BUG: ffmpeg not extracted in docker #359

Closed tidux closed 2 years ago

tidux commented 2 years ago
  1. Click "enable transcoding" in admin panel
  2. get notification ffmpeg was downloaded
  3. attempt to use ffmpeg binary
  4. get EACCESS error in logs from trying to execute ffmpeg binary
  5. docker exec -it $MSTREAM_CONTAINER_ID bash
  6. # find /opt -type f -name ffmpeg
  7. No results. Directory is empty.
  8. Check /config/.ffbinaries_cache/, see ffmpeg and ffprobe zips

For whatever reason mstream is not unzipping the binaries when run under docker. Manually unzipping the binaries worked, so the container does have unzip(1) installed.

EDIT: this appears to be a problem with enableTranscode() from src/util/admin.js not setting the default directory. Pull request incoming.

martadinata666 commented 2 years ago

So i tried and the ffmpeg downloaded enabled correctly, im on my own docker image build the log

mstream_app.1.ky3bzl15w460@homelab    | 
mstream_app.1.ky3bzl15w460@homelab    |              ____  _
mstream_app.1.ky3bzl15w460@homelab    |    _ __ ___ / ___|| |_ _ __ ___  __ _ _ __ ___
mstream_app.1.ky3bzl15w460@homelab    |   | '_ ` _ \\___ \| __| '__/ _ \/ _` | '_ ` _ \
mstream_app.1.ky3bzl15w460@homelab    |   | | | | | |___) | |_| | |  __/ (_| | | | | | |
mstream_app.1.ky3bzl15w460@homelab    |   |_| |_| |_|____/ \__|_|  \___|\__,_|_| |_| |_|
mstream_app.1.ky3bzl15w460@homelab    | v5.11.3
mstream_app.1.ky3bzl15w460@homelab    | 
mstream_app.1.ky3bzl15w460@homelab    | Check out our Discord server:
mstream_app.1.ky3bzl15w460@homelab    | https://discord.gg/AM896Rr
mstream_app.1.ky3bzl15w460@homelab    | 
mstream_app.1.ky3bzl15w460@homelab    | 2022-03-13T05:34:44.852Z info: Access mStream locally: https://localhost:3000
mstream_app.1.ky3bzl15w460@homelab    | 2022-03-13T05:34:47.909Z info: File scan started on /music
mstream_app.1.ky3bzl15w460@homelab    | 2022-03-13T05:35:29.331Z info: Metadata DB Saved
mstream_app.1.ky3bzl15w460@homelab    | 2022-03-13T05:35:29.384Z info: File scan completed with code 0
mstream_app.1.ky3bzl15w460@homelab    | 2022-03-14T05:34:44.916Z info: Successfully cleared shared playlists
mstream_app.1.ky3bzl15w460@homelab    | 2022-03-14T05:34:47.947Z info: File scan started on /music
mstream_app.1.ky3bzl15w460@homelab    | 2022-03-14T05:34:58.284Z info: Metadata DB Saved
mstream_app.1.ky3bzl15w460@homelab    | 2022-03-14T05:34:58.289Z info: File scan completed with code 0
mstream_app.1.ky3bzl15w460@homelab    | 2022-03-14T11:39:23.344Z warn: Failed login attempt from 10.0.0.2. Username: root
mstream_app.1.ky3bzl15w460@homelab    | Error: user not found
mstream_app.1.ky3bzl15w460@homelab    |     at /home/debian/mstream/src/api/auth.js:18:61
mstream_app.1.ky3bzl15w460@homelab    |     at runMicrotasks (<anonymous>)
mstream_app.1.ky3bzl15w460@homelab    |     at processTicksAndRejections (node:internal/process/task_queues:96:5)
mstream_app.1.ky3bzl15w460@homelab    | 2022-03-14T11:43:40.637Z info: Checking ffmpeg...
mstream_app.1.ky3bzl15w460@homelab    | 2022-03-14T11:45:11.650Z info: FFmpeg OK!
mstream_app.1.ky3bzl15w460@homelab    | 2022-03-14T11:55:37.348Z info: FFmpeg: file has been converted successfully

The ffmpeg config in admin page also give options to custom installation if you need to 🤔 This is the default config. 2022-03-14-184951_920x738_scrot

This should reported to LSIO mstream , as the program run as user but the directory permission still root. So when the program download ffmpeg then want to extract it got denied to bin dir not owned by user.

tidux commented 2 years ago

When I clicked on the button to edit the ffmpeg directory I got a "Coming soon!" error alert.

martadinata666 commented 2 years ago

When I clicked on the button to edit the ffmpeg directory I got a "Coming soon!" error alert.

Correct, that is why i recommends to raise and issue to LSIO docker, to make the bin dir writeable by user. Mostly just linking bin dir to /config/bin for example, or other method they prefered.

Also you could override ffmpeg dir via config file. https://github.com/IrosTheBeggar/mStream/blob/master/docs/json_config.md

"transcode": {
    "enabled": true,
    "ffmpegDirectory": "/path/to/ffmpeg-dir",
    "defaultCodec": "opus",
    "defaultBitrate": "128k"
  }
tidux commented 2 years ago

Also you could override ffmpeg dir via config file.

Sure, but when that doesn't exist by default it just fails silently, hence the PR.

martadinata666 commented 2 years ago

hence the PR wont help, as you still not have permission to extract it to that directory "opt/mstream/bin/ffmpeg. If you get the permission right, mstream will extract ffmpeg there.

Better is to set at /config/bin, but it also will break other native installation that is /path/to/mstream/bin

aptalca commented 2 years ago

This has just been fixed in the linuxserver image.

Normally, we would chown the whole app folder as abc and we would avoid such permission issues. However, docker has a weird overlayfs bug that can make the initial chown of a folder with many files extremely slow on some machines (up to 20 minutes), delaying the start of a newly created container. The bug comes and goes with kernel and docker updates and we have not been able to pin it down.

In this app, the node modules folder contain a lot of files, so we didn't chown the app folder. We incorrectly assumed the app didn't need to write anything in there (user data folders are moved to /config, which is properly chowned). We didn't realize these bins were downloaded.

The fix we implemented involves chowning the bin folder. Please let us know if there are any other folders the app would need write access to (other than bin, album-art, db and logs).

Thanks

IrosTheBeggar commented 2 years ago

@aptalca thanks for getting this fix in

mStream also uses the /save/sync folder for some upcoming features

aptalca commented 2 years ago

@IrosTheBeggar will that folder contain info that needs to be persistent through container recreation?

IrosTheBeggar commented 2 years ago

@aptalca yes it will