ffmpeg: How to copy all but also add in a convert of an existing audio stream?

I have several videos that have video, AAC audio, some with an additional alternate content audio stream, and subtitles.

What I want to do is to copy EVERYTHING as-is while inserting a converted a:0 from AAC to AC3 into the a:0 position (so all existing audio streams are "bumped" down by one spot) and making the new a:0 the default audio stream. End result is the same video file but with one new additional audio stream. (AAC stream is kept, not replaced.)

I've tried this, but I think I'm doing something wrong because it seems to take a long time (compared to converting the audio and then merging it in separately).

ffmpeg -i "AAC.mkv" -map 0:v -c:v copy -c:a:0 ac3 -b:a:0 640k -map 0:a:0 -map 0:a -map 0:s? -c:s copy "AC3.mkv"

It does appear to work, but as I said, seems to take longer than it really should. So, am I just being impatient, or am I doing something wrong that is slowing it down?


Solution 1:

I started to use ffmpeg just a few days ago, so I might be wrong but I think this method is slower because it reencodes both the original and the new audio since this code doesn't include "-c:a copy":

ffmpeg -i "AAC.mkv" -map 0:v -c:v copy -c:a:0 ac3 -b:a:0 640k -map 0:a:0 -map 0:a -map 0:s? -c:s copy "AC3.mkv"

While the other code contains "-c copy" which means that this one copies everything (including the original audio) and only reencodes the new audio via conversion and that's why it takes less time:

ffmpeg -i "AAC.mkv" -c copy -map 0:v -c:a:0 ac3 -b:a:0 640k -map 0:a:0 -map 0:a -map 0:s? -to 5:00 "AC3.mkv"