Page 1 of 1

makemkv on OSMC (Raspberry Pi 4)

Posted: Sat Jul 02, 2022 11:32 am
by xoocoon
Hi there,

I would like to share my insights on how to make makemkvcon work on the Open Source Media Center (OSMC). This also enables Kodi to play back Blu-Rays with an external USB drive.

OSMC is a Debian-based Linux distribution with Kodi as its main application. I use it on a Raspberry Pi 4B, but it is also available on the Vero 4K (among others). Regarding OSMC, the challenge is that it uses a 64-bit kernel but userland including Kodi is 32-bit. Basically, both 32-bit armhf and 64-bit arm64 executables work on OSMC.

Prerequisites:
For basic instructions on how to compile and use makemkv on Linux, see viewtopic.php?t=224.
Generally speaking, makemkv binaries for various architectures are contained in the makemkv-bin packages. An armhf version available in the post viewtopic.php?f=3&t=28533

Initial situation:
When executing the armhf binary of makemkvcon out of the box, the following error message appears:

Code: Select all

osmc@osmc:~$ makemkvcon info disc:0
...
Bus access error
This obviously comes from the attempt to use the 64 bit kernel module sg from a 32 bit executable. sg stands for SCSI generic and is the SCSI kernel interface makemkv uses for accessing Blu-Ray / DVD devices in a low-level generic way.

Approach:
Step 1.: As a basic strategy, we need to make the arm64 binary of makemkvcon work so that it can make use of the 64-bit kernel module sg. It also requires the libraries libdriveio.so.0 and libmakemkv.so.1 in an arm64 version. Step 2.: In the next step, we need an 32-bit armhf version of libmmbd.so.0 so that Kodi can dynamically integrate it when playing Blu-Rays.

Step 1:
To be able to execute the arm64 binary of makemkvcon on OSMC we need to install some basic arm64 libraries which are not available in the standard image of OSMC.

Code: Select all

sudo apt install libc6:arm64 libstdc++6:arm64 libssl1.1:arm64 zlib1g:arm64 libexpat1:arm64 libavcodec58:arm64
After that, executing the arm64 binary of makemkvcon might yield something like:

Code: Select all

osmc@osmc:~$ makemkvcon info disc:0
...
makemkvcon: error while loading shared libraries: libmakemkv.so.1: wrong ELF class: ELFCLASS32
This is the case when you compiled makemkv-oss in an armhf version. So we need arm64 versions of the libraries libdriveio.so.0 and libmakemkv.so.1. While it is possible to cross-compile makemkv-oss for arm64, I did this on a separate installation of 64-bit Raspberry OS to not screw up my OSMC installation. Then you need to copy the compiled libdriveio.so.0 and libmakemkv.so.1 files to /usr/lib/aarch64-linux-gnu on OSMC. Then executing

Code: Select all

makemkvcon info disc:0
should work.

Troubleshooting:
You might encounter the following message.

Code: Select all

osmc@osmc:~$ makemkvcon info disc:0
...
makemkvcon: /lib/aarch64-linux-gnu/libm.so.6: version `GLIBC_2.29' not found (required by /lib/libmakemkv.so.1)
This error comes from different Debian versions: Debian bullseye uses glibc 2.29 whereas Debian buster uses glibc 2.28. So in the above case, you have two options: Either upgrade to the new (experimental) bullseye port of OSMC (see https://discourse.osmc.tv/t/testing-deb ... seye/93054). Or you need to compile libdriveio.so.0 and libmakemkv.so.1 on Debian buster, i.e. with glibc 2.28.

Step 2:
To enable Kodi to play back Blu-Rays, copy the 32-bit file libmmbd.so.0 to /usr/lib/arm-linux-gnueabihf on OSMC.
Then symlink this file to libaacs.so.0 and libbdplus.so.0:

Code: Select all

sudo ln -s /usr/lib/arm-linux-gnueabihf/libmmbd.so.0 /usr/lib/arm-linux-gnueabihf/libaacs.so.0
sudo ln -s /usr/lib/arm-linux-gnueabihf/libmmbd.so.0 /usr/lib/arm-linux-gnueabihf/libbdplus.so.0
I hope this helps others who try to make blu-ray playback work in OSMC.

Re: makemkv on OSMC (Raspberry Pi 4)

Posted: Sun Jul 03, 2022 1:28 pm
by dtech
It looks like a little chaos to me. Under LibreELEC, the 64-bit ARM kernel (aarch64) is accompanied by a 64-bit module (CHR_DEV_SG).

Other than that, everything else is 32-bit, including the libraries in use, which are:
  • libcrypto.so.1.1 (OpenSSL)
  • libdriveio.so.0
  • libmakemkv.so.1
  • libmmbd.so.0

Re: makemkv on OSMC (Raspberry Pi 4)

Posted: Sun Jul 03, 2022 2:29 pm
by xoocoon
Strange. OSMC refuses to read discs with the 32-bit version of makemkvcon. The OSMC kernel was compiled with CHR_DEV_SG=m which seems straightforward.
Have you managed to play Blu-Rays with LibreELEC's Kodi?

Re: makemkv on OSMC (Raspberry Pi 4)

Posted: Sun Jul 03, 2022 3:35 pm
by dtech
Unfortunately, I don't have a BluRay drive or disc. However, the user (Samui) who requested the package from me tested it, and disc playback works for him without any problems under Kodi 18 (Leia) on my LE build v9.2.8.4.

Re: makemkv on OSMC (Raspberry Pi 4)

Posted: Mon Jul 04, 2022 9:03 am
by xoocoon
I can confirm that playing the main movie of Blu-rays works in my setup of OSMC on a Raspberry Pi 4B. That is, the 32-bit libmmbd library dynamically linked by Kodi can successfully spin off a 64-bit instance of makemkvcon to play back a Blu-Ray in a drive attached via USB. Getting Blu-Ray menus to work seems to be more tricky.
Once I have the chance, I will add some more details to the initial post above.

Re: makemkv on OSMC (Raspberry Pi 4)

Posted: Thu Aug 04, 2022 1:59 pm
by henryjfry
Could you post the copies:

"arm64 versions of the libraries libdriveio.so.0 and libmakemkv.so.1"

And

"the 32-bit file libmmbd.so.0"

For osmc from your system?

I'd like to try this on osmc on Vero 4k but if I don't need to wipe and install multiple os'es on a spare pi4 to be able to compile the correct versions files that would be useful.
Unless cross-compiling for arm64 isn't to difficult and you could give some pointers?

Also would an osmc install of makemkv for playing Blu-ray's require ffmpeg compiled at the same time?
It looks more like it's required for audio encoding, except maybe for decoding dts-hd?
xoocoon wrote:
Sat Jul 02, 2022 11:32 am
Hi there,

I would like to share my insights on how to make makemkvcon work on the Open Source Media Center (OSMC). This also enables Kodi to play back Blu-Rays with an external USB drive.

OSMC is a Debian-based Linux distribution with Kodi as its main application. I use it on a Raspberry Pi 4B, but it is also available on the Vero 4K (among others). Regarding OSMC, the challenge is that it uses a 64-bit kernel but userland including Kodi is 32-bit. Basically, both 32-bit armhf and 64-bit arm64 executables work on OSMC.

Prerequisites:
For basic instructions on how to compile and use makemkv on Linux, see viewtopic.php?t=224.
Generally speaking, makemkv binaries for various architectures are contained in the makemkv-bin packages. An armhf version available in the post viewtopic.php?f=3&t=28533

Initial situation:
When executing the armhf binary of makemkvcon out of the box, the following error message appears:

Code: Select all

osmc@osmc:~$ makemkvcon info disc:0
...
Bus access error
This obviously comes from the attempt to use the 64 bit kernel module sg from a 32 bit executable. sg stands for SCSI generic and is the SCSI kernel interface makemkv uses for accessing Blu-Ray / DVD devices in a low-level generic way.

Approach:
Step 1.: As a basic strategy, we need to make the arm64 binary of makemkvcon work so that it can make use of the 64-bit kernel module sg. It also requires the libraries libdriveio.so.0 and libmakemkv.so.1 in an arm64 version. Step 2.: In the next step, we need an 32-bit armhf version of libmmbd.so.0 so that Kodi can dynamically integrate it when playing Blu-Rays.

Step 1:
To be able to execute the arm64 binary of makemkvcon on OSMC we need to install some basic arm64 libraries which are not available in the standard image of OSMC.

Code: Select all

sudo apt install libc6:arm64 libstdc++6:arm64 libssl1.1:arm64 zlib1g:arm64 libexpat1:arm64 libavcodec58:arm64
After that, executing the arm64 binary of makemkvcon might yield something like:

Code: Select all

osmc@osmc:~$ makemkvcon info disc:0
...
makemkvcon: error while loading shared libraries: libmakemkv.so.1: wrong ELF class: ELFCLASS32
This is the case when you compiled makemkv-oss in an armhf version. So we need arm64 versions of the libraries libdriveio.so.0 and libmakemkv.so.1. While it is possible to cross-compile makemkv-oss for arm64, I did this on a separate installation of 64-bit Raspberry OS to not screw up my OSMC installation. Then you need to copy the compiled libdriveio.so.0 and libmakemkv.so.1 files to /usr/lib/aarch64-linux-gnu on OSMC. Then executing

Code: Select all

makemkvcon info disc:0
should work.

Troubleshooting:
You might encounter the following message.

Code: Select all

osmc@osmc:~$ makemkvcon info disc:0
...
makemkvcon: /lib/aarch64-linux-gnu/libm.so.6: version `GLIBC_2.29' not found (required by /lib/libmakemkv.so.1)
This error comes from different Debian versions: Debian bullseye uses glibc 2.29 whereas Debian buster uses glibc 2.28. So in the above case, you have two options: Either upgrade to the new (experimental) bullseye port of OSMC (see https://discourse.osmc.tv/t/testing-deb ... seye/93054). Or you need to compile libdriveio.so.0 and libmakemkv.so.1 on Debian buster, i.e. with glibc 2.28.

Step 2:
To enable Kodi to play back Blu-Rays, copy the 32-bit file libmmbd.so.0 to /usr/lib/arm-linux-gnueabihf on OSMC.
Then symlink this file to libaacs.so.0 and libbdplus.so.0:

Code: Select all

sudo ln -s /usr/lib/arm-linux-gnueabihf/libmmbd.so.0 /usr/lib/arm-linux-gnueabihf/libaacs.so.0
sudo ln -s /usr/lib/arm-linux-gnueabihf/libmmbd.so.0 /usr/lib/arm-linux-gnueabihf/libbdplus.so.0
I hope this helps others who try to make blu-ray playback work in OSMC.