BluRay playback and ripping on Fedora (AACS, BD+, BD-J)

There are multiple ways that one can try to make BluRay decryption and playback in Linux. Of course, after some googling and fiddling around, you can see that is quite simple even if not the different instructions are quite confused as they span across multiple iterations of software development.

First of all a brief introduction. It is all explained here in great detail on the BluRay Wikipedia page, this is just an extract.

There are two different types of encryption:

  • AACS, performed using keys)
  • BD+, performed using a small embedded Java VM that executes programs and decrypts contents

And one type of “enhanced” java embedded menu (even small apps, like internet connected browsers, etc.) that can run on the BluRay player:

  • BD-J, using a GEM standard Java VM that includes also BDlive, for internet access

If any of these is implemented in a disk you own, the thing you need to do is simply insert a disk and run the bd_info command (from the libbluray-utils package) against your BD/DVD device.

Screenshot from 2015-08-27 10-59-57

This, of course, does work if you have the proper decryption keys or software installed on your system. That is, by default, nothing. 🙂

So, to enable decryption of the discs, you can proceed in two different ways, one using only open source software (not really, as you need anyway keys and a JVM dump of a BluRay Player) or going through commercial software (free at the moment while in beta).

Unfortunately none of my BluRays worked with open source tools on my system. I was not even able to get the required keys with the aacskeys program; so the proprietary software is my current choice.

Required repositories

In both cases, first of all enable the RPMFusion and the HandBrake/MakeMKV repository. Most of the keys required can be fetched from labDV, where you can also contribute back yours.

For the following examples I’m taking VideoLan as the main player, as it has good support (and a nice interface) to fiddle around with the various settings and is already available in RPMFusion.

Open Source AACS/BD+ decryption

First of all install libaacs and libbdplus from RPMFusion:

dnf install libaacs libbdplus

Then put the required AACS keys in a place, so that your AACS client can find them. For example:

mkdir -p ~/.config/aacs
wget -c http://www.labdv.com/aacs/KEYDB.cfg -O ~/.config/aacs/KEYDB.cfg

Now, VLC, using libbluray, should dynamically load the library if it finds it on the system and then decrypt the AACS protected content if the key for the specific disc is available.

Similar to AACS, put the required BD+ JVM dump in the appropriate folder, so that your BD+ client can find them. For example:

mkdir -p ~/.config/bdplus/
wget -c http://www.labdv.com/aacs/libbdplus/bdplus-vm0.bz2 -O ~/bdplus-vm0.bz2
tar -xvjf ~/bdplus-vm0.bz2 -C ~/.config/

Again, now libbluray should dynamically load the library if it finds it on the system and then decrypt the BD+ protected content using the VM dump in your personal folder.

Do not forget to update the AACS keys and the VM dump every once in a while!

Moving keys and dumps in a system wide location

This is required if you have multiple user for the system and you want to avoid each user into maintaining its own set of keys and dumps.
After installing everything in your personal folder, you will end up with a structure like the following:

$ find .config/bdplus .config/aacs | sort
.config/aacs
.config/aacs/KEYDB.cfg
.config/bdplus
.config/bdplus/vm0
.config/bdplus/vm0/aes_keys.bin
.config/bdplus/vm0/device_discovery_1.bin
.config/bdplus/vm0/device_discovery_2.bin
.config/bdplus/vm0/device_discovery_3.bin
.config/bdplus/vm0/device_discovery_4.bin
.config/bdplus/vm0/device_discovery_5.bin
.config/bdplus/vm0/ecdsa_keys.txt
.config/bdplus/vm0/mem_area_02.bin
.config/bdplus/vm0/mem_area_03.bin
.config/bdplus/vm0/mem_area_04.bin
.config/bdplus/vm0/mem_area_05.bin
.config/bdplus/vm0/mem_area_06.bin
.config/bdplus/vm0/mem_area_07.bin
.config/bdplus/vm0/mem_free.bin
.config/bdplus/vm0/memory.map
.config/bdplus/vm0/mem_player_executable.bin
.config/bdplus/vm0/mem_player_name.bin
.config/bdplus/vm0/mem_player_version.bin

To move up everything to a common location, just performs the following commands:

sudo mv ~/.config/{aacs,bdplus} /etc/xdg
sudo chown -R root:root /etc/xdg/{aacs,bdplus}

That’s it!

Proprietary AACS/BD+ decryption

This is done through MakeMKV, available from the HandBrake/MakeMKV repository, with the registration key available publicly from their forum. The software is fast, works really well, and although not open source is the only way to properly get access to your disks.

Support for external decoders has been added in libbluray some time ago, and allows you to specify different libraries than libaacs/libbdplus for decrypting content.

To proceed, remove the libaacs/libbdplus libraries if you have them installed, and install MakeMKV:

dnf remove libaacs libbdplus
dnf install libbdplus

As explained in the repository page, the MakeMKV package sets up environment variables that override the default libraries using for decryption and just uses MakeMKV’s libmmbd to launch a hidden MakeMKV instance for decryption in the background. To load the environment, logoff and login again, so it is picked up by any program starting.

After logging in, check that the environment is loaded with the following command:

$ env | egrep "LIBAACS_PATH|LIBBDPLUS_PATH"
LIBBDPLUS_PATH=/usr/lib64/libmmbd.so.0
LIBAACS_PATH=/usr/lib64/libmmbd.so.0

Then start VLC, select to open a BluRay disc, with or without the menus. Both will smoothly work as long as it is not a BD-J, as you can see in the pictures below. Menu is navigable, reactive to selections and clickable.

menus

Now also the command bd_info works fine, using the same mechanism.

BD-J Java menus

BD-J support is still in its infancy, at the moment of writing, with the latest libbluray 0.8.1 I am able to get part of the menus working. Most of the time I just got a video loop where the menu should be but not the actual menu. This is much better than having just VideoLan crashing, though. 🙂

Support for this is enabled by installing the libbluray-bdj package. The package puts an OpenJDK compiled Java Archive inside the classpath of the Java VM, so no further configuration is required. To install the package, just do:

dnf install libbluray-bdj

After this, in VideoLan you can just select “Open Disc”, “Blu-Ray” as the source and deselect “No disc menus”. As I said, support is not perfect, in the screnshot below I was able to see the menus but not click on them and in the background I was having a lot of errors.

bdj

I’m tracking the upstream project, so if the library can be rebuilt without breaking compatibility with the additional Fedora packages, I will add it to the repository along with MakeMKV. Before version 0.8.1 I was not even able to open a BD-J enabled BluRay disc with VideoLan.

One final curiosity

All my BD-J enabled discs have a Playstation 3 firmware update on the disc. Don’t know why, but probably because Sony owns the BluRay format so they can do as they please. Meh!

As always, feedback is welcome.

NVIDIA repository improvements

I’ve just pushed a big update to the Nvidia repository. The list of changes is quite big, so if you are a user of the repository please take your time to read through it.

CUDA

CUDA has been replaced with version 7 for all supported RHEL/CentOS/Fedora releases, with the main difference being no more support for 32 bit systems. From now on, there will be no compatibility packages for the i686 architecture. So, after upgrading, make sure to remove all the i686 pacakges (that is, yum/dnf remove cuda\*.i686).

Apart from this, CUDA 7 packages introduce new stuff, improves on the packaging and can now run correctly on all Fedora systems, including Fedora 22, which was not supported by CUDA 6.5. As announced previously, the only “regression” is when enabling C+11 on GCC 5.1 (i.e. Fedora 22).

The new packages take into consideration the Nvidia provided ones, and replace them accordingly; so if you have their packages installed it should upgrade them where appropriate leaving no traces of the former. Local changes include the pkg-config files for development packages (not included in their self installer and in my 6.5 packages) and the segregation of static libraries in their own subpackage, thus reducing installed size greatly. The next step is to proceed like for the open components of the Nvidia driver: replacing all the pre-built binaries with source compiled stuff. At the moment, this includes cuda-gdb, for which sources do exist.

NVIDIA driver

The Nvidia driver has seen a repackaging of the main components, where the biggest change is the library layout.

All the unique libraries are now in standard locations, leaving only the duplicate ones under /usr/lib{,64}/nvidia. Also, X configuration files that the user should avoid touching, have been moved under /usr/share/X11/xorg.conf.d. Library dependencies have been reduced, so you can now compile a program against the NVML library (libnvidia-ml.so.1) or CUDA without needing to install the full driver or using the Nvidia provided stubs.

This makes for a simpler package with a simpler filter for conflicting libraries and is also propedeutic work to enable hardware accelerated encoding with Steam In-Home streaming and Nvidia drivers. Hardware decoding in Steam has been put in place, so now it’s time for the (only) supported hardware encoding.

NVIDIA beta driver (355.xx)

The biggest change comes with the 355.06 driver in Fedora 23, which introduces partial support for the GL Vendor-Neutral Dispatch library (libglvnd), a new kernel module building system (in preparation for their modeset driver after the 355.x series) and dropped support for Nvidia instanciated modules.

The new beta driver requires the GL Vendor Neutral Dispatch library in place for proper operation, and being this a separate open source project (only a prototype in Mesa, at the moment) it has been built from source. So there is now a required libglvnd package that only contains the libraries required by the driver for running. The more they are integrated with the driver, the more I will enable in the package. This is a transitional package only, as sooner or later Mesa and the X server will introduce the same mechanism, making the transitional package obsolete and just using distribution provided packages.

This with could eventually lead to system running different OpenGL implementations at the same time, solving the Optimus and multiple cards from multiple vendors combination issues.

The Nvidia control panel can be optionally linked to NVML, so I’ve tried to enable it in the beta drivers. I don’t see any changes so far, but probably this is due to the fact that I don’t have new enough cards to be compatible with NVML.

The beta driver has been pushed to the Fedora 23 branch only, as explained in the Nvidia repository page.

As always, feedback is welcome.

CUDA 7.0 enabled programs for Fedora 22

nv-cuda-2014header-updatedI’ve udpated the CUDA version in the Fedora 22 Nvidia repository, it now contains CUDA 7.0.28 along with the cuFFT 7.0.35 patch. Note that from this version, CUDA is x86_64 bit compatible only, so there are no more i386 packages. There is still the cudart library available for 32 bit, but I don’t think it’s worth packaging.

The packages hosted here should correctly upgrade and obsolete the ones in Nvidia’s own repository, so it should be possible to go straight from one version to the other, if you need.

The static libraries (according to packaging guidelines) have been placed in a cuda-static package, thus reducing by an order of magnitude the size of the packages containing libraries. The toolkit can of course be installed and used to create CUDA binaries on systems where there is no Nvidia adapter installed.

The Nvidia compiler (nvcc) throws an error if the GCC version detected is higher than 4.9 (Fedora 22 default is 5.1.1), but the removing the check makes the compiler run fine until you enable C++11 support. If you need to enable C++11 support you need to use a separate GCC, older than 5.x, for compilation. See this comment here for details.

As part of the update, the repository that contains CUDA enabled programs (Blender, CCMiner and NVENC enabled FFMpeg) has been updated for Fedora 22. This is completely optional, so you can have Nvidia packages on your system and still use RPMFusion’s FFMpeg and Fedora’s Blender. I’ve tried to submit Blender updates to the appropriate package maintainer but did not receive any answer.

I will rebase all distributions to CUDA 7.0 as soon as the next long lived driver release will be branched by Nvidia.

As always, feedback is welcome. If you have any issue or would request an enabled CUDA package to add to the repository, just write in the comments or write me an email.

Steam made easy

The Steam repository has received some love; changes to the Steam package will also be pushed in RPMFusion after a bit of feedback.

Updated X-Box gamepad driver

The SteamOS X-Box Gamepad driver has been updated with the new Valve rebase on the 3.18 kernel, with new hardware support and bugfixes. Remember to disable Secure Boot if you plan to use it on an UEFI system.

In-Home Streaming

There are now instructions for setting up In-Home streaming, including the firewall rules required for enabling your desktop to accept connections from other Steam clients that are available on your network.

Also, hardware decoding is available if you are streaming from another Steam client and you are not running the Ubuntu Runtime.

Disabling Ubuntu Runtime

It is now possible again to have the steam-noruntime package that pulls in all (known) 32 bit dependencies and allows you to run Steam without the Ubuntu Runtime. Remember this is not supported, so while getting the benefits of it, you might as well encounter additional problems.

Also, some games pull in additional dependencies (the Witcher 2 or Anodyne, for example), so without the Runtime you are on your own to figure out what is missing.

But running Steam without the Ubuntu Runtime has also its benefits, for example you use DTS 7.1 sound through PulseAudio.

The steam-noruntime package also pulls in as the dependencies the required libraries for the hardware accelerated decoding with In-Home Streaming. This makes streaming much less flickery client side.

Those features normally work only with the Ubuntu/Debian libraries on the system, so avoiding the runtime is the only choice.

170 games and counting!

Nvidia driver modeset kernel module

As part of the latest Nvidia driver update at version 352.09, there is now code supporting a new nvidia-modeset kernel module that should be running on a system and that interfaces with the usual nvidia kernel module.

Evidence of this is in the kernel module sources and in the nvidia-modprobe command code that is hosted in Github.

From the nv-modeset-interface.h header in the kernel module “sources”:

/*
 * This file defines the interface between the nvidia.ko and
 * nvidia-modeset.ko Linux kernel modules.
 *
 * A minor device file from nvidia.ko's pool is dedicated to
 * nvidia-modeset.ko.  nvidia-modeset.ko registers with nvidia.ko by
 * calling nvidia_register_module() and providing its file operation
 * callback functions.
 *
 * Later, nvidia-modeset.ko calls nvidia.ko's nvidia_get_rm_ops()
 * function to get the RMAPI function pointers which it will need.
 */

Let’s hope that modesetting support in the driver is near and we will not have to wait additional years for it. Also, let’s hope that the firmware images required for the latest hardware on Nouveau will be released soon, without further delays.

As soon as it will be delivered, I will implement it in the packages according to the driver table in the repository page.

Steam for CentOS / RHEL 7

The Steam repository now contains the Steam client package plus the S3 texture compression library for Open Source drivers for CentOS and Red Hat Enterprise Linux 7.

The CentOS/RHEL repository contains also all the SteamOS session files and binaries for running a Steam-only system, like the Fedora ones. As the Fedora packages, the main client is 32 bit only, so when running on 64 bit systems, make sure to load also your 32 bit libraries if you are running on proprietary drivers or the S3 texture compression library if you are running on a 64 bit system. Work on Valve’s X-Box kernel module for CentOS/RHEL is ongoing; as in its current form there are unresolved symbols.

As part of the update, also the Fedora X-Box kernel module has additional fixes on top of Valve’s code.

I will also add the packages to RPMFusion when a CentOS/RHEL 7 branch will eventually be available.

For full details see the repository page.

centos-steam2

centos-steam3

Updated Skype Pidgin plugin

The Skype Pidgin plugin has been updated, it now provides a working copy of the skypeweb plugin. This means you can have your Skype account in Pidgin without having the full Skype client running on your system.

Just disable the D-Bus plugin and enable the HTTP client, providing your Skype credentials.

Screenshot from 2015-05-05 18:09:51

Full details in the Skype and Skype Pidgin plugin page.

CUDA enabled programs

There is a new repository available with CUDA enabled programs in package format. This contains programs that have been linked to CUDA libraries or have CUDA support enabled. At the moment this is available only on Fedora 21, if there is sufficient feedback I will enable it also for other distributions.

The repository is available here.

At the moment of writing, the repository contains the following:

  • Nvidia Encoder (NVENC) enabled FFMpeg
  • CUDA and FFMpeg enabled Blender
  • ccminer (multi cryptocoin miner)

Please keep in mind that these packages update already available packages that are in Fedora and RPMFusion, so you might step into other dependency issues if you have tons of other programs using these libraries on your system.

Also, CUDA 6.5 works only on fairly recent GPUs, so your old models might not be compatible. Follow this Nvidia link to check if your GPU is CUDA capable. Basically, anything with Compute Capability >= 2.0 is ok. Also the Wikipedia article on CUDA has all the Compute Capability information available.

The Blender build looks for libcuda and the Nvidia Unified Video Memory module on the system to enable CUDA support. By installing the Nvidia driver from my repository with CUDA support, you should have a working Blender installation that is able to use your GPU for rendering.

Screenshot from 2015-04-27 20:03:57

As you can see from the picture, I only have the basic Nvidia driver plus CUDA support installed, there is no need to install the full CUDA stack. The runtime is required only for additional specific libraries (like ccminer that uses some specific CUDA math libraries).

This build of Blender looks for libcuda.so.1; so if you are using the official Blender build from blender.org, you also need to have the full nvidia-driver-devel package installed as it contains also the libcuda.so symlink.

To recap, this is what is required to have a fully working Blender with CUDA and FFMpeg support enabled on Fedora 21:

# yum-config-manager --add-repo=https://negativo17.org/repos/fedora-cuda-programs.repo
# yum-config-manager --add-repo=https://negativo17.org/repos/fedora-nvidia.repo
# yum install kernel-devel akmod-nvidia nvidia-driver nvidia-driver-cuda blender

Then reboot, and make sure the nvidia-uvm.ko module is loaded.

Repositories update

Another batch of changes has reached the repositories in the last weeks. The updates have touched everything:

  • MakeMKV has been updated to version 1.9.2.
  • HandBrake has been updated to the current 0.10.1 for Fedora 20, 21 and 22.
  • libdvdnav and libdvdread are based on 5.0.x releases. Also, all required libraries for MakeMKV and HandBrake have been rebuilt for Fedora 22 until RPMFusion catches up, at which point I will remove them from the repository.
  • The Nvidia driver is now at version 346.59 for all CentOS/RHEL and Fedora variants and at 349.12 (beta) for Fedora 22. According to the release notes, the 319.42 drivers will try to copy the framebuffer console’s contents out of /dev/fb0 making the Plymouth transition even better on UEFI systems.
  • The Nvidia driver is now using libvdpau 1.1 which contains support for decoding H.265/HEVC video streams (VDPAU Feature Set F) on supported GPUs.
  • The GPU Deployment kit (NVML headers and docs) is now at version 346.46. Also, nvidia-healthmon is now 64 bit only.
  • The CDRtools suite has been updated to version 3.01a28.
  • The Flash plugin package has been updated to version 11.2.202.451 and it has also been pushed to RPMFusion in the form of lpf package.
  • Spotify it’s at version 0.9.17.1 for CentOS/RHEL 7 and Fedora 20, 21 and 22. Instead of bundling Ubuntu’s libgcrypt library; now it uses the compat-libgcrypt package from ssaavedra/compat-libcrypt COPR repository. The package is already included where appropriate.
  • Wimms’ ISO tools have been updated to 2.30a.
  • RAR has been updated to version 5.2.1.

As always, any issue just let me know. I’m in the process of moving and starting a new job; so please bear some patience if I don’t reply to you immediately.