After a week of research I have written myself very simple code using ffmprg binaries:
if(frameCount<628){
saveFrame("temp/anim_#####.png");
}else if(frameCount == 628){
println("Saving file!");
processBuilder = new ProcessBuilder("G:/.../ffmpg/bin/ffmpeg.exe", "-r", "60", "-i",
"C:/.../temp/anim_%05d.png", "-c:v", "libx264",
"-r", "30", "-pix_fmt", "yuv420p", "C:/.../test.mp4");
try {
process = processBuilder.start();
} catch (Exception e) {
e.printStackTrace();
}
}
Of course you need to adjust paths to files and ffmpeg binaries (https://www.ffmpeg.org/download.html). It sjould be Processing version independent, as it uses only saveFrame and calls external binaries to generate video. Enjoy ;)