How to map streams to specific output streamIDs I'm trying to map specific streams to specific output indexes. The command I'm using is more complex but it can be reduced to this simple example

ffmpeg -i input.mkv -y -map 0:0 -c:5 copy -f mp4 out.mp4

I expected this to copy stream 0 from input.mkv into stream 5 of out.mp4. The issue is that it copies it into stream 0 (I guess it's using a counter?). Why is that and how can I force it to assign it a different index number?

Stream #0:0 -&gt; #0:0 (h264 (native) -&gt; h264 (libx264))
It's using a counter! To get it to be stream #5, map 5 streams before it :)

That said, mp4box will allow you to set a custom track ID.

mp4box -set-track-id 1:5 file.mp4


This changes existing track with ID 1 to 5. Use mp4box -info file.mp4 to get existing IDs.

However, this will still show up as stream 0 in ffmpeg. But mediainfo and mp4box will show it as having ID 5.