我需要在录制时暂停音频。所以我使用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();
}
}
有人面临类似情况吗?