Bluray to MKV with x265 and Opus

The major question is 'what tools do I use and what format do I pick?'

Choosing your tools and format

Step 1: Ripping

First, you have to get the raw movie off the Bluray. The most flexible and simple option is to use makemkv. It allows you to select the part of the disk you want and save it to a .mkv file. This lets you put the disk back in the sleeve and send it off or put it back on the shelf while you encode, which will take a while. The only real downside is you have to compile it in linux. This is quick though.

Step 2: Encoding

There are two major free tools out there; FFmpeg and HandBrake. The latter wins because it includes auto-cropping and the nlmeans denoise filter in one easy step. The command line version is very useful.

Step 3: Format

When using the encoding tool, you have to choose what format you want for the audio and video track. As long as you'll be watching it on a modern device, you can use modern 'codecs'  As of the beginning of 2017:

OPUS - To paraphrase FFmpeg's Page. This wins on both size and quality across most categories

x265 - This wins based on size. i.e. you can get the same perceived quality in half the size vs h.264 and it also edges out Google's VP9.  Netflix seems to agree as well.

mkv - this is a recent change, replacing mp4 which in the past was more compatibile. MKV is now widely supported and is much more flexible. 

Running the encode

Let's assume you looked at the makemkv pages and successfully ripped the main title to a mkv file with just the audio and subtitle track you care about. Let's also assume you're on Ubuntu and installed HandBrakeCLI from the repo.

HandBrakeCLI -i input.mkv -o output.mkv --encoder x265 --encoder-preset slower --quality 25 --nlmeans --nlmeans-tune film --subtitle 1 --aencoder opus --mixdown 5point1

A little about those options
--encoder        # Use x265 for lowest sized results
--encoder-preset # Use slower if you have time, compare here 
--quality        # 25 usually looks the same as source
--nlmeans        # Reduces size of video by reducing noise and detail
--nlmeans-tune   # Set to film or animation depending on source
--subtitle       # includes the subtitle track
--aencoder       # Use Opus
--mixdown        # If your source isn't 5.1 look at the HandBrakeCLI --help options

Of all of these options, nlmeans will chew up the most time. 


Not every source is better with the nlmeans filter. For details on how to test with short segments and batch options. See the HandBrakeCLI page.

HandBrakeCLI may not have the newest and greatest codecs in it. You can of course, extract tracks and run them though ffmpeg based options.

Plex on the FireTV doesn't understand opus 5.1. Until that is fixed you'll need to use --mixdown stereo