Command-line DTS encoder
The dcaenc command line utility converts multichannel wav files to DTS. Any valid bitrate that is not too low is supported, but currently there are no options to select the endianness and dynamic range. This is a bug.
The restriction on low bitrates stems from the following. To make the stream compatible with certain buggy hardware decoders, it must not say "allocate no bits to this frequency band in this channel", even though the DTS specification permits it. But, if the minimum number of bits is assigned to each frequency band in each channel, it's still quite a considerable bitrate: more than 256000 bits per second for a 48 kHz stereo stream. To make it possible, the encoder has to implement another, more compatible, way to make bands above a certain frequency empty.
The restriction on low bitrates doesn't affect the use of dcaenc to create DVD audio tracks with 5.1 channels and 754.5 kbps bitrate. Among the common use cases, only "256 kbps stereo" is affected by this bug.
The dcaenc command line utility has the following usage:
dcaenc input.wav output.dts bitrate
The input wav file should have the same channel order as defined by SMPTE, i.e.: left, right, center, lfe, surround left, surround right.
Some destinations require a specific bitrate to be specified. To create a CD-compatible DTS file from a multichannel file (that needs to have the sample rate of 44100 Hz and either 16 or 32 bits per sample), run:
dcaenc input.wav output.dts 1411200
To create a DVD-compatible track from a multichannel wav file that has the 48 kHz sample rate, run:
dcaenc input.wav output.dts 1509000
or for a half-rate output:
dcaenc input.wav output.dts 754500
and then byte-swap the resulting output.dts file with some external tool, e.g.:
ffmpeg -ar 48000 -ac 2 -f s16le -i output.dts -f s16be output_be.dts
Mux the byte-swapped file with your MPEG2 video track using the "mplex" tool from the mjpeg-tools package.
Known bug: wav files with floating-point samples are misinterpreted as containing 32-bit integer samples. Don't feed such files to dcaenc.
© Alexander E. Patrakov