I am trying to find the best solution to pause and resume video recording. As far as I know, the Media Recorder class does not allow you to pause recording while recording for Android 4.3 or lower.
I found the mp4parser library, which can merge several video files into one video file. I use the following jars:
aspectjrt-1.7.3.jar
isoparser-1.0.6.jar
The problem is that there is too much time to combine them. For example, 2-3 video files, which are about 5 minutes in total, take at least 2 minutes to combine them!
The default camera application that comes with my Galaxy S3 and Note 2, which have a pause option when recording video. Their paused videos take less than 1 second to complete the merge.
Can someone please tell me what I'm doing wrong here?
I use the following code to combine video files:
for (ArrayList<String> PathList : VideoList) { VideoPathList = PathList; } for (String mMovie : VideoPathList) { Movie movie = MovieCreator.build(mMovie); MovieList.add(movie); } List<Track> videoTracks = new LinkedList<Track>(); List<Track> audioTracks = new LinkedList<Track>(); for (Movie mMovie : MovieList) { for (Track t : mMovie.getTracks()) { if (t.getHandler().equals("soun")) { audioTracks.add(t); } if (t.getHandler().equals("vide")) { videoTracks.add(t); } } } Movie result = new Movie(); if(audioTracks.size() > 0) { result.addTrack(new AppendTrack(audioTracks.toArray(new Track[audioTracks.size()]))); } if(videoTracks.size() > 0) { result.addTrack(new AppendTrack(videoTracks.toArray(new Track[videoTracks.size()]))); } BasicContainer basicContainer = (BasicContainer) new DefaultMp4Builder().build(result); final String FileLocation = (UserSavedDirectoryPATH + "/"); final File DirectoryExistCheck = new File(FileLocation); if(!DirectoryExistCheck.exists()) { DirectoryExistCheck.mkdir(); } NewVideo = FileLocation + "Video " + ".mp4"; FileChannel fileChannel = new FileOutputStream(new File(String.format(NewVideo))).getChannel(); basicContainer.writeContainer(fileChannel); fileChannel.close(); } catch(Exception error) { } GalleryAddNewVideo(NewVideo); Delete_VideoPaths(VideoPathList);
I really appreciate your help,
Thank you very much
source share