Maybe this answer is a bit late, but here is how I solved it:
The issue really is that mp4 containers do have a global "orientation" and that if you concatenate two videos with different orientations via mp4parser, the orientation of the second one is lost (first one is kept for the concatenated video).
Sadly, the author of the lib doesn't want to help with this problem, see:
https://github.com/sannies/mp4parser/issues/130
In my case, I switched to another library (Transcoder, see https://github.com/natario1/Transcoder), which is able to handle different orientations on concatenation:
val resultFilePath = getNewFilePath(context)
var transcoder = Transcoder.into(resultFilePath)
// for loop to iterate list of input video files
for (index in videoPathList.indices) {
transcoder = transcoder.addDataSource(videoList[index])
}
transcoder.setListener(object: TranscoderListener {
override fun onTranscodeProgress(progress: Double) {
...
}
override fun onTranscodeCompleted(successCode: Int) {
...
}
override fun onTranscodeCanceled() {
...
}
override fun onTranscodeFailed(exception: Throwable) {
...
}
}).transcode()
I don't have any orientation issues with the resulting videos.