I\'m trying to use JCodec to turn a series of images into a video inside of a Java SE desktop application. The few methods I\'ve tried all resulted in a video that Windows
With 0.2.0 there is now https://github.com/jcodec/jcodec/blob/master/javase/src/main/java/org/jcodec/api/awt/AWTSequenceEncoder8Bit.java
This example creates a MP4 with a fixed background and overlaid animation. No sound.
AWTSequenceEncoder8Bit enc = AWTSequenceEncoder8Bit.create2997Fps(outputMovieFile);
int framesToEncode = (int) (29.97 * durationInSeconds);
java.awt.image.BufferedImage image = ...(some background image)
for (int frameIndx = 0, x = 0, y = 0, incX = speed, incY = speed; frameIndx < framesToEncode; frameIndx++, x += incX, y += incY) {
Graphics g = image.getGraphics();
g.setColor(Color.YELLOW);
if (x >= image.getWidth() - ballSize) incX = -speed;
if (y >= image.getHeight() - ballSize) incY = -speed;
if (x <= 0) incX = speed;
if (y <= 0) incY = speed;
g.fillOval(x, y, ballSize, ballSize);
enc.encodeImage(image);
}
enc.finish();