Uses 1860K of libraries. Click here for Pure Java version (653L/5K/16K).
!7 lib 1006715 // jcodec 0.2.0 lib 1006717 // jcodec 0.2.0 javase 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)); }
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1006716 |
Snippet name: | Make silent .mp4 (SequenceEncoderDemo JCodec 0.2.0) - WORKS! |
Eternal ID of this version: | #1006716/5 |
Text MD5: | 66cb42fa265acd1054c3cd3478c45c4b |
Transpilation MD5: | 0c7c233377ceee1019839f99d967ac51 |
Author: | stefan |
Category: | javax video |
Type: | JavaX source code |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2017-02-02 22:50:17 |
Source code size: | 1503 bytes / 49 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 956 / 1330 |
Version history: | 4 change(s) |
Referenced in: | [show references] |