mp4parser
mp4parser copied to clipboard
Unable to merge mp4 files
I am trying to merge these 2 mp4 files attached.
Only first video ends up in final video with size of that equalling addition of both files.
This is the code which I am using to merge
Any help is highly highly appreciated.
`fun combine(){
val inMovies = arrayOf<Movie>(MovieCreator.build(getVideoFile(1))
, MovieCreator.build(getVideoFile(2))/*
, MovieCreator.build(getVideoFile(3))
, MovieCreator.build(getVideoFile(4))
, MovieCreator.build(getVideoFile(5))
, MovieCreator.build(getVideoFile(6))*/)
val videoTracks = LinkedList<Track>()
val audioTracks = LinkedList<Track>()
for (m in inMovies) {
for (t in m.tracks) {
if (t.handler == "soun") {
audioTracks.add(t)
}
if (t.handler == "vide") {
videoTracks.add(t)
}
}
}
val result = Movie()
audioTracks.forEach {
result.addTrack(it)
}
videoTracks.forEach {
result.addTrack(it)
}
val out = DefaultMp4Builder().build(result) as BasicContainer
val fc = RandomAccessFile(
String.format(getOutputPath()), "rw").channel
out.writeContainer(fc)
fc.close()
}`
@sannies