BLAH-BLAH > IT > How-To's > Blu-Ray to MKV

Blu-Ray to MKV


Update 30.Dec.2010

Using mkvtoolnix (for "mmg") version 4.4.0 and mplayer 1.0_rc4_p20101219 (earlier versions might work as well - these are just the versions I tested) you can skip steps 3 and 4 saving a lot of time!
Meaning that if you want to keep the original quality you can put into the mkv-file straight the original video, audio (tried until now DTS-HD) (and BR-subtitles? Not confirmed) and mplayer will be able to handle them.
Of course you'll need a machine powerful enough to handle them when playing the file and a lot of free disk space. And in my case the DTS-HD audio stream is accepted by my old DTS-amplifier (over digital TOSLINK).


Overview

   1. I copy the contents of the BD on WinXP using "AnyDVD HD" and save it on my HDD.
   2. I extract the audio and subtitles on WinXP using "Clown_BD".
   3. I convert the subtitles on WinXP from sup to srt using "SupRip".
   4. I transcode the main movie on Linux using "mencoder".
   5. On Linux I put the video, audio and subtitles into a MKV-container using "mmg" (part of the "mkvtoolnix"-package).
   6. I watch the resulting file on my Linux-mediacenter using "mplayer" as player.


Details

Some time ago I decided to get rid from my living room of all those DVDs and decided to put there a PC (running a Linux OS using the Gentoo distribution), transform it into a mediacenter, connect it to the TV and convert all my DVDs to MKV-files, keeping all languages and subtitles.
It worked great! This way I was able to free up a lot of space and additionally whenever I want to watch a movie I don't have to spend time searching for the right movie-case.

Meanwhile technology advanced and Blu-Ray is slowly replacing DVDs offering a better picture quality for about the same price, so I thought about accomplishing again same but using the different medium :o|

I wasn't sure if it was already possible to do with blu-ray the same conversion to MKVs I used to do for DVDs, but last weekend I saw that LG's blu-ray-rom (GGC-H20L) was actually quite cheap, so I gave it a try.

As of now it looks like the whole procedure is not yet as easy as with DVDs, but at least it's working fine. Here are my notes about how to do that.

First of all: I am using two OS - WinXP and Linux - and on WinXP I am using the payware AnyDVD HD
WinXP is a must when it comes to decode the blu-ray - you'll have to install on that OS AnyDVD HD in order to be able to read the blu-ray. Linux is probably optional because of the great "mencoder/mplayer" and very nice & simple MKV-muxer "mmg" (both SW are available as well for Windows).


In Windows

  • Copy the contents of the BD to your HDD
    The first step is simple: download the trial version of AnyDVD HD and install it.
    After having done that, and rebooted the OS, you'll see that a new icon appears on the taskbar. Right-click on it and select to rip the whole disk to a directory you choose.
    After some time you'll have in that dir all files that were on the blu-ray, but they won't be anymore in an encrypted form.
  • Extract the audio and subtitles
    Now download and run Clown_BD. It's a great piece of software and with it you'll be able to extract (the main movie, which I don't - I do that in Linux) any audio language and any subtitle that is on the blu-ray.
    If the main language is in format "TrueHD/AC3" and you don't have a TrueHD-amplifier (or are just happy with the normal AC3-quality), don't select it and do afterwards again the same selecting only that specific language and choose instead of "Unconverted" the "AC3"-option with 640kbps. This because a TrueHD/AC3-track needs ~4GB, while the same needs ~700MB as normal multitrack AC3.
  • Convert the subtitles
    Once you have extracted the audio (.ac3?) and subtitle (.sup) tracks download and start SupRip - this will allow you to convert the subtitles sup-format to srt, which can then be included into a the final mkv-file (check first on Moviesubtitles.org if by chance they're already available).
    Select the subtitle you wish and after that you should see the first subtitle, probably with some of the chars highlighted in red - those ones could not be recognized by the program.
    Double-check the settings - try them out to see if things improve. I am currently using the following ones:
        * Space Width: 12
        * Character Split Tolerance: 1
        * Character Similarity Tolerance: 25
        * Contrast: 0
    If you click on the "OCR"-button it will show you the first char which was not recognized. Type in the correct letter, select if the char is displayed in italic-form or not, click on "OK" and the program will ask you again about the next char in the subtitle that it wasn't able to recognize. Once you're done click again on "OCR" and the program will search for the next char that it didn't recognize.

    This might sound like a looong job to do, but the program learns each time you perform a correction, so in the end it took me just 30 minutes to extract the english subs of Star Trek XI and the quality was practically perfect - very nice.

    Once you're done save the sub to a ".srt"-file.
  • Time to reboot (if you have Linux on the same machine) and start Linux. 

In Linux

  • Transcode the main movie
    Now that you're in Linux, mount the windows partition (or transfer the files) where you have the blu-ray you extracted and the audio & subtitle tracks.
    Have a look at the dir where you have extracted the whole blu-ray - you should see a file which is huge - in my case ~40 GB - that's the main movie and that's what you want to transcode to order to make it smaller. Doublecheck with mplayer -framedrop that that file really contains the main movie.
    To transcode the main movie I use the following script (for sure not the best script around:oP ):

echo DID YOU REVIEW THE CROPPING PARAMETERS??
echo Sleeping for 5 seconds...
sleep 5
rm x264_2pass.log*
rm divx2pass.log*
mencoder $1 -vf crop=1920:800:0:140,hqdn3d=chroma_tmp -oac copy -ovc lavc -lavcopts \
vcodec=libx264:vbitrate=9000:vpass=1:threads=4:turbo:mbd=2:trell=yes:v4mv=yes:autoaspect \
-o /dev/null
cp x264_2pass.log divx2pass.log
mencoder $1 -vf crop=1920:800:0:140,hqdn3d=chroma_tmp -oac copy -ovc lavc -lavcopts \
vcodec=libx264:vbitrate=9000:vpass=2:threads=4:mbd=2:trell=yes:v4mv=yes:autoaspect \
-o converted.avi

Actually, a after upgrading few weeks ago (today: June 2010) mplayer, ffmpeg and x264, the script above didn't work anymore - was complaining about some ffmpeg-profiles and I didn't quite understand what I had to do in order to make it work.
I therefore switched to x264 instead of lavc and I am now using the following parameters:

echo DID YOU REVIEW THE CROPPING PARAMETERS?? -vf cropdetect=50
echo Sleeping for 5 seconds...
sleep 5
rm divx2pass.log*
mencoder $1 -vf crop=1920:800:0:140 -oac copy -ovc x264 -x264encopts \
bitrate=10000:pass=1:turbo=1:me=umh:me_range=32:subq=5:nodct_decimate:threads=4 -o /dev/null
mencoder $1 -vf crop=1920:800:0:140 -oac copy -ovc x264 -x264encopts \
bitrate=10000:pass=2:turbo=0:me=umh:me_range=32:subq=5:nodct_decimate:threads=4 -o converted.avi

As you can see I do not use anymore the filter "hqdn3d" - I had the feeling that it doesn't work very well when using the other x264encopts-parameters.

The utility "mencoder" is contained in the package "mplayer" - the best media player of planet earth. Before running the script make sure to review...

   1. The overall parameters: I am using those parameters after a long run of trial-and-error. Please read the section below about them.
   2. The crop parameter ("crop=1920:800:0:140") to eventually remove the black side-bands of the video. You can try to auto-detect them with "mplayer -vf cropdetect=50 ." or just take it out if your video has no side-bands or don't have a clue what it is, but this might reduce the final quality of the transcode.
   3. The bitrate of the output video. "vbitrate=9000" will generate a ~8GB file for a ~2-hours 1080p movie.
   4. The number of threads ("threads=4") which should be equal to the number of available CPU-cores on your PC.

Save the script into some file, make it executable (chmod +x myscript) and run it (myscript ).
After it's done (maaaany hours, sigh.....) it will generate an output file called "converted.avi".

If you have multiple ".m2ts"-files, just rerun the script as well for the other files and use "avimerge" (part of the "transcode"-package) to join all the files at the end (e.g.: "avimerge -i file1.avi file2.avi file3.avi -o allfiles.avi). "avimerge" won't touch the encoded movie - it will just unite all the single files and will run very fast.

  • Create the MKV-file
    Once you have the output file, run (still in Linux) mmg (contained in the package mkvtoolnix), add the file you just converted (select only the video track), add the the audio tracks you extracted before using clown_BD and add the srt-file you created.

mencoder parameters

I am not going to write about the main parameters. Here is a screenshot of the original blu-ray...

...and the resulting transcoded file:

vcodec=libx264:vbitrate=9000:vpass=1:threads=4:turbo:mbd=2:trell=yes:v4mv=yes:autoaspect

As you can see I am using as well the "hqdn3d" which you might not use.
I personally hate the grainy look that movies have on blu-ray, and I wanted to get rid of it. That filter, and this is my personal opinion, partially solves that problem without destroying the fine details of the movie (up to you to decide):

They're not exactly the same frames (wasn't able to extract them), but while the first and second pictures should show the same amount of details, in the third picture you should see less "grain" in the empty areas (e.g. around the star) than in the others, while the details have been preserved.
I admit that the difference is minimal, but still better than the original - "stronger" parameters would have probably decreased the overall quality.


Links: https://help.ubuntu.com/community/RestrictedFormats/BluRayAndHDDVD