public static Size getPicSize(SeqParameterSet sps) { int w = (sps.picWidthInMbsMinus1 + 1) << 4; int h = SeqParameterSet.getPicHeightInMbs(sps) << 4; if (sps.frameCroppingFlag) { w -= (sps.frameCropLeftOffset + sps.frameCropRightOffset) << sps.chromaFormatIdc.compWidth[1]; h -= (sps.frameCropTopOffset + sps.frameCropBottomOffset) << sps.chromaFormatIdc.compHeight[1]; } return new Size(w, h); }
@Override public DemuxerTrackMeta getMeta() { return new DemuxerTrackMeta(org.jcodec.common.TrackType.VIDEO, codec, 0, null, 0, state, org.jcodec.common.VideoCodecMeta.createSimpleVideoCodecMeta(new Size(demuxer.pictureWidth, demuxer.pictureHeight), ColorSpace.YUV420), null); }
@Override public VideoCodecMeta getCodecMeta(ByteBuffer data) { return org.jcodec.common.VideoCodecMeta.createSimpleVideoCodecMeta(new Size(width, height), ColorSpace.YUV420); } }
@Override public DemuxerTrackMeta getMeta() { return new DemuxerTrackMeta(TrackType.VIDEO, Codec.RAW, totalDuration, null, totalFrames, null, org.jcodec.common.VideoCodecMeta.createSimpleVideoCodecMeta(new Size(width, height), ColorSpace.YUV420), null); }
@Override public VideoCodecMeta getCodecMeta(ByteBuffer data) { try { BufferedImage rgb = ImageIO.read(new ByteArrayInputStream(NIOUtils.toArray(data))); return VideoCodecMeta.createSimpleVideoCodecMeta(new Size(rgb.getWidth(), rgb.getHeight()), ColorSpace.RGB); } catch (IOException e) { return null; } } }
@Override public VideoCodecMeta getCodecMeta(ByteBuffer frame) { NIOUtils.skip(frame, 6); int twoBytesWidth = (frame.get() & 0xFF) | (frame.get() & 0xFF) << 8; int twoBytesHeight = (frame.get() & 0xFF) | (frame.get() & 0xFF) << 8; int width = (twoBytesWidth & 0x3fff); int height = (twoBytesHeight & 0x3fff); return org.jcodec.common.VideoCodecMeta.createSimpleVideoCodecMeta(new Size(width, height), ColorSpace.YUV420); } }
@Override public VideoCodecMeta getCodecMeta(ByteBuffer data) { MPEG4DecodingContext ctx = MPEG4DecodingContext.readFromHeaders(data.duplicate()); if (ctx == null) return null; return VideoCodecMeta.createSimpleVideoCodecMeta(new Size(ctx.width, ctx.height), ColorSpace.YUV420J); }
@Override public VideoCodecMeta getCodecMeta(ByteBuffer data) { ByteBuffer codecPrivate = getSequenceHeader(data.duplicate()); SequenceHeader sh = SequenceHeader.read(codecPrivate.duplicate()); return org.jcodec.common.VideoCodecMeta.createSimpleVideoCodecMeta(new Size(sh.horizontal_size, sh.vertical_size), ColorSpace.YUV420); } }
/** * Calculates the component size based on the fullt size and color subsampling of the given component index. * @param size * @return Component size */ public Size compSize(Size size, int comp) { if (compWidth[comp] == 0 && compHeight[comp] == 0) return size; return new Size(size.getWidth() >> compWidth[comp], size.getHeight() >> compHeight[comp]); } }
@Override public VideoCodecMeta getCodecMeta(ByteBuffer data) { FrameHeader fh = readFrameHeader(data); return org.jcodec.common.VideoCodecMeta.createSimpleVideoCodecMeta(new Size(fh.width, fh.height), fh.chromaType == 2 ? ColorSpace.YUV422 : ColorSpace.YUV444); } }
public void encodeImage(File png) throws IOException { if (size == null) { BufferedImage read = ImageIO.read(png); size = new Size(read.getWidth(), read.getHeight()); // Add video track to muxer outTrack = muxer.addVideoTrack(Codec.PNG, VideoCodecMeta.createSimpleVideoCodecMeta(size, ColorSpace.RGB)); } // Add packet to video track outTrack.addFrame(MP4Packet.createMP4Packet(NIOUtils.fetchFromFile(png), frameNo, 25, 1, frameNo, FrameType.KEY, null, frameNo, frameNo, 0)); frameNo++; }
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); }
private Size applyMatrix(TrakBox videoTrack, Size size) { int[] matrix = videoTrack.getTrackHeader().getMatrix(); return new Size((int) ((double) size.getWidth() * matrix[0] / 65536), (int) ((double) size.getHeight() * matrix[4] / 65536)); }
private Size applyMatrix(TrakBox videoTrack, Size size) { int[] matrix = videoTrack.getTrackHeader().getMatrix(); return new Size((int) ((double) size.getWidth() * matrix[0] / 65536), (int) ((double) size.getHeight() * matrix[4] / 65536)); }
private Size applyMatrix(TrakBox videoTrack, Size size) { int[] matrix = videoTrack.getTrackHeader().getMatrix(); return new Size((int) ((double) size.getWidth() * matrix[0] / 65536), (int) ((double) size.getHeight() * matrix[4] / 65536)); }
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); }
@Override public void close() throws IOException { Size size = new Size(width, height); SampleEntry sampleEntry = MP4Muxer.videoSampleEntry("jpeg", size, "IHMCVideoCodecs"); track.addSampleEntry(sampleEntry); muxer.writeHeader(); channel.close(); encoder.delete(); }
@Override public void close() throws IOException { Size size = new Size(width, height); SampleEntry sampleEntry = MP4Muxer.videoSampleEntry("jpeg", size, "IHMCVideoCodecs"); track.addSampleEntry(sampleEntry); muxer.writeHeader(); channel.close(); encoder.delete(); }
@Override public DemuxerTrackMeta getMeta() { Size size = null; if (video) { GenericPictureEssenceDescriptor pd = (GenericPictureEssenceDescriptor) descriptor; size = new Size(pd.getStoredWidth(), pd.getStoredHeight()); } TrackType t = video ? TrackType.VIDEO : (audio ? TrackType.AUDIO : TrackType.OTHER); return new DemuxerTrackMeta(t, getCodec().getCodec(), demuxer.duration, null, demuxer.totalFrames, null, org.jcodec.common.VideoCodecMeta.createSimpleVideoCodecMeta(size, ColorSpace.YUV420), null); }