public void doWrite(ByteBuffer out) { out.put(JCodecUtil.asciiString(majorBrand)); out.putInt(minorVersion); for (String string : compBrands) { out.put(JCodecUtil.asciiString(string)); } } }
public static Format detectFormatBuffer(ByteBuffer b) { int maxScore = 0; Format selected = null; for (Map.Entry<Format, Class<?>> vd : demuxers.entrySet()) { int score = probe(b.duplicate(), vd.getValue()); if (score > maxScore) { selected = vd.getKey(); maxScore = score; } } return selected; }
private static _3<Integer, Integer, Codec> selectSuitableTrack(String input, Format format, TrackType targetType) throws IOException { _2<Integer, Demuxer> demuxerPid; if (format == Format.MPEG_TS) { demuxerPid = JCodecUtil.createM2TSDemuxer(new File(input), targetType); } else { demuxerPid = _2(0, JCodecUtil.createDemuxer(format, new File(input))); } if (demuxerPid == null || demuxerPid.v1 == null) return null; int trackNo = 0; List<? extends DemuxerTrack> tracks = targetType == TrackType.VIDEO ? demuxerPid.v1.getVideoTracks() : demuxerPid.v1.getAudioTracks(); for (DemuxerTrack demuxerTrack : tracks) { Codec codec = detectVideoDecoder(demuxerTrack); if (supportedDecoders.contains(codec)) { return _3(demuxerPid.v0, trackNo, codec); } trackNo++; } return null; }
public static Format detectFormatChannel(ReadableByteChannel f) throws IOException { return detectFormatBuffer(NIOUtils.fetchFromChannel(f, 200 * 1024)); }
public static MetadataEditor createFrom(File f) throws IOException { Format format = JCodecUtil.detectFormat(f); if (format != Format.MOV) { throw new IllegalArgumentException("Unsupported format: " + format); } Movie movie = MP4Util.parseFullMovie(f); MetaBox keyedMeta = NodeBox.findFirst(movie.getMoov(), MetaBox.class, MetaBox.fourcc()); MetaBox itunesMeta = NodeBox.findFirstPath(movie.getMoov(), MetaBox.class, new String[] { "udta", MetaBox.fourcc() }); return new MetadataEditor(f, keyedMeta == null ? new HashMap<String, MetaValue>() : keyedMeta.getKeyedMeta(), itunesMeta == null ? new HashMap<Integer, MetaValue>() : itunesMeta.getItunesMeta()); }
private static Codec detectVideoDecoder(DemuxerTrack track) throws IOException { DemuxerTrackMeta meta = track.getMeta(); if (meta != null) { Codec codec = meta.getCodec(); if (codec != null) return codec; } Packet packet = track.nextFrame(); if (packet == null) return null; return JCodecUtil.detectDecoder(packet.getData()); }
case FOURCC_VP8X: default: Logger.warn("Skipping unsupported chunk: " + JCodecUtil.dwToFourCC(fourCC) + "."); byte[] b1 = new byte[size]; raf.readFully(b1);
public static Format detectFormat(File f) throws IOException { return detectFormatBuffer(NIOUtils.fetchFromFileL(f, 200 * 1024)); }
inputFormat = getFormatFromExtension(input); if (inputFormat != Format.IMG) { Format detectFormat = JCodecUtil.detectFormat(new File(input)); if (detectFormat != null) { inputFormat = detectFormat;
protected void doWrite(ByteBuffer out) { out.put(JCodecUtil.asciiString(fmt)); } }
public static FrameGrab createFrameGrab(SeekableByteChannel _in) throws IOException, JCodecException { ByteBuffer header = ByteBuffer.allocate(65536); _in.read(header); header.flip(); Format detectFormat = JCodecUtil.detectFormatBuffer(header); if (detectFormat == null) { throw new UnsupportedFormatException("Could not detect the format of the input video."); } SeekableDemuxerTrack videoTrack_; switch (detectFormat) { case MOV: MP4Demuxer d1 = MP4Demuxer.createMP4Demuxer(_in); videoTrack_ = (SeekableDemuxerTrack)d1.getVideoTrack(); break; case MPEG_PS: throw new UnsupportedFormatException("MPEG PS is temporarily unsupported."); case MPEG_TS: throw new UnsupportedFormatException("MPEG TS is temporarily unsupported."); default: throw new UnsupportedFormatException("Container format is not supported by JCodec"); } FrameGrab fg = new FrameGrab(videoTrack_, detectDecoder(videoTrack_)); fg.decodeLeadingFrames(); return fg; }
public static Codec detectDecoder(ByteBuffer b) { int maxScore = 0; Codec selected = null; for (Map.Entry<Codec, Class<?>> vd : decoders.entrySet()) { int score = probe(b.duplicate(), vd.getValue()); if (score > maxScore) { selected = vd.getKey(); maxScore = score; } } return selected; }
protected void doWrite(ByteBuffer out) { out.put(JCodecUtil.asciiString(fmt)); } }
public void doWrite(ByteBuffer out) { out.put(JCodecUtil.asciiString(majorBrand)); out.putInt(minorVersion); for (String string : compBrands) { out.put(JCodecUtil.asciiString(string)); } } }
public void doWrite(ByteBuffer out) { super.doWrite(out); out.put(JCodecUtil.asciiString(componentType)); out.put(JCodecUtil.asciiString(componentSubType)); out.put(JCodecUtil.asciiString(componentManufacturer)); out.putInt(componentFlags); out.putInt(componentFlagsMask); if (componentName != null) { out.put(JCodecUtil.asciiString(componentName)); } }
protected void doWrite(ByteBuffer out) { out.put(JCodecUtil.asciiString(name)); out.putInt(0); }
public static void writePascalString(ByteBuffer buffer, String name) { buffer.put((byte) name.length()); buffer.put(JCodecUtil.asciiString(name)); }
protected void doWrite(ByteBuffer out) { out.put(JCodecUtil.asciiString(name)); out.putInt(0); }
public void doWrite(ByteBuffer out) { super.doWrite(out); out.put(JCodecUtil.asciiString(componentType)); out.put(JCodecUtil.asciiString(componentSubType)); out.put(JCodecUtil.asciiString(componentManufacturer)); out.putInt(componentFlags); out.putInt(componentFlagsMask); if (componentName != null) { out.put(JCodecUtil.asciiString(componentName)); } }
@Override public void doWrite(ByteBuffer out) { out.put(JCodecUtil.asciiString(type)); out.putShort(primariesIndex); out.putShort(transferFunctionIndex); out.putShort(matrixIndex); }