14

I've manually created a stereo mixdown oft some 5.1 DTS tracks. Now I would like to add the new audio track to the original movie file, without dropping the old audio tracks.

My problem appears to be that I either miss to hand ffmpeg the correct mapping of the tracks (the file has a two audio tracks already and a number of subtiles, which appear to count too), so that I receive the "Number of stream maps must match the number of output streams" (quoted from memory), or I even geht the whole stream/map concept wrong.

Is there any good explanation for what I'm trying to do? I'd even read a whole text about the topic, the documentation in ffmpeg.org just isn't that helpful in this case.

To be more specific: I want to know if there is any way to make ffmpeg display the actual stream mapping of a file and how can I merge my stereo track into it?

Everything I've found so far deals with silent videos vor replacling an audio track, which is not what I want to do.

1 Answer 1

24
ffmpeg -i input.mkv -i audio.dts -map 0 -map 1 -c copy output.mkv

The default stream selection behavior only chooses one stream per stream type, so in this case you have to use -map to tell it which streams you want.

The input file index starts counting from 0, so using -map 0 will choose all streams from the first input (input.mkv), and -map 1 will choose all streams from the second input (audio.dts).

The result is that output.mkv will contain all of the streams from both inputs. Using -c copy will stream copy the streams, so they will simply be re-muxed without additional re-encoding.

1
  • 2
    Why didn't you also set the language of the audio track? I think it can be specified by just adding for example (for English): -metadata:s:a:1 language=eng -metadata:s:a:1 title="ENG" to the command just before output.mkv. s:a:1 sets the second audio track, it starts counting at 0 and you need to change that number as needed.
    – mYnDstrEAm
    Dec 10, 2022 at 14:50

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .