How to Remuxing Blu-ray into .mkv

How to Remuxing Blu-ray into .mkv1. Introduction

Muxing comes from the word multiplexing, which in technical language stands for combining different data signals into one data signal. In our context, muxing simply means bringing streams of various kinds (e.g. audio, video, subtitles, video-in-video etc.) together into something meaningful like a movie. However, movies are not the only media type that "gets muxed": for instance, one can mux two different audio streams to create an audio book with two different stories. Unlike mixing, the main feature of muxing is that it keeps the various streams in their own dedicated tracks, thus still preserving them well distinguishable from each other for all technical purposes. At this point I will spare you any deeper comparision of muxing vs. mixing of data signals as it would go far beyond the scope of this guide.

As the name suggests, demuxing is the inverse process of muxing, i.e. splitting, say, a movie, be it in blu-ray folder structure format or .mkv container format, into its various streams (e.g. audio, video, subtitles etc.).

In our context, remuxing is thus the process of extracting the streams from a movie and their subsequent muxing. At first, this may sound like pure idling, but it is not! More specifically, remuxing allows a lossless conversion of a movie from one format to another format while being able to get rid of additional unnecessary information not directly relevant to the movie itself, thus saving precious storage space. This is often the case with blu-rays and this guide is focused on the lossless conversion of movies from blu-ray format into .mkv container format while getting rid of additional blu-ray features and tracks from the blu-ray, thus significantly shrinking the size of the movie without even the slightest decrease in audio or video quality.

2. Setup

2.1. Software:

Operating system: Windows 7 x64

Demuxing software: EAC3TO (portable cmd application)

Muxing software:
mkvmergeGUI from the MKVtoolnix suite for Windows (available either as a windows installer or as 7zipped portable application)

Remark 1:
On my computer I have a folder C:/Video_Encoding, where I place the folders of all portable tools used for the purposes of any type of video (de-, re-)muxing, encoding or editting. In particular, the eac3to.exe tool is placed under C: /Video_Encoding/eac3to. In the following guide, I will be using these paths for reference, but of course, you are free to choose names and paths that better suit your needs and taste.

Remark 2:
Once you have opened eac3to cmd window, do not close it until you have finished demuxing, or you will have lots of unnecessary typing work to do...

Remark 3:
To gain some useful typing space on cmd, I have resized its window to width 150 and height 70. It certainly helps for a good overview!

2.2. A very short comparison between eac3to and tsmuxer:


If you want, you can skip this section and go right to 2.3.

TSmuxer
is another popular tool to de- and remux blu-rays. However, I prefer eac3to to tsmuxer for a few reasons that I would like to explain here:

- Unlike eac3to, the development of tsmuxer was discontinued a much longer ago. Thus, in a long run, the chances that tsmuxer will work properly with upcoming standards and format advances decrease. In fact, as I will mention shortly, tsmuxer appears to have issues with even some of the already existing stuff.


- In many cases tsmuxer gives too long names to the output files, which results in a "-2 error" since Windows has general limitations for the lenght of file names, thus stopping the process of demuxing even before it has started. Unfortunately, I am not aware of any way to change the naming rules of tsmuxer. FYI, it combines the names of all relevant .m2ts files into the name of the output file, which is the reason for these lengthy file names. However, one can work around this issue by choosing the Desktop as output folder.


- It seems that tsmuxer cannot
always demux .m2ts files for themselves, but it is hardcoded to make use of stream interlinking. To back up this claim, a recent example I stumbled upon is the movie "The Way Back", where, if I remember correctly, the main stream file was 00006.m2ts. Demuxing it with tsmuxer results in a video that also includes the copyright warning frame that is actually located in a different stream file. One can then see in tsmuxer log that it actually makes use of additional .m2ts files, even though it was specifically set to use only 00006.m2ts. This issue is not present in eac3to. Why can this be a problem? Firsty, because most people don't like that additional frame being reminded of copyright stuff (pun not intended), especially when they have most likely downloaded the movie from some place... And secondly and more importantly, because the audio and video would be then out of sync due to the additional frames, unless, of course, one exactly knows the timing difference and adjusts the muxing software for it.

- TSmuxer does not cope well with glitches in the source. A very recent example for this is the TVseries "Broken Trail", where in part I there is a minor video glitch between the 8th and 9th minute. Demuxing with tsmuxer totally messes up the timing of audio and video, so both get out of sync past the glitch point. No such problem exists with eac3to.


2.3. The intelligent setup:


While, as the name suggests,
mkvmergeGUI is in fact a GUI, eac3to does not have its own GUI as it is purely a cmd application. There are third-party GUI projects for eac3to, but I neither like, nor trust them, so I simply don't use them. In fact, once got used to it, the cmd way is much faster and convenient than the gui way and also saves you from potential bugs in the GUIs! There is only one drawback: you cannot start eac3to by double-clicking the .exe file in its folder because it is a cmd application and will close immediately. So, you will always have to browse to its folder via cmd, which slowly but surely becomes annoying over time. But as always, there is a work-around:

(1) navigate to
C:/Video_Encoding/eac3to/eac3to.exe, right-click on eac3to.exe and select 'Send to Desktop' in order to create a shortcut of it on the desktop;

(2) right-click on that shortcut, select 'Properties' and then select the tab 'Shortcut', where under 'Target' remove anything present and enter the following:


Code


cmd /k "C:/Video_Encoding/eac3to/eac3to.exe"

Now you have a working shortcut on your desktop that opens eac3to in cmd mode without the window being immediately closed on you like before, and you can start using the tool right away! Of course, if you have placed the eac3to folder under a different path, you will have to adjust the right hand side of the above code accordingly.

3. The demuxing process


3.1. Identifying the playlists with eac3to:


The movie we are going to demux is
Ghost.1990.1080p.Blu-ray.CEE.AVC.TrueHD.5.1-HDRoad. One thing you should know about the blu-ray format by now is that the BDMV folder (=Blu-ray Disk MoVie) is the main folder in the Blu-ray structure where all the streams and playlists are located. In the BDMV folder we find the STREAM folder and the PLAYLIST folder. As the names suggest, the STREAM folder contains all the streams (various video, audio etc.) in the form of multiple interlinked files .m2ts containers and the PLAYLIST folder contains playlist files in .mpls format that allow the playback of various combinations of the streams.

In my case the BDMV folder is located under:


Code


F:/uTorrent/Ghost.1990.1080p.Blu-ray.CEE.AVC.TrueHD.5.1-HDRoad

where uTorrent is the folder I place my current downloads. Fire up eac3to from the desktop shortcut. If you have set up the shortcut properly as described above, eac3to window should look like this:


Now, type in the
eac3to cmd window:

Code


eac3to "F:/uTorrentGhost.1990.1080p.Blu-ray.CEE.AVC.TrueHD.5.1-HDRoad

and press enter. Notice the quotes-unquotes on both sides of the movie location! BTW, instead ot typing this whole long path, you can just type

Code


eac3to ""

then navigate to the Blu-ray folder in Windows Explorer, copy the path, then right-click in between the quote-unquotes in the eac3to cmd window and choose 'paste', then hit enter. This minimizes the typing work by some. You should get something like this:



EAC3TO displays all the
relevant playlists in the BDMV folder, enumerating them by 1), 2), 3) etc. In our case, we have only one relevant playlist, that is labeled as 1). However, in general, it is not always playlist 1) that contains the main movie. In particular, this is often the case with blu-rays that include multiple cuts, so one has to pick the playlist that corresponds to the cut one wishes do demux. Often, the playlist containing the main movie (or the cut of interest) could be recognized by its duration, but sometimes this can be deceptive, because the longest in duration playlist might also include some additional stuff and thus is not suitable for demuxing. Occasionally, even worse, none of the available playlists will be suitable for demuxing as they would include either too much or too less of the main movie. In the latter case see section 3.4.

3.2. Identifying the tracks with eac3to:


To get a detailed overview of the various tracks included in the playlist that we may wish to demux, type in the
eac3to cmd window:

Code


eac3to "F:/uTorrentGhost.1990.1080p.Blu-ray.CEE.AVC.TrueHD.5.1-HDRoad" 1)

or instead you can just press the up-arrow on your keyboard, which will invoke the last entered command, and then you add 1) in the end of the command string. This way you don't have to type everything over and over again.

Hit enter. You should see something like this:




EAC3TO enumerates the different tracks in the selected playlist
1) by 1:, 2:, 3:, 4: etc.

3.3. Demuxing of the chosen tracks:


Now, we are going to select the tracks we need to get demuxed, the output path and the output names. I am interested in the following tracks:


2:
h264/AVC video
3:
TrueHD audio
11:
English PGS subtitles
15:
Bulgarian PGS subtitles

The path where I would like the output of the demuxing to be stored is


Code


E:/ghost

There is no need to create that folder beforehand, eac3to will do it for you when it starts demuxing.

Go back to the
eac3to cmd window, again press the up-arrow and append at the end of the command string the following things:

Code


2: E:/ghost/video.h264 3: E:/ghost/audio.thd 11: E:/ghost/en_subs.sup 15: E:/ghost/bg_subs.sup

or altogether typed:

Code


eac3to "F:/uTorrent/Ghost.1990.1080p.Blu-ray.CEE.AVC.TrueHD.5.1-HDRoad" 1) 2: E:/ghost/video.h264 3: E:/ghost/audio.thd 11: E:/ghost/en_subs.sup 15: E:/ghost/bg_subs.sup

It should look like this:



I will explain shortly what everything means. More generally, the syntax of
eac3to for our purposes is basically:

Code


eac3to "<movie path>" <playlist number> <track_1 number> <track_1 output>...<track_n number> <track_n output>

where 'output' is going to be the output file together with its full path.

You
do not have to name the output files by 'audio', 'video' and 'subtitle' as I do, you can choose any valid name for them, but you do have to append the correct file extensions, depending on the type of stream you are demuxing. Below you can find a table of the stream types and the corresponding file extensions:

Video

VC-1: .vc1
AVC (h264): .h264
MPEG-2: .mpeg2, .m2v

Remark:
eac3to has also the ability to mux raw video streams directly into .mkv (you need to have Haali Media Splitter installed). That is, you can save the video stream directly as .mkv. However, you will still have to use mkvmerge later in order to add the audio and subtitle tracks.

Audio

AC3 (used by Dolby Digital): .ac3
FLAC: .flac
EAC3 (used by Dolby Digital+): .eac3
TrueHD (without AC3 core): .thd
TrueHD (with AC3 core): .thd+ac3
DTS: .dts
DTS-HD: .dts, .dtshd, dtsma (it does not matter whether it is MA or HR)
LPCM: .wav (the more natural extension would be .pcm, but for some reason mkvmergeGUI appears to have problems muxing the .pcm format, so it is better to store the LPCM audio track in a raw .wav file)

Chapters

.txt

Remark:
If you are going to use tsMuxeR with TrueHD audio after demuxing with eac3to, make sure the extract the TrueHD audio stream together with the AC3 core, otherwise tsMuxeR will reject the TrueHD audio stream!

PGS Subtitles (from blu-ray
)
.sup

To sum up, we have reached the stage:


Code


eac3to "F:/uTorrentGhost.1990.1080p.Blu-ray.CEE.AVC.TrueHD.5.1-HDRoad" 1) 2: E:/ghost/video.h264 3: E:/ghost/audio.thd 11: E:/ghost/en_subs.sup 15: E:/ghost/bg_subs.sup

Press enter and let eac3to do its job. After it has completed, you will find the files video.h264, audio.thd, bg_subs.sup and en_subs.sup in the output folder E:/ghost, ready and waiting for you to mux them into a .mkv container.

If eac3to produces an error, you will hear a very unpleasant sound. If it finishes with success, you will hear a relatively pleasent sound. I found both annoying, so I disabled them by deleting the two .wav files located in the eac3to folder...


3.4. Demuxing from a .m2ts file:


In some cases, one has to demux directly from a stream file instead from a playlist file, for instance from


Code


F:/uTorrentGhost.1990.1080p.Blu-ray.CEE.AVC.TrueHD.5.1-HDRoad/BDMV/STREAM/0125.m2ts

which then altogether becomes our <movie path> in the syntax above. Notice that unlike with demuxing from playlists in the BDMV folder, one has to specify the exact file! You will have to do all aforementioned steps to find out the contained tracks, i.e. start with

Code


eac3to "F:/uTorrentGhost.1990.1080p.Blu-ray.CEE.AVC.TrueHD.5.1-HDRoad/BDMV/STREAM/0125.m2ts"

and proceed analogously (of course, excluding the playlist step since we are not demuxing from playlists).

As already mentioned, the movie "The Way Back" is an example where one has to demux from the 'core' stream file instead from the main playlist, otherwise one ends up with some extra copyright stuff in the video track that brings audio and video out of sync in the default muxing mode, unless one knows the exact timing discrepancy.


3.4. Full demuxing:


Using the
-demux switch in eac3to, one can easily do a full demux of a playlist or a file, without having to specify path and name for each stream.

Examples:


Code


eac3to "F:/uTorrentGhost.1990.1080p.Blu-ray.CEE.AVC.TrueHD.5.1-HDRoad" 1) -demux

and
Code

eac3to "F:/uTorrentGhost.1990.1080p.Blu-ray.CEE.AVC.TrueHD.5.1-HDRoad/BDMV/STREAM/0125.m2ts" -demux

The streams are then automatically extracted in the eac3to folder. Also note that the -demux switch will extract TrueHD audio as .thd+ac3, i.e. including the AC3 core. This method has the disadvantage of being slighly slower due to the fact that it extracts all tracks, but is has two advantages: you will have to type less and it will give nicely descriptive names to the various streams.

4. Muxing:


4.1. Specifying the frame rate:


Fire up
mkvmergeGUI, select video.h264, audio.thd, bg_subs.sup and en_subs.sup and drag and drop them onto it. It should look like this:



When you are adding the files,
mkvmergeGUI will warn you that you are adding a AVC/h.264 video, so the default setting for 25 fps frame rate may not be applicable. Click 'OK' and keep in mind that while most Blu-rays have the frame rate of 23.976 fps, there happen to be a few exceptions. More on the frame rates of BDs can be found in this link.

You always have to make sure what the exact frame rate of the movie is, because you will need to specify this in
mkvmergeGUI. Specifying wrong frame rates will bring your video and audio out of sync. The exact frame rate can be read from eac3to's initial scan as follows:



The string
1080p24 /1.001 gives us the information that the frame rate of the movie is 24/1.001, which means 24 frames per 1001 miliseconds or the mathematically equivalent 23.976 frames per 1000 miliseconds (1 second=1000 miliseconds) a.k.a 23.976 fps.

Now we know for sure that the frame rate of our movie is
23.976 fps. The first thing we do next is to enter this value where it belongs: under 'tracks, chapters and tags' select the video track and switch below to the tab 'Format specific options'. There under FPS you have to enter the exact frame rate or[b] select the correct frame rate in the drop down list, in this case [b]23.976 (24000/1001). It should now look like this:



4.2. Some cosmetics - specifying the track language and names:


You can rearrange the different tracks in the order video-audio-subtitles if you want to, but more importantly, always try to specify their language under the
tab 'General track options'. If you have several video, audio or subtitle tracks, omitting to specify the language makes only one of the multiple tracks visible to MPC-HC, and so, for instance, you won't be able to switch between different subtitles. It should now look like this:



If you wish, you can also specify a name to some tracks. Do not add brackets to the track name, mkvmergeGUI will do it for you. This feature is particularly useful if you want to include additional subtitles that for instance feature commentaries from the director and/or the actors, so you can distinguish them from the normal subtitles of the same language.


4.3. Compression settings:


There is now only one thing left before we can start muxing, and that is whether or not to use
zlib and header removal compression in the muxing mode. This is a matter of taste for those who are going to play the movie only on their HTPC's, but it is a matter of life and death for those who are going to use other kinds of hardware! Zlib is a general algorithm to compress "stuff" and is per default used by mkvmergeGUI to compress certain subtitle streams. Header removal compression is an algorithm used per default by mkvmergeGUI for 'lossy lossless' reduction of audio and video stream size. It is 'lossy' because it actually cuts off certain bits of the video and audio stream, but it is 'lossless', because these bits are not related in any way to the factual quality of the audio or video stream, but only play a "serving" role. More about it can be found here. The problem with these types of compression is that not every hardware is compatible with them (yet), although the general trend is that manufacturers release compatibility updates for their players to enable them to play that type of media content. As for the question, how much storage space is saved by these compression methods - in my experience, it can hardly reach 100 MB, when it happens at all (and this is not very often, it seems), which is pretty much nothing against the background of, say, 18 GB for a relatively small remux. As already mentioned, both zlib and header removal compression are enabled by default in mkvmergeGUI. If you want to disable them, switch to the tab 'Extra options', highlight each track and under 'Compression' choose 'none' for each track. It should look like this:



The default compression for audio and video streams can be permanently disabled from the options of the mkvmerge as follows:


(thanks to Quasit for the screenshot!)

Unfortunately, as of now, there is no similar option for the subtitle tracks...


4.4. The special case TrueHD audio:

Unfortunately, as with any other popular mkv muxer, mkvmerge removes the AC3 core from TrueHD audio streams when muxing. If you want to keep the AC3 audio, say, for compatibility reasons, you will have to extract it from the raw TrueHD audio stream and mux it with mkvmerge as a separate track. The way to extract the AC3 core from the raw TrueHD audio stream is the following:

Code


eac3to audio.thd+ac3 audio2.ac3

where "audio.thd+ac3" stands for the full path of the TrueHD audio with AC3 and "audio2.ac3" stands for the full path of the output AC3 audio. The whole extraction process does not take more than 2-3 minutes.

4.5. Final step before muxing:


Under
'Output filename' specify the path and file name of the output file, but don't fotget to append the extension .mkv. If, however, you have forgotten to add this extension, this will not obstruct mkvmergeGUI from doing its job, you will simply have to add the file extension to the output file later on in explorer.

Now, you are done with all settings and can start the actual muxing


Note:
even if you have forgotten one of the aforementioned options, you can always 'repair' the .mkv by loading it back into mkvmergeGUI, selecting the option you have forgotten about, and performing the muxing again. There is no need to remux the full blu-ray all over again. However, keep in mind that you will still have to disable compression (if you want to assure compatibility) since at every run compression is performed by mkvmerge per default.

5. Performance:


Since both eac3to and mkvmergeGUI involve sequential reading and writing of big files, one can improve the application performance by choosing storage with good specs in sequential reading/writing. Also, it is wise to separate the reading from the writing by using two different storage devices. For example: the full blu-ray is stored on disk F, demux it to a location on disk E, then mux the different streams to a location on disk F. Avoid using the system disk (unless it is really fast), because mkvmergeGUI and in particular eac3to will noticeably slow down your system due to arresting your system disk for their own I/Os. EAC3TO is also just a little bit of cpu and ram intensive, but nothing extreme. The performance bottleneck for both applications is definitely the storage device. With two 7200rpm Hitachi HDDs (E: and F:) and two Quad-Core Xeons @3.00 GHz (not really relevant here), it takes about 20min to remux a full blu-ray with the approx. size of 42 GB down to ~30 GB.



Please share your comments and experiences on the comment area.


Similar Links: 

0 comments:

Post a Comment

 
© 2009 windows 8 download free Software | Powered by Blogger | Built on the Blogger Template Valid X/HTML (Just Home Page) | Design: Choen | PageNav: Abu Farhan