Playing a Bluray disc on linux
It's late 2019 and the convenience of streaming is supreme. Netflix is great, but they occasionally remove shows, so I have blu-ray copies of some things. Because of streaming, I actually don't have a blu-ray player attached to my tv anymore, so it would be great to be able to play them on my computer instead.
It turns out this is a hard problem, and from what I can tell it's actually a bit easier on linux than on windows.
TLDR, it's possible to get things working but it's not going to work for everything and it's going to involve some trade-offs.
The goal
High level, I want to be able to watch blu-ray discs in VLC in ubuntu linux.
I am doing this entirely for my own personal access to things I 100% already own.
Hardware
First things first, I got an external blu-ray drive, connected it with USB3. Device detected, ubuntu mounts it as an external drive without problems, So we made it past the first hurdle!
Install some tools and libraries
In windows, you would be dowloading and installing some DLLs from random forums (side rant: I hate having to do things from random php forums - they're messy, outdated, and full of conflicting information from angry unhelpful people).
This is one step that's definitely easier in linux. Just install some bluray tools, most importantly the libaacs
library.
AACS is the copy-protection stuff on blu-ray discs, and it differs a bit depending on how new your discs are. Libaacs is for interacting with AACS.
sudo apt install libbluray2 libbluray-bdj libbluray-bin libaacs0
Download KEYDB.cfg
I mentioned AACS. Long-story short, there's just a bunch of identifying and encyption keys that the tools need to have before you'll be able to do anything.
Without the key for your specific release of the specific movie, the disc is useless.
From reading the doom9 forums (again, ugh), it seems that there's a database of key IDs, which is updated by volunteers. So, let's obtain the key list.
Use one of the download links from:
Save it as ~/.config/aacs/KEYDB.cfg
so libaacs can find it.
Caution: there are a few different sources for KEYDB.cfg, and some are more complete than others. Generally go with one that has more entries in it.
Capitalization of the filename matters. Make sure the file doesn't have a BOM (byte order mark) - see below.
I found it useful to refer to the spec for that file format, since I ran into some errors. Specification of the KEYDB.cfg file format
VLC Errors and Logs
VLC is an incredibly good video player, and it can play blu-rays when things are set up right. But it's error messages aren't great.
By default it write the useful error messages to /var/log/syslog
. If you set it up to log to a more convenient file, it actually still puts some error messages in syslog.
Remove the BOM
When trying to watch the movie with VLC, I was getting errors like:
syntax error: line 1 bad entry at or around line 1
Turns out the file had a BOM - byte order mark, which is messing with VLC and libaac.
The KEYDB.cfg specification obliquely states that's a bad thing. So, remove the BOM with sed:
sed -i '1 s/^\xef\xbb\xbf//' KEYDB.cfg
Check the disc
You can use the bd_info command to output details of the current disc. This is useful for quickly checking if there's a disc ID available or not.
bd_info /dev/sr1
That outputs some useful information:
AACS detected : yes libaacs detected : yes Disc ID : FD2E5296EC3DA6A2925689150EF4BCA083C811A3 AACS MKB version : 62 AACS handled : no (no matching processing key)
If that disc ID is present in your KEYDB, then good odds you'll be able to play it.
WTF is Bus Encryption?
The first disc I was trying to watch was Deadpool, and at this point it still wasn't working.
Here's the errors, about bus encryption:
vlc.desktop[6540]: aacs.c:1202: Unable to initialize bus encryption required by drive and disc vlc.desktop[6540]: aacs.c:121: No usable AACS libraries found
DVDFab has a useful blurb:
AACS Bus Encryption is a new copy protection that applied in some Blu-ray discs. It mainly adds the PC player encryptions to prevent the decryption of the content even if the AACS keys are known. Therefore, AACS Bus Encryption will prevent you from playing some blu-ray discs with PC based player software such as Power DVD, ARC soft 5, Total Media Theater, Cineplayer BD with 3D, WinDVD Pro. It also added second layer of encryption between the player software host and PC drive. Moreover, AACS Bus Encryption uses Dynamic keys. So that the disc content shall be much safer and the identification process shall be easier.
So, that's not particularly promising. And really just reinforces how consumer-unfriendly blu-ray is as a format.
Try a different disc
Deadpool doesn't want to play, but VLC is perfectly fine with Guardians of the Galaxy V1.
So, this is a qualified success! I'm able to play at least some of these blu-ray discs in linux.
Summary
Blu-rays in linux are still a PITA, but it's possible to get them working.
At the end of the day, most of my blu-rays came with a DVD disc in the same box, likely because even with official blu-ray players their incessant copy protection means not every device can play every movie.
I'm generally just going to watch the DVD version, and not have to deal with all of the BS.