UPDATE: This script has been superseded to add more features and correct a major issue, see here.
I’ve been buying some BluRay audio discs as a relatively inexpensive route to HD audio content, there’s some great remasters and remixes coming out and many include a conventional CD and BluRay audio in various formats, from 96/24 LPCM, 192/24 LPCM or various surround sound formats.
There’s numerous pieces of software for this and some paid for options might be slightly simpler, but I’m using MakeMKV (http://www.makemkv.com/) as it’s cross-platform and cheaper than many other options (it’s free for DVD ripping, a one off payment for BluRay ripping.
The latest version of MakeMKV can rip the audio tracks to FLAC, the result of which, in the case of a BluRay audio disc, is a video file (the video part of which is usually the track listing) and a FLAC audio track. It also results in all audio tracks being in a single video file, with chapter metadata identifying the individual tracks.
What we need to do is split the video file into chapters and demux the audio streams to produce a FLAC file we can use on our music playback system of choice (in my case various Squeezeboxes or a Raspberry Pi with a Wolfson / Cirris audio card).
Whilst this can be done with various open source tools, remembering the command line to type to achieve it can be frustrating, so I cobbled together some bash script to do the hard work, based on a post in the MakeMKV forum here.
The workflow is: –
- Choose tracks in MakeMKV to rip, along with the relevant audio track you require
- Split resulting video file into chapters
- Demux audio into FLAC file
- Add metadata (tags)
- Listen and enjoy!
First of all, run MakeMKV and enable ‘Expert’ mode within the settings.
The next challenge is to split, demux and tag the resulting files, this is where the bash script comes in, the following script uses mkvmerge to split the single video file into chapters (placing the split files into a folder with the same name as a ripped track), it will then ask you for track names for each chapter (which is the name of each song), this will rename the files with the titles you type in (or press enter to keep them the same). Although this doesn’t add tags to the files, you can use many audio tagging tools to convert the file name to tags.
Once the files are split and renamed, it uses mkvextract to demux the audio to a FLAC file, deleting the individual MKV files.
The script above accepts the file to be demuxed as it’s input argument. Assuming you’ve saved the above to a file called chaptersplit.sh, you can run it thus: –
The result will be a folder named ‘inputfile’ containing all of the audio tracks in the original MKV as FLAC files, with the names you entered into the script when asked.
You can then use your tagging tool of choice to convert the file names to tags, adding Artist info and dates as necessary.
It would be nice to automate this latter part, if anyone knows a way to add this functionality in automatically, please let me know in the comments and I’ll amend this post accordingly for the benefit of others.