gpac / mp4box.js

JavaScript version of GPAC's MP4Box tool
https://gpac.github.io/mp4box.js/
BSD 3-Clause "New" or "Revised" License
1.94k stars 328 forks source link

mp4box changes positions of existing streams upon importing subtitle track #228

Closed Android-X13 closed 3 years ago

Android-X13 commented 3 years ago

Presumably the same also applies when importing other kinds of tracks, but I've only tested it with subtitles.

I have an .mp4 container with 1 video stream and 3 audio streams (info is taken via MediaInfo):

Video, StreamOrder:0, ID:1
Audio (eng), StreamOrder:1, ID:2
Audio (ita), StreamOrder:2, ID:3
Audio (fre), StreamOrder:3, ID:4

This is what happens when I add a subtitle via ffmpeg:

ffmpeg -i in.mp4 -i subtitles.srt -map 0 -map 1 -c copy -c:s mov_text out.mp4

Video, StreamOrder:0, ID:1
Audio (eng), StreamOrder:1, ID:2
Audio (ita), StreamOrder:2, ID:3
Audio (fre), StreamOrder:3, ID:4
Text, StreamOrder:4, ID:5

And this is the end result when importing the same subtitle to the same .mp4 with mp4box:

mp4box -add subtitles.srt in.mp4

Video, StreamOrder:3, ID:1
Audio (fre), StreamOrder:0, ID:4
Audio (ita), StreamOrder:1, ID:3
Audio (eng), StreamOrder:2, ID:2
Text, StreamOrder:4, ID:5

So all existing streams have changed positions while retaining their IDs, the last stream became first, the penultimate stream became second, and so on. Is this behavior wanted for some reason?

Android-X13 commented 3 years ago

Sorry for this, moved to gpac