jlesage / docker-makemkv

Docker container for MakeMKV
MIT License
454 stars 52 forks source link

Help getting this working #40

Closed rome1983 closed 5 years ago

rome1983 commented 5 years ago

Hi, I have a synology ds1815+ and I’m trying to figure out to change the parameters. I’m able to see MAKEMKV GUI on the webpage but need help getting it to find my optical disc drive.

rome1983 commented 5 years ago

Found my optical disc drive @ /dev/sg6 but on the webpage I get program can’t find any usable optical drives.

jlesage commented 5 years ago

Look at the container’s log: you will see clear messages about which Linux devices need to be exposed to the container.

rome1983 commented 5 years ago

The log only shows sg6 needing to be exposed and gives a warning that performance might suffer because it doesn't see /dev/sr*.

C4Wiz commented 5 years ago

straight from my log: [cont-init.d] 95-check-optical-drive.sh: found optical drive [/dev/sr0, /dev/sg10]

jlesage commented 5 years ago

You normally have to expose 2 devices. Can you provide the whole log?

C4Wiz commented 5 years ago

edit the container, in the extra parameters section add: --device /dev/sr0 --device /dev/sg0 --device /dev/sg1 --device /dev/sg2 --device /dev/sg3 --device /dev/sg4 --device /dev/sg5 --device /dev/sg6 --device /dev/sg7 --device /dev/sg8 --device /dev/sg9 --device /dev/sg10

this will keep you covered over reboots in case it changes

rome1983 commented 5 years ago

I can provide the whole log a few hours.

rome1983 commented 5 years ago

@ c4wiz are you using a synology nas? I will be back home in few hours. It would awesome to get this work.

C4Wiz commented 5 years ago

@ c4wiz are you using a synology nas? I will be back home in few hours. It would awesome to get this work.

No, im Using unRAID v. 6.6.6

rome1983 commented 5 years ago

I started it from the CLI like this. docker run -d \

--name=makemkv \
-p 5800:5800 \
-v /docker/appdata/makemkv:/config:rw \
-v $HOME:/storage:ro \
-v $HOME/MakeMKV/output:/output:rw \
--device /dev/sg6 \
jlesage/makemkv

makemkv.html.zip

jlesage commented 5 years ago

Looks like one device is not properly detected. Could you provide the output of:

docker exec makemkv lsscsi -g -k
rome1983 commented 5 years ago

[0:0:0:0] disk HGST HDN726040ALE614 APGN /dev/sdc /dev/sg0 [1:0:0:0] disk HGST HDN726040ALE614 APGN /dev/sdd /dev/sg1 [2:0:0:0] disk HGST HDN726040ALE614 APGN /dev/sde /dev/sg2 [4:0:0:0] disk HGST HDN726040ALE614 APGN /dev/sda /dev/sg3 [5:0:0:0] disk HGST HDN726040ALE614 APGN /dev/sdb /dev/sg4 [10:0:0:0] disk Synology DiskStation PMAP /dev/synoboot /dev/sg5 [13:0:0:0] cd/dvd ASUS BW-16D1HT 3.01 - /dev/sg6

jlesage commented 5 years ago

Looks like the Linux CDROM driver (sr) is not loaded. Can you provide the output of the following command:

lsmod|grep sr
jlesage commented 5 years ago

It seems that Synology doesn't officially supports optical drives: https://www.synology.com/en-global/knowledgebase/DSM/tutorial/Compatibility_List/Does_Synology_Product_support_external_DVD_RW_DVD_ROM_CD_ROM_or_CD_RW_drive

But it seems that some users were able to compile proper drivers and make it work.

rome1983 commented 5 years ago

I just got it detected with sudo chmod 660 /dev/sg6 . about to try a disc now.

jlesage commented 5 years ago

Do you know what were the permissions and the owner of the device before the change? This is something that should have been caught by the detection script.

rome1983 commented 5 years ago

Before crw------- 1 root root After crw-rw---- 1 root root

rome1983 commented 5 years ago

Also no extra parameters section on synology.

jlesage commented 5 years ago

To which value did you configured USER_ID and GROUP_ID?

rome1983 commented 5 years ago

Im trying to figure it out now because I keep getting error posix when trying to write to directory.

rome1983 commented 5 years ago

Just set it 0 to test and it works, will figure out permissions when it finish.

rome1983 commented 5 years ago

uid=1026(rome1931) gid=100(users) groups=100(users),101(administrators) I tried 1026 and 100 without success.

jlesage commented 5 years ago

Look at the ownership and permission of the folder you mapped to /output.

rome1983 commented 5 years ago

I had figured it out, but the ripping speed is super slow. 1.1x
When I ripped as root it was 5.5x and I didnt let it finish to see top speed.

rome1983 commented 5 years ago

It took a while, but rip speed got faster. Thank you

rome1983 commented 5 years ago

No cdrom module on synology. Your detection script did detect it, right after the [ -, sg6] was group 0. I didn’t know that was the root group.

rome1983 commented 5 years ago

The permissions kept changing on reboot. I was able to solve that with a udev rule and creating a cdrom group and adding myself to it. SUBSYSTEMS=="usb", ATTRS{idVendor}=="", ATTRS{idProduct}=="", GROUP="cdrom", MODE="0660"

agster27 commented 5 years ago

Hello! This is a great Container and love the work put into it! Can someone point me in the right direction on how other Synology users got a dvd drive to work?

The logs show the container can see the drive. How do I expose the dvd?

2019-01-24 02:48:19 stdout [cont-init.d] 95-check-optical-drive.sh: WARNING: for best performance, the host device - needs to be exposed to the container.
2019-01-24 02:48:19 stdout [cont-init.d] 95-check-optical-drive.sh: found optical drive [-, /dev/sg5], group 0.
rome1983 commented 5 years ago

Everything I did is in this thread.

jlesage commented 5 years ago

To expose the drive, see https://github.com/jlesage/docker-makemkv#access-to-optical-drives

agster27 commented 5 years ago

To expose the drive, see https://github.com/jlesage/docker-makemkv#access-to-optical-drives

In Synology you cannot pass a --device option to the container. Or at least I cannot figure out how! Sorry I was not more clear. I was curious if someone figured out how to pass the --device option.

jlesage commented 5 years ago

I guess you mean you cannot pass a device when using the UI to create the container?

rome1983 commented 5 years ago

Did you bother to read this thread?

agster27 commented 5 years ago

Did you bother to read this thread?

@rome1983 I did! It was not clear how you passed the --device to the container in Synology. I read it a few times. Any help would be appreciated.

agster27 commented 5 years ago

I guess you mean you cannot pass a device when using the UI to create the container?

I didn't try to pass --device when I "created" the container... I only tried it after I created it. I'll try that now! :)

rome1983 commented 5 years ago

You also need to change permissions on the drive. See above udev rule. Cdrom group doesn’t exist, you have to create it and add yourself to it.

agster27 commented 5 years ago

@rome1983 and @jlesage I made the permission changes and so far it seems to be working. I still cannot figure out for the life of me how to "present" the device syntax when creating the container in Synology under the "Execute command" field. I tried to put just "--device /dev/sg05" in the field and the container would not start up. I think the syntax was/is wrong. I'll send a screen shot with an error.

You guys have been super helpful. I might have more questions if you do not mind.

rome1983 commented 5 years ago

From the command line my config is Not showing right on my phone docker run -d \ --name=makemkv \ -p 5800:5800 \ -e USER_ID=1026 \ -e GROUP_ID=100 \ -v /volume1/docker/appdata/makemkv:/config:rw \ -v $HOME:/storage:ro \ -v /volume1/MyMedia/Movies:/volume1/MyMedia/Movies:rw \ --device /dev/sg7 \ jlesage/makemkv

S8ShowBob commented 7 months ago

And yet another new user who can't manage to use the BlueRay drive.

In the meantime I have read quite a few threads about it, but still can't get it to work.

I'm not using Docker on my Synology DS923+ (DSM 7.2.1-69057 Update 3), but the "Container Manager". JDownloader-2, Handbrake, MKVToolNix work without any problems.

But with MakeMKV I can't get access to my "BUFFALO Optical Drive". This message appears:

2024/04/03 21:34:19,stdout,[cont-init] 54-check-optical-drive.sh: no usable optical drive found.
2024/04/03 21:34:19,stdout,[cont-init] 54-check-optical-drive.sh:   --> the host device /dev/sg5 is not exposed to the container.
2024/04/03 21:34:19,stdout,[cont-init] 54-check-optical-drive.sh:   --> the host device - is not exposed to the container.
2024/04/03 21:34:19,stdout,"[cont-init] 54-check-optical-drive.sh: found optical drive [-, /dev/sg5], but it is not usable because:
2024/04/03 21:34:19,stdout,[cont-init] 54-check-optical-drive.sh: looking for usable optical drives... 

I tried my admin user (uid=1026, gid=101).

su@NAS:/$ cat /etc/passwd | grep -E 'su|root'
root:x:0:0::/root:/bin/ash`
su:x:1026:100::/var/services/homes/su:/bin/sh

Still no access, then i tried uid=0, gid=0 (root). Again, no access to it. Then i tried like rome1983:

su@NAS:/$ ls -l dev/sg5
crw------- 1 root root 21, 5 Apr  3 21:07 dev/sg5

su@NAS:/$ sudo chmod 660 dev/sg5
su@NAS:/$ ls -l dev/sg5
crw-rw---- 1 root root 21, 5 Apr  3 21:07 dev/sg5

Still no access. I guess I'll have to keep using the drive on my computer, the DS923+ don't accept it. Or replace the "Container Manager" with Docker and try that.

But I would like to avoid that if possible. (PS: The "Container Manager" is the new Docker)


UPDATE:

Well... it finally works. Instead of creating the container the lazy way, I created a project in the "Container Manager" -> example.

There I had the possibility to add a compose.yml where I could add the device (and it's working).

compose.yml

version: '3'
services:
    makemkv:
        image: jlesage/makemkv:latest
        container_name: makemkv
        restart: unless-stopped
        ports:
          - "5802:5802"
          - "5902:5902"
        environment:
          MAKEMKV_KEY: *****
          USER_ID: 1026
          GROUP_ID: 101
          AUTO_DISC_RIPPER: 0
          APP_NICENESS: 0
          WEB_LISTENING_PORT: 5802
          VNC_LISTENING_PORT: 5902
          VNC_PASSWORD: *****
          MAKEMKV_GUI: 1
          DISPLAY_WIDTH: 1920
          DISPLAY_HIGHT: 1080
       volumes:
      - "/volume1/docker/appdata/makemkv:/config:rw"
      - "/volume1/video/storage:/storage:ro"
      - "/volume1/video/output:/output:rw"
    devices:
      - "/dev/sg5:/dev/sg5"

Drive eject doesn't work... but who cares...

final

rome1983 commented 1 month ago

Good news, sr_mod.ko and cdrom.ko is compiled and available at https://synocommunity.com/ https://synocommunity.com/package/synokernel-cdrom eject now works!!!

sebnapower commented 1 month ago

Hey fellow Synology users :)

I am trying to get it working and I am running into issues. I managed to get it to work on DSM 7.0 (and then scrapped it) but having problems with getting it to work from scratch on 7.2.1-69057 Update 5.

I am using following yml compose file:

version: '3'
services:
  makemkv:
    image: jlesage/makemkv
    container_name: makemkv
    restart: unless-stopped
    ports:
      - "5800:5800"
    environment:
      MAKEMKV_KEY: ****
      USER_ID: 1026
      GROUP_ID: 101
      AUTO_DISC_RIPPER: 0
      APP_NICENESS: 0
    #  WEB_LISTENING_PORT: 5802
      MAKEMKV_GUI: 1    
    volumes:
      - "/volume1/docker/MakeMKV_Test1/AppData:/config:rw"
      - "/volume1/Test-10gbit/TestAutoMKVStorage:/storage:ro"
      - "/volume1/Test-10gbit/TestAutoMKVOutput:/output:rw"
    devices:
      #- "/dev/sr0:/dev/sr0"
      #- "/dev/sg1:/dev/sg1"
      #- "/dev/sg2:/dev/sg2"
      #- "/dev/sg3:/dev/sg3"
      #- "/dev/sg4:/dev/sg4"
      #- "/dev/sg5:/dev/sg5"
      #- "/dev/sg6:/dev/sg6"
      #- "/dev/sg7:/dev/sg7"
      #- "/dev/sg8:/dev/sg8"
      - "/dev/sg9:/dev/sg9"
#- "/dev/sg10:/dev/sg10"

And I am getting the following in the logs of the container image

And no drive defected in the app itself.

While when I change in yml file following values:

USER_ID: 0
GROUP_ID: 0

MakeMKV reports the same warning in logs of the container but it sees the drive in the application.

Running command dmesg via SSH (and extracting from it relevant info gives the following two BD drives - I use two drives to rip). Here as you can see they are type 5? While MakeMKV logs report them as group 0? Is it the same thing, should the numbers match?

Line 1199: [   25.558557] scsi 11:0:0:0: CD-ROM            HL-DT-ST BD-RE  WH16NS60          1.02 PQ: 0 ANSI: 0
Line 1203: [   25.591509] scsi 11:0:0:0: Attached scsi generic sg9 type 5
Line 1206: [   25.636994] scsi 12:0:0:0: CD-ROM            HL-DT-ST BD-RE BU40N              1.03 PQ: 0 ANSI: 0
Line 1207: [   25.648673] scsi 12:0:0:0: Attached scsi generic sg10 type 5

Running sudo docker exec makemkv lsscsi -g -k gives the following (I unplugged one of the drives so that is why only one shows in this output).

[0:0:0:0]    disk    TOSHIBA  HDWE150                  FP1R  /dev/sda   /dev/sg0
[1:0:0:0]    disk    TOSHIBA  HDWE150                  FP1R  /dev/sdb   /dev/sg1
[3:0:0:0]    disk    WDC      WD101EFAX-68LDBN0        0A81  /dev/sde   /dev/sg2
[4:0:0:0]    disk    TOSHIBA  HDWE150                  FP1R  /dev/sdd   /dev/sg3
[5:0:0:0]    disk    TOSHIBA  HDWE150                  FP1R  /dev/sdc   /dev/sg4
[7:0:0:0]    disk    WDC      WD101EFAX-68LDBN0        0A81  /dev/sdh   /dev/sg5
[8:0:0:0]    disk    WDC      WD101EFAX-68LDBN0        0A81  /dev/sdg   /dev/sg6
[9:0:0:0]    disk    WDC      WD101EFAX-68LDBN0        0A81  /dev/sdf   /dev/sg7
[10:0:0:0]   disk    Synology DiskStation              DL17  /dev/synoboot  /dev/sg8
[11:0:0:0]   cd/dvd  HL-DT-ST BD-RE  WH16NS60          1.02  -          `/dev/sg9

Any ideas why it works when I change it to 0 and 0 (from reading this thread looks like it makes it run with root privileges) and what to do to be able to go back to 1026 and 101?

USER_ID: 0 GROUP_ID: 0

I can follow instructions and have some very hazy understanding of what I am working with but I am novice linux user so please have patience. On the flip side. It will come handy to everyone that follows in my footsteps :)

BTW I have two Synology NASes, both running the same DSM software version (so current DSM that is pushed via update service - I know there is a newer version that can be downloaded manually) and both behave exactly the same way.

In version DSM 7.0 it was working with 1026 and 101...

EDIT: I also tried sudo chmod 660 /dev/sg9 but it seemed to make no difference. Am I right that all that I would need to do after running it is to stop and start again the container? When I tried it was running with 1026/101 user/group settings, but it made no difference.

I have also now tried it wtih 1026/100 (sudo chmod 660 /dev/sg9).

So it looks like udev rule would not change anything in my case as it just makes sudo chmod 660 /dev/sg9 a permanent arrangement if my understanding is correct?

So, so far only running container with root user ID seems to be working, which I am assuming is far from ideal and should not be done long term?

sebnapower commented 1 month ago

The permissions kept changing on reboot. I was able to solve that with a udev rule and creating a cdrom group and adding myself to it. SUBSYSTEMS=="usb", ATTRS{idVendor}=="", ATTRS{idProduct}=="", GROUP="cdrom", MODE="0660"

Could you explain how and where to use it in DSM? Thank you.

I assume that I am supposed to enter my VID and PID for my BD drives in between corresponding "" but this command would not work via SSH. Thanks

rome1983 commented 1 month ago

lsusb gives idvendor an idProduct

152d:0578:0415 00 3.00 5000MBit/s 8mA 1IF (JMicron USB to ATA/ATAPI Bridge 0123456789ABCDEF)

udev rule would like this

SUBSYSTEMS=="usb", ATTRS{idVendor}=="152d", ATTRS{idProduct}=="0578", GROUP="cdrom", MODE="0660"

use task-scheduler to copy udev rule on boot run as root

cp /path/to/edev/rule/51-dvd-rom.rules /usr/lib/udev/rules.d/ udevadm control --reload

I also created a cdrom group and added myself to it.

Hope this helps.

sebnapower commented 1 month ago

lsusb gives idvendor an idProduct

152d:0578:0415 00 3.00 5000MBit/s 8mA 1IF (JMicron USB to ATA/ATAPI Bridge 0123456789ABCDEF)

udev rule would like this

SUBSYSTEMS=="usb", ATTRS{idVendor}=="152d", ATTRS{idProduct}=="0578", GROUP="cdrom", MODE="0660"

use task-scheduler to copy udev rule on boot run as root

cp /path/to/edev/rule/51-dvd-rom.rules /usr/lib/udev/rules.d/ udevadm control --reload

I also created a cdrom group and added myself to it.

Hope this helps.

Hey,

Thanks for getting back to me. It does help a lot. I will try it later on today but I am assuming it will not make a difference and the reason is that I have already tried (sg9 is position of one of my BD drives).

sudo chmod 660 /dev/sg9

... and it made no difference and I assume that udev rule only makes it persistent over restarts? Would I be right?

In relation to your tips on how to get the udev rule going. Am I right that I have to create file named 51-dvd-rom.rules and type into it and save SUBSYSTEMS=="usb", ATTRS{idVendor}=="152d", ATTRS{idProduct}=="0578", GROUP="cdrom", MODE="0660" as a sole line in it (of course using my particular VID and PID) and then use the copy command in the boot-up script?

What would happen if would just put the file manually in it's destination? I am guessing that without --reload switch it would not be executed on DSM restart?

BTW - another way to get VID and PID in DSM is to go to system info in CP and hover your mouse over the device you want to get the details for and a pop-up will show with this info.

Thanks

rome1983 commented 1 month ago

The udev rule be deleted after every dsm update. I uesd task scheduler to automate the proess. I would also create the cdrom group as the udev rule is dependent on it. I have another script that changes ownership of cdrom drive

chown USER:cdrom /dev/sg9

sebnapower commented 1 month ago

The udev rule be deleted after every dsm update. I uesd task scheduler to automate the proess. I would also create the cdrom group as the udev rule is dependent on it. I have another script that changes ownership of cdrom drive

chown USER:cdrom /dev/sg9

Thank you again. I will be trying all that we have discussed in next few hours and report back afterwards.

sebnapower commented 1 month ago

The udev rule be deleted after every dsm update. I uesd task scheduler to automate the proess. I would also create the cdrom group as the udev rule is dependent on it. I have another script that changes ownership of cdrom drive

chown USER:cdrom /dev/sg9

chown USER:cdrom /dev/sg9

This command fails due to syntax but even if I go for simple

chown user /dev/sg9

I am getting

chown: changing ownership of '/dev/sg9': Operation not permitted

lsusb gives idvendor an idProduct

152d:0578:0415 00 3.00 5000MBit/s 8mA 1IF (JMicron USB to ATA/ATAPI Bridge 0123456789ABCDEF)

udev rule would like this

SUBSYSTEMS=="usb", ATTRS{idVendor}=="152d", ATTRS{idProduct}=="0578", GROUP="cdrom", MODE="0660"

use task-scheduler to copy udev rule on boot run as root

cp /path/to/edev/rule/51-dvd-rom.rules /usr/lib/udev/rules.d/ udevadm control --reload

I also created a cdrom group and added myself to it.

Hope this helps.

Unfortunately as suspected running that script makes no difference either. The script works correctly to copy the file into the right location and the other command refreshes udav rules but it makes no difference to the container. Any other ideas? What version of DSM are you running? Am I right that it is not the newest one?

image

image

image

sebnapower commented 1 month ago

How unwise / dangerous it is to leave the container running with root privileges?

rome1983 commented 1 month ago

Replace USER with your username and judging by your udev rule it would be

sudo chown sebnapower:BDRippers /dev/sg9

after that run

ls -al /dev/sg9 edit: you van also add owner to udev rule. SUBSYSTEMS=="usb", ATTRS{idVendor}=="152d", ATTRS{idProduct}=="0578", OWNER="USERID", GROUP="cdrom", MODE="0660"

rome1983 commented 1 month ago

I refined my udev rule to where I only need one. This works if you have the sr_mod.ko and cdrom.ko kernel modules loaded. The ENV{PHYSDEVDRIVER}=="sr" is nedded to only apply permissions to devices using that driver.

SUBSYSTEMS=="scsi", KERNEL=="s[rg]*", ENV{PHYSDEVDRIVER}=="sr", ATTRS{type}=="5", OWNER="USERID", GROUP="cdrom"