This is intended as a small guide in extracting hi-res audio from Blu-ray discs to be played in your favourite audio player iTunes, Audirvãna etc. This guide will show you how to convert any high resolution PCM audio track on a Blu-Ray video/audio disc into Apple Lossless audio (ALAC) and split it into tracks based on chapters on the disc.
Some manual tinkering will be need to make it work, so some technical knowledge is needed, as well as knowledge of how to use the Terminal under MacOS.
Tools that is used for this guide are:
- MKVExtract (Command line tool): https://mkvtoolnix.download
- BBEdit (text editor with RegEx capabilities) https://www.barebones.com/products/bbedit/index.html
- XLD – for splitting and converting the audio.
XLD (X Lossless Decoder) is a lossless decoder for MacOS which is usually used to rip CD’s, but it also capable of converting PCM with CUE files into a format of choice, and that is what this guide will use it for.
XLD documentation and download can be found here: https://tmkk.undo.jp/xld/index_e.html
The MKV tools needed can be installed using HomeBrew
We assume that the blu-ray has already been ripped to disc and main content has already been placed in a MKV container, from which we can extract the raw audio as well as chapter information.
- Extract the raw audio:
mkvextract [name_of_input.mkv] tracks --fullraw [trackid]:[outputname.pcm]
2. Extract chapter information
mkvextract [name_of_input.mkv] chapters -s [outputname.txt]
This well output chapter information in the following format, which contain the starttime for each chapter, which will be used to determine the start time for the final tracks.
CHAPTER01=00:00:00.000 CHAPTER01NAME=Chapter 01 CHAPTER02=00:10:02.000 CHAPTER02NAME=Chapter 02 CHAPTER03=00:15:35.000 CHAPTER03NAME=Chapter 03
Note: The time is in hh:mm:ss.zzz format, where XLD need time in the format mm:ss:zz, so some manual editing is need for rips that are longer that 60 minutes,
3. Converting Chapters files to CUE format
For this we will be used BBEdit.
The basic .cue format needed for XLD is as below
TITLE "[The album title goes here]" PERFORMER "[The Artist name goes here]" REM DATE "[year]" REM DISCNUMBER 1 REM TOTALDISCS 1 FILE "[name of the PCM file]" WAVE TRACK 01 AUDIO TITLE "Track 01" INDEX 01 00:00:00 TRACK 02 AUDIO TITLE "Track 02" INDEX 01 09:02:00
So we need to do some text replacing using some simple RegEx in BBEdit to convert the exported chapter information into the .cue format.
grep: CHAPTER([0-9][0-9])= replace: TRACK \1 AUDIO\nTITLE "Track \1"\nINDEX \1 grep: ".[0-9][0-9][0-9]" replace: ":00" grep: "INDEX [0-9][0-9]" replace: "INDEX 01" grep: "TRACK" replace: " TRACK" grep: "TITLE" replace: " TITLE" grep: "INDEX" replace: " INDEX" grep: " [0-9][0-9]:" replace: " " grep: "CHAPTER[0-9][0-9]NAME=Chapter [0-9][0-9]\n" replace: ""
Note that the above will strip the “hh:” information from the timestamps, so for titles longer than 1 hour, you will have to manually edit the time stamps for the tracks, by adding 60 minutes for the chapters above hour 1, 120 minutes for any track above hour 2 etc.
Once this is done, we just need to add the missing title, performer, disc etc. information to the top of the file, and then save it as a .cue alongside the exported .pcm file, ready to be picked up by XLD.
4. Converting using XLD
In XLD go to “File” -> “Open Raw PCM (bin+cue)” and open the .cue file created above. This should automatically load the exported .pcm file and you should see a list of tracks in the window.
You can now use the build in “Get Metadata” function to get the track titles, or you can rename them yourself.
Once ready click on “Transcode” and this will export the PCM to ALAC (or what settings you have made in XLD for output format), and now the soundtrack from your favourite Blu-Ray will be playable in iTunes in all its high-res glory.
Hope this can be of help – feel free to comment below.
If you found this guide useful, maybe you’d check out my guides How to extract subtitles from TS (transport stream) files or How to extract subtitles from TS (transport stream) files.