I am using jcodec library for converting a series of images to video, along with the transitions / animation like fade / flip and so on...
While this conversion process, I use the below function of SequenceEncoder class for each of the image.
public void encodeNativeFrame(Picture pic) throws IOException {
if (toEncode == null) {
toEncode = Picture.create(pic.getWidth(), pic.getHeight(), encoder.getSupportedColorSpaces()[0]);
}
// Perform conversion
transform.transform(pic, toEncode);
// Encode image into H.264 frame, the result is stored in '_out' buffer
_out.clear();
ByteBuffer result = encoder.encodeFrame(toEncode, _out);
// Based on the frame above form correct MP4 packet
spsList.clear();
ppsList.clear();
H264Utils.wipePS(result, spsList, ppsList);
H264Utils.encodeMOVPacket(result);
// Add packet to video track
outTrack.addFrame(new MP4Packet(result, frameNo * 1, (int)FPS, 1, frameNo, true, null, frameNo * 1, 0));
frameNo++;
result = null;
}
Each of the frame, takes a very long time in the process (about a minute)
Especially, the following statement takes very long time -
ByteBuffer result = encoder.encodeFrame(toEncode, _out);
Converting even the series of 4 images to video with transition / animation takes at least 7 minutes.
Need suggestions to quicken this.