0

I am capturing video1 by using the front camera and video2 by using the back camera. After I merge both videos by using mp4parser.

Video1 is playing properly and the video2 playing upside down. If I recorded both videos with front or back cam it is working perfectly. The problem occurs only recording through the front and back cam.

If anyone knows the solution. Please help me.

Thanks in advance.

kiran
  • 3,244
  • 7
  • 34
  • 57

1 Answers1

1

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.