Warning: session_start(): open(/var/lib/php/sessions/sess_gbvfcpn1a1u04ggkgcvt9ajlmb, O_RDWR) failed: No space left on device (28) in /var/www/tb-usercake/models/config.php on line 51
Warning: session_start(): Failed to read session data: files (path: /var/lib/php/sessions) in /var/www/tb-usercake/models/config.php on line 51
!7
import org.jcodec.api.awt.AWTSequenceEncoder8Bit;
/**
* This class is part of JCodec ( www.jcodec.org ) This software is distributed
* under FreeBSD License
*
* A demo of SequenceEncoder that generates a video with a bouncing ball
*
* @author Stan Vitvitskyy
*
*/
p {
final int speed = 4;
final int ballSize = 40;
File outFile = prepareProgramFile("test.mp4");
int framesToEncode = 100;
AWTSequenceEncoder8Bit enc = AWTSequenceEncoder8Bit.create25Fps(outFile);
enc.getEncoder().setKeyInterval(25);
long totalNano = 0;
BufferedImage image = new BufferedImage(640, 480, BufferedImage.TYPE_3BYTE_BGR);
for (int i = 0, x = 0, y = 0, incX = speed, incY = speed; i < framesToEncode; i++, x += incX, y += incY) {
Graphics g = image.getGraphics();
g.setColor(Color.BLACK);
g.fillRect(0, 0, image.getWidth(), image.getHeight());
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);
long start = System.nanoTime();
enc.encodeImage(image);
totalNano += System.nanoTime() - start;
}
enc.finish();
System.out.println("FPS: " + ((1000000000L * framesToEncode) / totalNano));
}