MP4 parser takes a long time to merge video files

642 views Asked by At

I need to pause audios while recording. So I'm using mP4 parser to merge the audios of .3GPP format. If the audios are less than 1 second, it gets merged. But if the audio size exceeds more than 1 second, it doesn't get merged. Here is my code:

private void mergeFiles(File filePath, ArrayList audioFiles) throws IOException {

    int count = audioFiles.size();
    Movie[] inMovies = new Movie[count];
    for (int i = 0; i < count; i++) {


        Movie movie = MovieCreator.build(new FileDataSourceImpl(file));
        inMovies[i] = movie;
    }
    List<Track> movieTracks = new LinkedList<Track>();
    for (Movie m : inMovies) {
        for (Track t : m.getTracks()) {
            movieTracks.add(t);
        }
    }
    Movie finalMovie = new Movie();
    if (movieTracks.size() > 0)
        finalMovie.addTrack(new AppendTrack(movieTracks.toArray(new Track[movieTracks.size()])));

    Container container = new DefaultMp4Builder().build(finalMovie);
    File anotherFile = new File(getFinalFileName());
    final FileOutputStream fos = new FileOutputStream(anotherFile);
    final WritableByteChannel bb = Channels.newChannel(fos);
    container.writeContainer(bb);
    fos.close();
    for (int i = 0; i < count; i++) {
        File arrayFile = new File(mAudioFiles.get(i));
        if (arrayFile.exists())
            arrayFile.delete();
    }

}

Is anyone facing a similar situation..?

0

There are 0 answers