Playing DVDs in Linux is generally a pretty painless process. The libdvdcss library does a sterling job of allowing us to watch our DVDs on legitimate hardware using the operating system of our choice, legal machinations notwithstanding. It also manages to circumvent the region encoding of the DVD (an abitrary and legally dubious restriction), allowing you to play DVDs from any region in your player without intervention. At least, most of the time it does; there are a few DVDs in the wild that libdvdcss can’t access unless the drive is set to the correct region.
I came across one example of this recently, when I bought People Like Us Season 2. It seems that this was only ever released in Australia, and as such is a region 4 disc. I’m in the UK, and so have (I assumed – more on this shortly) a region 2 DVD drive in my machine. Most of the time this isn’t a problem – I have DVDs from most regions in my collection, and so far they’ve all played just fine. This one, however, wouldn’t play ball. When I tried to play the DVD, mplayer took ten minutes to do anything, and then it couldn’t play all the tracks. A quick look at the libdvdread activity revealed the problem:
libdvdread: Using libdvdcss version 1.2.10 for DVD access There are 8 titles on this DVD. There are 1 angles in this DVD title. libdvdread: Attempting to retrieve all CSS keys libdvdread: This can take a _long_ time, please be patient libdvdread: Get key for /VIDEO_TS/VIDEO_TS.VOB at 0x00000152 libdvdread: Elapsed time 0 libdvdread: Get key for /VIDEO_TS/VTS_01_0.VOB at 0x000001c2 libdvdread: Elapsed time 0 libdvdread: Get key for /VIDEO_TS/VTS_01_1.VOB at 0x0000ac4a libdvdread: Elapsed time 1 libdvdread: Get key for /VIDEO_TS/VTS_02_0.VOB at 0x0000dd3b libdvdread: Elapsed time 0 libdvdread: Get key for /VIDEO_TS/VTS_02_1.VOB at 0x0000dd92 libdvdread: Elapsed time 0 libdvdread: Get key for /VIDEO_TS/VTS_03_0.VOB at 0x0000f04c libdvdread: Elapsed time 0 libdvdread: Get key for /VIDEO_TS/VTS_03_1.VOB at 0x0000f0a3 libdvdread: Elapsed time 46 libdvdread: Get key for /VIDEO_TS/VTS_04_0.VOB at 0x000a7da2 libdvdread: Elapsed time 1 libdvdread: Get key for /VIDEO_TS/VTS_04_1.VOB at 0x000a7df9 libdvdread: Error cracking CSS key for /VIDEO_TS/VTS_04_1.VOB (0x000a7df9)!! libdvdread: Elapsed time 303 libdvdread: Get key for /VIDEO_TS/VTS_05_0.VOB at 0x001416de libdvdread: Elapsed time 0 libdvdread: Get key for /VIDEO_TS/VTS_05_1.VOB at 0x00141735 libdvdread: Error cracking CSS key for /VIDEO_TS/VTS_05_1.VOB (0x00141735)!! libdvdread: Elapsed time 249 libdvdread: Get key for /VIDEO_TS/VTS_06_0.VOB at 0x001d8a51 libdvdread: Elapsed time 0 libdvdread: Get key for /VIDEO_TS/VTS_06_1.VOB at 0x001d8aa8 libdvdread: Error cracking CSS key for /VIDEO_TS/VTS_06_1.VOB (0x001d8aa8)!! libdvdread: Elapsed time 259 libdvdread: Get key for /VIDEO_TS/VTS_07_0.VOB at 0x002754ed libdvdread: Elapsed time 0 libdvdread: Get key for /VIDEO_TS/VTS_07_1.VOB at 0x00275544 libdvdread: Elapsed time 18 libdvdread: Get key for /VIDEO_TS/VTS_08_0.VOB at 0x0030a0a4 libdvdread: Elapsed time 0 libdvdread: Get key for /VIDEO_TS/VTS_08_1.VOB at 0x0030a0fb libdvdread: Elapsed time 1 libdvdread: Found 8 VTS's libdvdread: Elapsed time 878
The CSS tracks for three of the titles on the disc couldn’t be extracted, and those titles wouldn’t play. This left me with a problem – a DVD that I couldn’t watch. Since I knew that I could watch all my other DVDs, I set about finding out how to change my DVD drive to region 4; I could then play my new Australian DVD, and still be able to play my current collection. This is important – most drives will only allow you to change the region a set number of times (usually five), so I couldn’t afford to keep chopping and changing the region.
The Linux utility regionset (available in the Universe repository in Ubuntu) allows you to view and change the region code of your DVD drive. Having installed regionset, I ran to it change my region:
$ regionset regionset version 0.1 -- reads/sets region code on DVD drives Current Region Code settings: RPC Phase: II type: NONE vendor resets available: 4 user controlled changes resets available: 5 drive plays discs from region(s):, mask=0xFF Would you like to change the region setting of your drive? [y/n]:
This is an interesting result – it seems that my DVD drive had no region set at all. I would have thought a drive sold in the UK would be pre-set to region 2, but perhaps the region is left to be set the first time you play a DVD. Who knows? For our purposes, it doesn’t matter. I decided that I would like to change my DVD’s region:
Would you like to change the region setting of your drive? [y/n]:y Enter the new region number for your drive [1..8]:4
Once I’d entered that, my DVD region was changed:
$ regionset regionset version 0.1 -- reads/sets region code on DVD drives Current Region Code settings: RPC Phase: II type: SET vendor resets available: 4 user controlled changes resets available: 3 drive plays discs from region(s): 4, mask=0xF7
So I now have an Australian DVD drive, which can play my Australian DVD. (My reset count has dropped by two because of my inability to type the number 4 on the first attempt.) I tried a few of my DVDs from other regions, and they still played just fine, so all is well. Or is it? As well as my main desktop machine, I sometimes watch DVDs on my laptop, as well as my work laptop when I’m travelling. Do I have to go through all this to play People Like Us on those machines too?
From previous encounters with libdvdcss, I knew that it kept its decrypted DVD keys cached in my home directory, ~/.dvdcss. I wondered if I could simply copy the cached key for the People Like Us DVD onto my other machines. I had a look in the cache directory, and found the sub-directory for People Like Us. Luckily, most DVDs are easily identifiable:
... MY_NAME_IS_EARL_S1_DISC_4-2006090710551600-1bf2fbef18 MY_NAME_IS_EARL_SEASON2_DISC3 MY_NAME_IS_EARL_SEASON2_DISC4 PEOPLE_LIKE_US_SERIES2-2007081517503500-19deac38e6 PHOENIX_NIGHTS POLICE_SQUAD PORRIDGE ...
I copied the PEOPLE_LIKE_US directory to a thumb drive, and took it to my laptop. Having confirmed that this machine couldn’t play the DVD either, I installed the copied keys into the ~/.dvdcss directory and tried again. Voilà! Instant entertainment from Australia, and I still have all my region changes intact.
In summary, then: if you find a DVD that takes ages to start playing, and doesn’t fully work, the chances are that your DVD is set to the wrong (or no) region. Use the regionset tool to set your DVD drive’s region, or find someone who’s already watched the DVD, and ask them for a copy of the decryption keys.