based on L. Preston Sego III’s work, check it out here.

first we need to install some tools:

$ mkdir ConverterTemp
$ cd ConverterTem
$ curl -O http://www.cmake.org/files/v2.8/cmake-2.8.3.tar.gz
$ tar xvfz cmake-2.8.3.tar.gz
$ cd cmake-2.8.3
$ ./bootstrap
$ make
$ sudo make install
$ svn co http://aften.svn.sourceforge.net/svnroot/aften Aften
$ cd Aften
$ mkdir default
$ cd default
$ cmake /../../Aften/
$ make
$ sudo make install
$ svn co svn://svn.videolan.org/libdca/trunk libdca
$ cd libdca
$ ./bootstrap
$ ./configure
$ make
$ sudo make install

download MKVtoolNIX from http://jonthn.free.fr/MKVtoolnix/

$ sudo ln -s /Applications/Mkvtoolnix.app/Contents/MacOS/mkv* /usr/local/bin/

install mkvdts2ac3:

$ curl -O https://github.com/JakeWharton/mkvdts2ac3/raw/master/mkvdts2ac3.sh
$ chmod 755 mkvdts2ac3.sh
$ sudo cp mkvdts2ac3.sh /usr/local/bin/mkvdts2ac3

Usage:

$ mkvdts3ac3 --new -n -f -wd /Volumes/myDisk/Rips mymovie.mkv