public PixelAspectExt(Rational par) { this(); this.hSpacing = par.getNum(); this.vSpacing = par.getDen(); }
public PixelAspectExt(Rational par) { this(); this.hSpacing = par.getNum(); this.vSpacing = par.getDen(); }
private void outChunkIfNeeded(int entryNo) throws IOException { Assert.assertTrue(tgtChunkDurationUnit == Unit.FRAME || tgtChunkDurationUnit == Unit.SEC); if (tgtChunkDurationUnit == Unit.FRAME && curChunk.size() * tgtChunkDuration.getDen() == tgtChunkDuration.getNum()) { outChunk(entryNo); } else if (tgtChunkDurationUnit == Unit.SEC && chunkDuration > 0 && chunkDuration * tgtChunkDuration.getDen() >= tgtChunkDuration.getNum() * timescale) { outChunk(entryNo); } }
private void outChunkIfNeeded(int entryNo) throws IOException { Assert.assertTrue(tgtChunkDurationUnit == Unit.FRAME || tgtChunkDurationUnit == Unit.SEC); if (tgtChunkDurationUnit == Unit.FRAME && curChunk.size() * tgtChunkDuration.getDen() == tgtChunkDuration.getNum()) { outChunk(entryNo); } else if (tgtChunkDurationUnit == Unit.SEC && chunkDuration > 0 && chunkDuration * tgtChunkDuration.getDen() >= tgtChunkDuration.getNum() * timescale) { outChunk(entryNo); } }
private void outChunkIfNeeded(int entryNo) throws IOException { checkState(tgtChunkDurationUnit == Unit.FRAME || tgtChunkDurationUnit == Unit.SEC); if (tgtChunkDurationUnit == Unit.FRAME && curChunk.size() * tgtChunkDuration.getDen() == tgtChunkDuration.getNum()) { outChunk(entryNo); } else if (tgtChunkDurationUnit == Unit.SEC && chunkDuration > 0 && chunkDuration * tgtChunkDuration.getDen() >= tgtChunkDuration.getNum() * _timescale) { outChunk(entryNo); } }
public static Rational reduceRational(Rational r) { return reduce(r.getNum(), r.getDen()); }
public static Rational reduce(Rational r) { return reduce(r.getNum(), r.getDen()); }
public static Rational reduce(Rational r) { return reduce(r.getNum(), r.getDen()); }
private void outChunkIfNeeded() throws IOException { Assert.assertTrue(tgtChunkDurationUnit == Unit.FRAME || tgtChunkDurationUnit == Unit.SEC); if (tgtChunkDurationUnit == Unit.FRAME && framesInCurChunk * tgtChunkDuration.getDen() == tgtChunkDuration.getNum()) { outChunk(); } else if (tgtChunkDurationUnit == Unit.SEC && chunkDuration > 0 && chunkDuration * tgtChunkDuration.getDen() >= tgtChunkDuration.getNum() * _timescale) { outChunk(); } }
private void outChunkIfNeeded() throws IOException { Assert.assertTrue(tgtChunkDurationUnit == Unit.FRAME || tgtChunkDurationUnit == Unit.SEC); if (tgtChunkDurationUnit == Unit.FRAME && framesInCurChunk * tgtChunkDuration.getDen() == tgtChunkDuration.getNum()) { outChunk(); } else if (tgtChunkDurationUnit == Unit.SEC && chunkDuration > 0 && chunkDuration * tgtChunkDuration.getDen() >= tgtChunkDuration.getNum() * timescale) { outChunk(); } }
private void outChunkIfNeeded() throws IOException { Assert.assertTrue(tgtChunkDurationUnit == Unit.FRAME || tgtChunkDurationUnit == Unit.SEC); if (tgtChunkDurationUnit == Unit.FRAME && framesInCurChunk * tgtChunkDuration.getDen() == tgtChunkDuration.getNum()) { outChunk(); } else if (tgtChunkDurationUnit == Unit.SEC && chunkDuration > 0 && chunkDuration * tgtChunkDuration.getDen() >= tgtChunkDuration.getNum() * timescale) { outChunk(); } }
public Size getDisplayDimensions() { int width = 0, height = 0; if (sampleEntries != null && !sampleEntries.isEmpty() && sampleEntries.get(0) instanceof VideoSampleEntry) { VideoSampleEntry vse = (VideoSampleEntry) sampleEntries.get(0); PixelAspectExt paspBox = NodeBox.findFirst(vse, PixelAspectExt.class, PixelAspectExt.fourcc()); Rational pasp = paspBox != null ? paspBox.getRational() : new Rational(1, 1); width = pasp.getNum() * vse.getWidth() / pasp.getDen(); height = vse.getHeight(); } return new Size(width, height); }
@Override public Packet nextFrame() throws IOException { if (invalidFormat != null) throw new RuntimeException("Invalid input: " + invalidFormat); ByteBuffer buf = NIOUtils.fetchFromChannel(is, 2048); String frame = readLine(buf); if (frame == null || !frame.startsWith("FRAME")) return null; is.setPosition(is.position() - buf.remaining()); ByteBuffer pix = NIOUtils.fetchFromChannel(is, bufSize); Packet packet = new Packet(pix, frameNum * fps.getDen(), fps.getNum(), fps.getDen(), frameNum, FrameType.KEY, null, frameNum); ++frameNum; return packet; }
public Size getDisplayDimensions() { int width = 0, height = 0; if (sampleEntries.get(0) instanceof VideoSampleEntry) { VideoSampleEntry vse = (VideoSampleEntry) sampleEntries.get(0); PixelAspectExt paspBox = Box.findFirst(vse, PixelAspectExt.class, PixelAspectExt.fourcc()); Rational pasp = paspBox != null ? paspBox.getRational() : new Rational(1, 1); width = (int) (pasp.getNum() * vse.getWidth()) / pasp.getDen(); height = (int) vse.getHeight(); } return new Size(width, height); }
public Size getDisplayDimensions() { int width = 0, height = 0; if (sampleEntries.get(0) instanceof VideoSampleEntry) { VideoSampleEntry vse = (VideoSampleEntry) sampleEntries.get(0); PixelAspectExt paspBox = Box.findFirst(vse, PixelAspectExt.class, PixelAspectExt.fourcc()); Rational pasp = paspBox != null ? paspBox.getRational() : new Rational(1, 1); width = (int) (pasp.getNum() * vse.getWidth()) / pasp.getDen(); height = (int) vse.getHeight(); } return new Size(width, height); }
public static PixelAspectExt createPixelAspectExt(Rational par) { PixelAspectExt pasp = new PixelAspectExt(new Header(fourcc())); pasp.hSpacing = par.getNum(); pasp.vSpacing = par.getDen(); return pasp; }
public Size getDisplaySize() { TrakBox videoTrack = getVideoTrack(); if (videoTrack == null) return null; ClearApertureBox clef = NodeBox.findFirst(videoTrack, ClearApertureBox.class, "tapt", "clef"); if (clef != null) { return applyMatrix(videoTrack, new Size((int) clef.getWidth(), (int) clef.getHeight())); } Box box = NodeBox.findFirst(videoTrack, SampleDescriptionBox.class, "mdia", "minf", "stbl", "stsd").getBoxes() .get(0); if (box == null || !(box instanceof VideoSampleEntry)) return null; VideoSampleEntry vs = (VideoSampleEntry) box; Rational par = videoTrack.getPAR(); return applyMatrix(videoTrack, new Size((int) ((vs.getWidth() * par.getNum()) / par.getDen()), (int) vs.getHeight())); }
public Size getDisplaySize() { TrakBox videoTrack = getVideoTrack(); if (videoTrack == null) return null; ClearApertureBox clef = NodeBox.findFirst(videoTrack, ClearApertureBox.class, "tapt", "clef"); if (clef != null) { return applyMatrix(videoTrack, new Size((int) clef.getWidth(), (int) clef.getHeight())); } Box box = NodeBox.findFirst(videoTrack, SampleDescriptionBox.class, "mdia", "minf", "stbl", "stsd").getBoxes() .get(0); if (box == null || !(box instanceof VideoSampleEntry)) return null; VideoSampleEntry vs = (VideoSampleEntry) box; Rational par = videoTrack.getPAR(); return applyMatrix(videoTrack, new Size((int) ((vs.getWidth() * par.getNum()) / par.getDen()), (int) vs.getHeight())); }
@Override public void apply(MovieBox mov) { TrakBox vt = mov.getVideoTrack(); vt.setPAR(newPAR); Box box = NodeBox.findFirstPath(vt, SampleDescriptionBox.class, Box.path("mdia.minf.stbl.stsd")).getBoxes() .get(0); if (box != null && (box instanceof VideoSampleEntry)) { VideoSampleEntry vs = (VideoSampleEntry) box; int codedWidth = (int) vs.getWidth(); int codedHeight = (int) vs.getHeight(); int displayWidth = codedWidth * newPAR.getNum() / newPAR.getDen(); vt.getTrackHeader().setWidth(displayWidth); if (BoxUtil.containsBox(vt, "tapt")) { vt.setAperture(new Size(codedWidth, codedHeight), new Size(displayWidth, codedHeight)); } } }
public Size getDisplaySize() { TrakBox videoTrack = getVideoTrack(); if (videoTrack == null) return null; ClearApertureBox clef = NodeBox.findFirstPath(videoTrack, ClearApertureBox.class, Box.path("tapt.clef")); if (clef != null) { return applyMatrix(videoTrack, new Size((int) clef.getWidth(), (int) clef.getHeight())); } Box box = NodeBox.findFirstPath(videoTrack, SampleDescriptionBox.class, Box.path("mdia.minf.stbl.stsd")).getBoxes() .get(0); if (box == null || !(box instanceof VideoSampleEntry)) return null; VideoSampleEntry vs = (VideoSampleEntry) box; Rational par = videoTrack.getPAR(); return applyMatrix(videoTrack, new Size((int) ((vs.getWidth() * par.getNum()) / par.getDen()), (int) vs.getHeight())); }