I have a sound recording in several files. I create one ongoing sound file using the com.googlecode.mp4parser:isoparser:1.0.2
library.
Below is my code:
String mediaKey = isAudio ? "soun" : "vide"; List<Movie> listMovies = new ArrayList<>(); for (String filename : sourceFiles) { listMovies.add(MovieCreator.build(filename)); } List<Track> listTracks = new LinkedList<>(); for (Movie movie : listMovies) { for (Track track : movie.getTracks()) { if (track.getHandler().equals(mediaKey)) { listTracks.add(track); } } } Movie outputMovie = new Movie(); if (!listTracks.isEmpty()) { outputMovie.addTrack(new AppendTrack(listTracks.toArray(new Track[listTracks.size()]))); } Container container = new DefaultMp4Builder().build(outputMovie); FileChannel fileChannel = new RandomAccessFile(String.format(targetFile), "rw").getChannel(); container.writeContainer(fileChannel); fileChannel.close();
The Android phone is working on the code. As a mobile environment for each application, there are restrictions on access to memory.
The problem with the above code is when I load Movie from a file and create a list of tracks for small files, which works fine. But as the file size increases, the operation begins to become unresponsive. It takes a lot of memory. How to make memory effective. Are they any way to perform this operation in small threads, as is the case with file copy operations in Java?
Update: To record sound in files I use android MediaRecorder
for these operations with output format as MPEG_4
and audio MPEG_4
as AAC
mRecorder.setAudioSource(MediaRecorder.AudioSource.MIC); mRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4); mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);
source share