MP4解析器需要很长时间才能合并视频文件

时间:2014-11-19 07:32:31

标签: audio video mp4parser

我需要在录制时暂停音频。所以我使用mP4解析器合并.3GPP格式的音频。如果音频小于1秒,则会合并。但如果音频大小超过1秒,它就不会合并。这是我的代码:

private void mergeFiles(File filePath,ArrayList audioFiles)抛出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();
    }

}

有人面临类似情况吗?

0 个答案:

没有答案