How to Mux DTS Audio into MKV with FFmpeg

This guide provides a straightforward, step-by-step tutorial on how to mux a raw DTS audio file into an MKV (Matroska) container using FFmpeg. You will learn the exact command-line syntax needed to combine your audio and video tracks or wrap a standalone DTS file into an MKV container without re-encoding, preserving the original quality of your audio stream.

Scenario 1: Muxing Video and Raw DTS Audio into MKV

To combine an existing video file (such as an MP4 or MKV without audio) and a raw DTS audio file into a single MKV container, use the following FFmpeg command:

ffmpeg -i input_video.mp4 -i input_audio.dts -c:v copy -c:a copy output.mkv

Command Breakdown: * -i input_video.mp4: Defines the input video source. * -i input_audio.dts: Defines the input raw DTS audio source. * -c:v copy: Instructs FFmpeg to copy the video stream directly without re-encoding it, saving time and preserving original video quality. * -c:a copy: Instructs FFmpeg to copy the DTS audio stream directly without transcoding it, maintaining the lossless or lossy integrity of the original DTS track. * output.mkv: The name of the final merged output file.


Scenario 2: Wrapping Standalone DTS Audio into an MKV/MKA Container

If you want to place a raw DTS audio file into a Matroska container without any video stream, you can output it to .mkv (or .mka for audio-only Matroska):

ffmpeg -i input_audio.dts -c:a copy output.mkv

Command Breakdown: * -i input_audio.dts: Defines the input raw DTS audio file. * -c:a copy: Copies the audio stream stream-for-stream without re-encoding. * output.mkv: The output container file.


Scenario 3: Replacing Existing Audio in a Video with DTS Audio

If your input video already has an audio track and you want to replace it entirely with your raw DTS file, you must map the specific streams:

ffmpeg -i input_video.mp4 -i input_audio.dts -map 0:v:0 -map 1:a:0 -c:v copy -c:a copy output.mkv

Command Breakdown: * -map 0:v:0: Selects the first video stream from the first input file (input_video.mp4). * -map 1:a:0: Selects the first audio stream from the second input file (input_audio.dts), ignoring any audio inside the first video file. * -c:v copy -c:a copy: Copies both video and audio streams without re-encoding.