-
Notifications
You must be signed in to change notification settings - Fork 141
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to pause the recording? #5
Comments
I will implement this soon. |
The only way I was able to do this is to create different video files each time the video is paused/resumed and then merge them together. There is a library called Mp4Parser that can merge the files. Implement the library into your project then you can merge the files like this: public static boolean mergeMediaFiles(boolean isAudio, String sourceFiles[], String targetFile) {
try {
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();
return true;
}
catch (IOException e) {
Log.e(LOG_TAG, "Error merging media files. exception: "+e.getMessage());
return false;
}
} You can also use FFmpeg to merge the files. I will be closing this issue because this can be implemented by the developer instead of adding it to the library. |
@HBiSoft i have tried to merge video using above code but not able to do because mp4parser lib gives error. |
@chiragthummar |
its give me error like below
|
and sometime it give this error as well.
|
will you please give me full example of merging video ? |
@chiragthummar I was thinking of creating a repo demonstrating this for future developers. |
thanks |
Hello
|
@chiragthummar You can pause the recording by calling: hbRecording.pauseScreenRecording(); You can resume the recording by calling: hbRecording.resumeScreenRecording(); This is only available for devices running 24> and it is important to check if the recording has started or was paused using Hope you find this helpful. |
Thank you so much for your quick answer. |
Like I want to pause the screen recording while it is recording and restart it again from there? How I can do it?
The text was updated successfully, but these errors were encountered: