Right now I am displaying a live stream on a Surface using the vitamio librairy.
I wish to record it in order to watch it later as the feed comes from a drone.
Right now I am periodically saving a series of bitmaps using jcodec :
SequenceEncoder enc = new SequenceEncoder(new File("filename"));
// GOP size will be supported in 0.2
// enc.getEncoder().setKeyInterval(25);
for(...) {
BufferedImage image = ... // Obtain an image to encode
enc.encodeImage(image);
}
enc.finish();
My problems are :
Moreover I still need to find a way to mux it.. I looked into Mp4Parser without much succes.
Why not to use data input stream:
DataInputStream in = new DataInputStream (recording.getInputStream());
FileOutputStream videoFile = new FileOutputStream(targetFile);
int len;
byte buffer[] = new byte[8192];
while((len = in.read(buffer)) != -1) {
videoFile.write(buffer, 0, len);
}
videoFile.close();
Then, you can play the video from file.