Cocktails and Traffic Cones – party time with DVDs and Blu-Rays in Ubuntu

This title may evoke images of a rumbustious night out filled with exotic drinks and highjinks followed by a morning waking up in possession of a traffic cone, the acquisition of which has somehow escaped the wreckage of your short-term memory.
If this is the case, you may be a tiny bit disappointed. This is all about how to play and rip DVDs and Blu-rays on Ubuntu.
Whilst that may not sound like quite as much fun, it’s less to leave you with a raging hangover. It should however, enable you to enjoy your video on your OS of choice.
What cocktails and traffic cones have to do with all of this will become apparent shortly.

What I’m going to cover here is :

  • How to Decode and Play DVDs using VLC
  • How to Convert DVD and Blu-ray files to mp4 video using Handbrake
  • How to Transcode DVD and Blu-ray discs to Matroska (mkv) format using MakeMKV

This should give you all of the steps required to watch and – if required – copy movies, tv shows etc from an optical disc.

First of all though…

The Legal Disclaimer
The legality of ripping copyrighted material differs across jurisdictions. You may want to check the situation where you are before you follow any of the steps detailed in this article.

Whilst we’re on the subject of disclaimers…

The Taste Disclaimer
The subject matter at hand means that there is a strong temptation to include quotes and (possibly) oblique references to movies here and there. Of course I wouldn’t dream of stooping so low just to get cheap laughs…much.

Oh, one more thing…

Efficacy disclaimer – The steps described here will work most discs. In the rare instances where this is not the case do not seem to follow and discernible pattern.
For example, the same steps to persuade a dark comedy to present you with a Marmalade Sandwich (in mp4 format), may cause a loveable cartoon bear to fix you with a stare that’s harder than a coffin nail.

Moving swiftly on…

Required Libraries

In order to read DVDs and Blu-rays there are a number of packages that you’ll need. As I don’t know which desktop you’re running (I’m currently on Unity on Ubuntu 16.04 LTS), I’ll do this bit in the Terminal (the CLI, not the Tom Hanks film)…

To start with, you should find that most of the packages we need are there already…

apt list libdvd* libaacs* libbluray* --installed

…should confirm that the following packages are installed :

There are a few more packages required which we can acquire in two stages. First of all…

sudo apt-get install libdvd-pkg

…which produces the following output


[sudo] password for mike: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  autoconf automake autopoint autotools-dev debhelper dh-autoreconf dh-strip-nondeterminism libfile-stripnondeterminism-perl libltdl-dev libmail-sendmail-perl libsigsegv2
  libsys-hostname-long-perl libtool m4 po-debconf
Suggested packages:
  autoconf-archive gnu-standards autoconf-doc dh-make libtool-doc gfortran | fortran95-compiler gcj-jdk libmail-box-perl
The following NEW packages will be installed
  autoconf automake autopoint autotools-dev debhelper dh-autoreconf dh-strip-nondeterminism libdvd-pkg libfile-stripnondeterminism-perl libltdl-dev libmail-sendmail-perl libsigsegv2
  libsys-hostname-long-perl libtool m4 po-debconf
0 to upgrade, 16 to newly install, 0 to remove and 496 not to upgrade.
Need to get 2,897 kB of archives.
After this operation, 8,428 kB of additional disk space will be used.
Do you want to continue? [Y/n] Y

Enter Y to continue.

Next up :

sudo apt-get install libbluray-bdj

…initially the output will be something like :

The following additional packages will be installed:
  ca-certificates-java default-jre-headless java-common libasm4-java openjdk-8-jre-headless
Suggested packages:
  default-jre fonts-dejavu-extra fonts-ipafont-gothic fonts-ipafont-mincho fonts-wqy-microhei fonts-wqy-zenhei fonts-indic
The following NEW packages will be installed
  ca-certificates-java default-jre-headless java-common libasm4-java libbluray-bdj openjdk-8-jre-headless
0 to upgrade, 6 to newly install, 0 to remove and 496 not to upgrade.
Need to get 27.8 MB of archives.
After this operation, 101 MB of additional disk space will be used.
Do you want to continue? [Y/n] 

This time, hitting Y will cause a number of things to happen. Apart from a Java Runtime being installed ( if one is not already present on the system), you are likely to find yourself presented with this screen :

Say Yes ( hit Enter) and you’ll then get :

Once again, say Yes (hit Enter).

Now that’s all done, if we re-run our initial check…

apt list libdvd* libaacs* libbluray* --installed

we should now get :

Before we leave the Command Line (for now, at least) there’s one more step requried to facilitate reading blu-rays…

mkdir -p ~/.config/aacs/
cd ~/.config/aacs/ && wget http://vlc-bluray.whoknowsmy.name/files/KEYDB.cfg

After all that, it’s probably a good idea to check that you can now play any discs that you’re planning to rip.
Whilst Totem is default tool for this on my desktop, in the wider Linux world – and pretty much everywhere else for that matter – the best app for playing video is undoubtedly…

VLC

The Video Lan Media Player (VLC) is available across multiple platforms and will pretty much play anything. As a clincher, it’s versions are named after Discworld characters. I’ve used Wetherwax (2.2.2) here.
Oh, and it’s icon is a traffic cone, which goes some way to explaining the title of this article.

To see if you already have VLC installed, you can run :

which vlc

If this returns something like…

/usr/bin/vlc

…then you’re good to go. Otherwise, you can either install from the Terminal…

sudo apt-get install vlc

…or via the Software centre

Either way, you can now use VLC to play your DVDs.

With a DVD disc in the drive, start VLC and go to the Media menu and select Open disc…

Playing a Blu-Ray requires some slightly different settings when opening the disc in VLC :

When playing blu-rays with VLC there are a couple of points to note –

  1. don’t try to open the disc with VLC because VLC will assume it’s a DVD. Instead, open VLC then open the disc from the VLC menu
  2. make sure that “No disc menus” is checked when you open the disc in VLC

If all you need is a means of playing discs on your Ubuntu machine, then VLC and the aforementioned packages do the job.
If however, you’ve ever opened a DVD case in anticipation of an hour-and-a-half of explosions and mayhem, only to find a Disney Musical, and reflected that high spirits are just no substitute for 800 rounds-a-minute, you’ll be interested in finding a way to store all your movies in one place on file.

Fortunately, as well as playing video from disc, VLC allows you to see which Title holds the movie (on DVDs at least) :


Whilst this is usually fairly obvious, there are discs that contain several titles of the same or similar length.

Using VLC enables you to determine which track you need to rip.

All we need now is a cocktail tool to do the ripping …

Handbrake

Of all the ripping tools available in Linux, Handbrake appears to be the most well-supported and long-lived.
Whilst it is included in the Ubuntu repositories, the documentation on the Handbrake Website suggests that sourcing the package from there may not be the best approach.
If you want to follow this advice, but persist with the package route, you can add the Ubuntu handbrake repository to your system…

 
sudo add-apt-repository ppa:stebbins/handbrake-releases 
sudo apt-get update

The screenshots here are taken from version 1.1.0 (64-bit version) :

Hanbrake is a converter – it will take your source video and convert it to another format. In this case, we’re going to convert to MP4.
The MP4 file you end up with is likely to be a fraction of the size of the source video file(s) you start with.
The act of conversion is rather CPU-intensive. As a result, you will find that the time taken to rip a movie will be as dependent on the speed of the available hardware as it is on the settings you choose.

The other point to note is that prolonged high CPU activity can cause your machine to run quite hot. Therefore, I’ve found that it’s a good idea to :

  • Ensure that your machine is sitting somewhere that is well-ventilated
  • Allow the machine to cool down between prolonged bouts of ripping

If you want to get an idea of the internal temperature of your machine, you could use the sensors command :

By now, you’ll probably have noticed Handbrake’s distinctive icon. This should give you a hint that, even with an extremely fast processor, transcoding is an activity that you can kick off and leave to run for a while.

When you start Handbrake, the first decision you are presented with is which preset to use.
These presets provide default settings for how you want to rip your movie.

Not being particularly fussy about such things, I usually select Very Fast 1080p30 because it makes the transcoding process…well…a bit faster than the default (Fast 1080p30).

Once you’ve made your selection, simply close the Presets Window.
You then need to click the Open Source button to select the location of the source you want to transcode. If there is an optical disc available, Handbrake should defualt to this.
Simply click Open

The disc will then be scanned ( which can take a while) before Handbrake presents you with it’s choice of which title to encode :

…which you can then change if you with using the drop-down.

Once you have chosen which title, you may want to have a look at the Subtitles tab.
By default, Handbrake will only attempt to rip “forced” subtitles. These are subtitles for parts of the movie that aren’t in the main language of the movie. If the movie you are working on does not include these then you can save yourself 1 encode pass ( and a fair bit of time) by removing them by clicking the ‘X’ button

Once done, you can return to the Summary Tab and hit the Start Encoding button

If you do select subtitiles, Handbrake will do two encoding passes. The first appears to be for the subtitles and has no appreciable impact on system resource usage.

When the second pass starts, however, you’ll observe a spike in the CPU usage…

For most discs, this approach should work perfectly well.
But what can you do when a disc decides to do an impression of a barnacle covered in bioluminescent algae ?

MakeMKV

MakeMKV is a transcoder – i.e. it converts video into MKV format.
MakeMKV has also been in Beta since at least 2008.

Usually, I’m a bit reluctant to risk beta programs on my machine. On this occasion however, I’ve decided that I just need to chill out and Let It Go…

Also, whilst Blu-Ray processing will be an additional cost feature when (if) the tool ever moves to a “production” version, it is currently free.

The installation route I followed was :

sudo add-apt-repository ppa:heyarje/makemkv-beta
sudo apt-get update
sudo apt-get install makemkv-oss makemkv-bin

Note that you may occasionally be prompted for a license key when starting this tool. If so, you can find it on this MakeMKV official forum post.

Fire up MakeMKV and it will automatically scan any optical drives.
Once the tool recognises that there is a disc in the drive, click on the drive graphic to open the disc :

MakeMKV will then scan the disc and then present you with a list of titles.
You will need to check/uncheck the appropriate titles to copy…

For DVDs this should simply correspond to the title selected by VLC (see above).
For Blu-Rays, things are slightly more complex.

If you check the right-hand pane for each Title, it will show the duration. You’re looking for one that is the approximate runtime of the film.
If there are multiple titles that fit the bill then check the number of chapters as well. This should also match the number of chapters in the Title auto-selected by VLC
Note If the Title does not contain any chapters then the Chapters row will be omitted from the Title details pane.

Once you’re happy with your selection – uncheck the checkboxes for all of the other titles.
Expand your chosen title and make sure that you’re happy with the sub-menu selections.

Once all that’s done, hit the Save button.

By default the tool will save the file to a newly created sub-directory under $HOME/Videos. It will prompt you before creating this. In my case, I just say yes at this point.
Whilst the transcoding is not resource intensive, it also does not tend to be that fast. You may be twiddling your thumbs for a bit…

Current size is shown as Output size

MakeMKV demand on system resources is modest…

…and you will eventually end up with an mkv file…although it’s quite big (over 20GB in this case).

The good news is that you can now point handbrake at said file…

Converting mkv to mp4 using Handbrake

Now we’ve got our rather large .mkv file, we can turn it into a more reasonably sized mp4 file by using Handbrake.
Simply open Handbrake, and select Open Source as before.
This time however, instead of using a disc directly, navigate to the .mkv file and select it.

Handbrake should then work as before, down to the resource intensive conversion. Ultimately however, you will be left with an mp4 file which is a rather more manageable size. For movies originally copied from Blu-Ray it’s usually no more than 2GB, depending on the Handbrake settings you’ve chosen.

Wrap-up

Hopefully, the tools and techniques covered here will work for most (if not all) of the discs you want to view or copy on your Ubuntu device.
Once you have your videos on file, you may find it useful to use some kind of media management software, such as Plex.

There are a number of articles around that may also be of use in your continuing Ubuntu video adventures…

As for me, I’m off in search of some cookie robots.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.