Skip to content

Instantly share code, notes, and snippets.

@tobadia
Last active August 7, 2017 12:45
Show Gist options
  • Save tobadia/4ac870057459b398f80df88e2bed5aa1 to your computer and use it in GitHub Desktop.
Save tobadia/4ac870057459b398f80df88e2bed5aa1 to your computer and use it in GitHub Desktop.
Convert DTS audio to AC3 in a MKV file
#######################################################################
## Correct use of DTS2AC3 script forked from GitHub ##
## ##
## Source: https://github.com/JakeWharton/mkvdts2ac3 ##
## Last edit: 2017-05-30 ##
#######################################################################
## I forked the repo and cloned it into my NAS as of today
## Requirement: ffmpeg, mkvtoolnix, rsync
## Demux, re-encode audio, remux
mkvdts2ac3.sh --initial --no-dts --new --wd "." input.mkv
# --initial: puts the new AC3 track as first audio track
# --no-dts : drops the DTS audio track
# --new : do not replace original file
# --debug : shows commands one by one, but have to press ENTER at each command
# --wd "." : works in current directory instead of /tmp by default
# It will take a long time, because the DTS -> AC3 process runs at ~1x
# --initial sets the newt track before the video track, which is not optimal.
# Yet I fear not using --initial would result in the converted track being the last one (not optimal either)
# Looking into:
# https://superuser.com/questions/539640/how-do-i-swap-the-first-and-second-audio-streams-in-an-mkv-in-a-linux-based-syst
# This allows swapping the first two tracks, i.e. the new audio track (due to --initial) and the video track (which was first before),
# while preserving all other subtitles tracks.
# PS: not sure how it would behave with more audio tracks, but it works with at least 2!
ffmpeg -i input.mkv -map 0:v:0 -map 0:a:1 -map 0:a:0 -map 0:s -c copy output.mkv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment