Libraryless. Compilation Failed (78L/2K).
1 | !1000278 // jcodec library |
2 | |
3 | import static org.jcodec.common.NIOUtils.writableFileChannel; |
4 | import java.io.File; |
5 | import java.nio.ByteBuffer; |
6 | import java.util.Arrays; |
7 | import org.jcodec.codecs.raw.V210Encoder; |
8 | import org.jcodec.common.model.ColorSpace; |
9 | import org.jcodec.common.model.Picture; |
10 | import org.jcodec.common.model.Size; |
11 | import org.jcodec.containers.mp4.muxer.FramesMP4MuxerTrack; |
12 | import org.jcodec.containers.mp4.muxer.MP4Muxer; |
13 | import org.jcodec.containers.mp4.MP4Packet; |
14 | |
15 | /** |
16 | * This class is part of JCodec ( www.jcodec.org ) This software is distributed |
17 | * under FreeBSD License |
18 | * |
19 | * This code generates two dark gradients 8bit and 10 bit quantization and saves |
20 | * it into v210 mov |
21 | * |
22 | * @author Jay Codec |
23 | * |
24 | */ |
25 | public class main { |
26 | public static void main(String[] args) throws Exception { |
27 | if (args.length == 0) |
28 | args = new String[] {"out.mov", "200"}; |
29 | |
30 | if (args.length < 2) { |
31 | System.out.println("<out mov> <n frames>"); |
32 | return; |
33 | } |
34 | |
35 | System.out.println("Writing movie: " + args[0]); |
36 | int width = 640; |
37 | int height = 480; |
38 | Picture pic = Picture.create(width, height, ColorSpace.YUV422_10); |
39 | Arrays.fill(pic.getPlaneData(1), 512); |
40 | Arrays.fill(pic.getPlaneData(2), 512); |
41 | drawGrad(pic.getPlaneData(0), new Size(pic.getWidth(), pic.getHeight())); |
42 | V210Encoder encoder = new V210Encoder(); |
43 | MP4Muxer muxer = new MP4Muxer(writableFileChannel(new File(args[0]))); |
44 | ByteBuffer out = ByteBuffer.allocate(width * height * 10); |
45 | ByteBuffer frame = encoder.encodeFrame(out, pic); |
46 | FramesMP4MuxerTrack videoTrack = muxer.addVideoTrack("v210", new Size(width, height), "jcodec", 24000); |
47 | for (int i = 0; i < Integer.parseInt(args[1]); i++) { |
48 | videoTrack.addFrame(new MP4Packet(frame, i * 1001, 24000, 1001, i, true, null, i * 1001, 0)); |
49 | } |
50 | muxer.writeHeader(); |
51 | System.out.println("Done writing movie."); |
52 | } |
53 | |
54 | private static void drawGrad(int[] y, Size ySize) { |
55 | int blockX = ySize.getWidth() / 10; |
56 | int blockY = ySize.getHeight() / 7; |
57 | fillGrad(y, ySize.getWidth(), blockX, blockY, 9 * blockX, 3 * blockY, 0.2, 0.1, 8); |
58 | fillGrad(y, ySize.getWidth(), blockX, 4 * blockY, 9 * blockX, 6 * blockY, 0.2, 0.1, 10); |
59 | } |
60 | |
61 | private static void fillGrad(int[] y, int stride, int left, int top, int right, int bottom, double from, double to, |
62 | int quant) { |
63 | int step = stride + left - right; |
64 | int off = top * stride + left; |
65 | for (int j = top; j < bottom; j++) { |
66 | for (int i = left; i < right; i++) { |
67 | y[off++] = colr(((double) i - left) / (right - left), ((double) j - top) / (bottom - top), from, to, |
68 | quant); |
69 | } |
70 | off += step; |
71 | } |
72 | } |
73 | |
74 | private static int colr(double i, double j, double from, double to, int quant) { |
75 | int val = ((int) ((1 << quant) * (from + (to - from) * i))) << (10 - quant); |
76 | return val; |
77 | } |
78 | } |
download show line numbers debug dex old transpilations
Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
ID | Author/Program | Comment | Date |
---|---|---|---|
330 | #1000604 (pitcher) | 2015-08-20 15:28:24 | |
329 | #1000610 (pitcher) | 2015-08-18 00:07:07 |
Snippet ID: | #620 |
Snippet name: | JCodec test (generate out.mov) |
Eternal ID of this version: | #620/1 |
Text MD5: | d41605a566debf3a1a3be97fd3285593 |
Transpilation MD5: | a0d0c78f0f9d97a6032a6c20937e69df |
Author: | stefan |
Category: | javax video |
Type: | JavaX source code |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2015-05-19 21:09:44 |
Source code size: | 2958 bytes / 78 lines |
Pitched / IR pitched: | No / Yes |
Views / Downloads: | 1554 / 1326 |
Referenced in: | [show references] |