mkvdts2ac3.py
is a python script for linux, windows or os x which can be used
for converting the DTS in Matroska (MKV) files to AC3. It provides you with a set
of options for controlling the resulting file.
A recreation of mkvdts2ac3.sh which was created by Jake Wharton and Chris Hoekstra. I figured that most people are using this with sabnzbd which requires python so a non-os specific solution would help people out (as well as myself). There are a few extras I have added such as, sabnzbd support, nzbget support, recursively decending directories, and overwrite mode.
Make sure the executables for the following libraries are accessible.
- python - Python
- mkvtoolnix - Matroska tools
- ffmpeg - Audio conversion tool
Note: If you are a Mac OS X user you may need to compile these libraries.
If you have git
installed, you can just run
git clone git://github.com/dcthomson/mkvdts2ac3.py.git
.
You can download the script directly with wget or curl:
wget https://raw.github.com/dcthomson/mkvdts2ac3.py/master/mkvdts2ac3.py
-or-
curl -O https://raw.github.com/dcthomson/mkvdts2ac3.py/master/mkvdts2ac3.py
Otherwise you can click the "Download" link on the GitHub project page and download an archive and extract its contents.
Optional: If you want easy access to the script from any directory you can copy
or symlink the mkvdts2ac3.py
file to a directory in your PATH variable or else
append the script's directory to the PATH variable.
usage: mkvdts2ac3.py [-h] [--aac] [--aacstereo] [--aaccustom TITLE] [-c TITLE] [-d] [--destdir DIRECTORY] [-e] [-f] [--ffmpegpath DIRECTORY] [-i] [-k] [--md5] [--mp4] [--mkvtoolnixpath DIRECTORY] [-n] [--new] [--no-subtitles] [-o] [-r] [-s MODE] [--sabdestdir DIRECTORY] [--stereo] [-t TRACKID] [--all-tracks] [-w FOLDER] [-v] [-V] [--test] [--debug] FileOrDirectory [FileOrDirectory ...] convert matroska (.mkv) video files audio portion from dts to ac3 positional arguments: FileOrDirectory a file or directory (wildcards may be used) optional arguments: -h, --help show this help message and exit --aac Also add aac track --aacstereo Make aac track stereo instead of 6 channel --aaccustom TITLE Custom AAC track title -c TITLE, --custom TITLE Custom AC3 track title -d, --default Mark AC3 track as default --destdir DIRECTORY Destination Directory -e, --external Leave AC3 track out of file. Does not modify the original matroska file. This overrides '-n' and '-d' arguments -f, --force Force processing when AC3 track is detected --ffmpegpath DIRECTORY Path of ffmpeg -i, --initial New AC3 track will be first in the file -k, --keepdts Keep external DTS track (implies '-n') --md5 check md5 of files before removing the original if destination directory is on a different device than the original file --mp4 create output in mp4 format --mkvtoolnixpath DIRECTORY Path of mkvextract, mkvinfo and mkvmerge -n, --nodts Do not retain the DTS track --new Do not copy over original. Create new adjacent file --no-subtitles Remove subtitles -o, --overwrite Overwrite file if already there. This only applies if destdir or sabdestdir is set -r, --recursive Recursively descend into directories -s MODE, --compress MODE Apply header compression to streams (See mkvmerge's --compression) --sabdestdir DIRECTORY SABnzbd Destination Directory --stereo Make ac3 track stereo instead of 6 channel -t TRACKID, --track TRACKID Specify alternate DTS track. If it is not a DTS track it will default to the first DTS track found --all-tracks Convert all DTS tracks -w FOLDER, --wd FOLDER Specify alternate temporary working directory -v, --verbose Turn on verbose output. Use more v's for more verbosity. -v will output what it is doing. -vv will also output the command that it is running. -vvv will also output the command output -V, --version Print script version information --test Print commands only, execute nothing --debug Print commands and pause before executing each
If you want to set some options as default you can use the configuration file: mkvdts2ac3.cfg
[mkvdts2ac3] # These options take an argument. # To enable you must remove the # at the beginning of the line and supply the # argument. #sabdestdir = #custom = #compress = #destdir = #track = #wd = #verbose = # These options don't take any arguments, they are only true or false # false is the default # remove the # at the beginning of the line to enable the option #default = True #external = True #force = True #initial = True #keepdts = True #nodts = True #new = True #overwrite = True #recursive = True #test = True #debug = True
Here is an example of how to set up with SABnzbd
-
make sure that mkvdts2ac3.py is in your sabnzbd post-processing scripts folder
-
set the category Script to mkvdts2ac3.py and Folder/Path to where you want the files downloaded to
###Renamer If you are using something with a renamer / sorter such as Couch Potato set the Folder/Path to any folder you want the downloaded files to be put in while the conversion is being done. Then set the #sabdestdir in the mkvdts2ac3.cfg to the directory that Couch Potato looks for completed downloads.
If you do not already have a postprocessing script directory for nzbget:
-
Create the directory on your filesystem (usually 'nzbget MainDir'/ppscripts)
-
Set the path in the web frontend: Settings -> PATHS -> ScriptDir (usually ${MainDir}/ppscripts)
-
Click "Save all Changes" button at the bottom of the page
Now add mkvdts2ac3.py into nzbget
-
Copy mkvdts2ac3.py into your nzbget postprocessing scripts directory
-
Reload nzbget (Settings -> SYSTEM -> Reload)
-
Under settings go to POST-PROCESSING SCRIPTS and add mkvdts2ac3.py to DefScript
-
Click "Save all Changes" button at the bottom of the page
-
Reload nzbget again (Settings -> SYSTEM -> Reload)
###Defaults Now under Settings there should be a MKVDTS2AC3.PY menu item. You can change the defaults there if needed.
- Drew Thomson -
Git repository located at github.com/dcthomson/mkvdts2ac3.py
- Jake Wharton
- Chris Hoekstra
Copyright (C) 2012 Drew Thomson
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.