private VisualSampleEntry mergeVisualSampleEntry(VisualSampleEntry vse1, VisualSampleEntry vse2) { VisualSampleEntry vse = new VisualSampleEntry(); if (vse1.getHorizresolution() == vse2.getHorizresolution()) { vse.setHorizresolution(vse1.getHorizresolution()); } else { LOG.error("Horizontal Resolution differs"); return null; vse.setCompressorname(vse1.getCompressorname()); // ignore if they differ if (vse1.getDepth() == vse2.getDepth()) { vse.setDepth(vse1.getDepth()); } else { LOG.error("Depth differs"); if (vse1.getFrameCount() == vse2.getFrameCount()) { vse.setFrameCount(vse1.getFrameCount()); } else { LOG.error("frame count differs"); if (vse1.getHeight() == vse2.getHeight()) { vse.setHeight(vse1.getHeight()); } else { LOG.error("height differs"); return null; if (vse1.getWidth() == vse2.getWidth()) { vse.setWidth(vse1.getWidth()); } else { LOG.error("width differs");
public static void main(String[] args) throws IOException { IsoFile i = new IsoFile("C:\\Users\\sannies\\Downloads\\CF2.0_1920x1080_8000.mp4"); VisualSampleEntry sampleEntry = Path.getPath(i, "/moov[0]/trak[0]/mdia[0]/minf[0]/stbl[0]/stsd[0]/avc1[0]"); List<Box> nuBoxes = new ArrayList<Box>(); assert sampleEntry != null; for (Box box : sampleEntry.getBoxes()) { if (!box.getType().equals("pasp")) { nuBoxes.add(box); } } sampleEntry.setBoxes(nuBoxes); i.writeContainer(new FileOutputStream("C:\\Users\\sannies\\Downloads\\CF2.0_1920x1080_8000-without-pasp.mp4").getChannel()); }
private VisualSampleEntry createSampleEntry() { VisualSampleEntry visualSampleEntry = new VisualSampleEntry("hvc1"); visualSampleEntry.setDataReferenceIndex(1); visualSampleEntry.setDepth(24); visualSampleEntry.setFrameCount(1); visualSampleEntry.setHorizresolution(72); visualSampleEntry.setVertresolution(72); visualSampleEntry.setWidth(640); visualSampleEntry.setHeight(480); visualSampleEntry.setCompressorname("HEVC Coding"); visualSampleEntry.addBox(hevcConfigurationBox); return visualSampleEntry;
@Override public void getBox(WritableByteChannel writableByteChannel) throws IOException { writableByteChannel.write(getHeader()); ByteBuffer byteBuffer = ByteBuffer.allocate(78); byteBuffer.position(6); IsoTypeWriter.writeUInt16(byteBuffer, dataReferenceIndex); IsoTypeWriter.writeUInt16(byteBuffer, 0); IsoTypeWriter.writeUInt16(byteBuffer, 0); IsoTypeWriter.writeUInt32(byteBuffer, predefined[0]); IsoTypeWriter.writeUInt32(byteBuffer, predefined[1]); IsoTypeWriter.writeUInt32(byteBuffer, predefined[2]); IsoTypeWriter.writeUInt16(byteBuffer, getWidth()); IsoTypeWriter.writeUInt16(byteBuffer, getHeight()); IsoTypeWriter.writeFixedPoint1616(byteBuffer, getHorizresolution()); IsoTypeWriter.writeFixedPoint1616(byteBuffer, getVertresolution()); IsoTypeWriter.writeUInt32(byteBuffer, 0); IsoTypeWriter.writeUInt16(byteBuffer, getFrameCount()); IsoTypeWriter.writeUInt8(byteBuffer, Utf8.utf8StringLengthInBytes(getCompressorname())); byteBuffer.put(Utf8.convert(getCompressorname())); int a = Utf8.utf8StringLengthInBytes(getCompressorname()); while (a < 31) { a++; byteBuffer.put((byte) 0); } IsoTypeWriter.writeUInt16(byteBuffer, getDepth()); IsoTypeWriter.writeUInt16(byteBuffer, 0xFFFF); writableByteChannel.write((ByteBuffer) byteBuffer.rewind()); writeContainer(writableByteChannel); }
String codecName = vse.getType(); AvcConfigurationBox avc1 = vse.getBoxes(AvcConfigurationBox.class).get(0); avcLevel = avc1.getAvcLevelIndication(); log.debug("AVC level: {}", avcLevel); if (vse.getBoxes(ESDescriptorBox.class).size() > 0) { ESDescriptorBox esds = vse.getBoxes(ESDescriptorBox.class).get(0); if (esds != null) { ESDescriptor descriptor = esds.getEsDescriptor(); log.debug("Unrecognized video codec: {} compressor name: {}", codecName, vse.getCompressorname());
int visual_object_verid = 0; mp4v = new VisualSampleEntry("mp4v"); mp4v.addBox(esds);
private void parse(LookAhead la) throws IOException { visualSampleEntry = new VisualSampleEntry("avc1"); visualSampleEntry.setDataReferenceIndex(1); visualSampleEntry.setDepth(24); visualSampleEntry.setFrameCount(1); visualSampleEntry.setHorizresolution(72); visualSampleEntry.setVertresolution(72); visualSampleEntry.setWidth(width); visualSampleEntry.setHeight(height); visualSampleEntry.setCompressorname("AVC Coding"); ); visualSampleEntry.addBox(avcConfigurationBox);
@Override public void getBox(WritableByteChannel writableByteChannel) throws IOException { writableByteChannel.write(getHeader()); ByteBuffer byteBuffer = ByteBuffer.allocate(78); byteBuffer.position(6); IsoTypeWriter.writeUInt16(byteBuffer, dataReferenceIndex); IsoTypeWriter.writeUInt16(byteBuffer, 0); IsoTypeWriter.writeUInt16(byteBuffer, 0); IsoTypeWriter.writeUInt32(byteBuffer, predefined[0]); IsoTypeWriter.writeUInt32(byteBuffer, predefined[1]); IsoTypeWriter.writeUInt32(byteBuffer, predefined[2]); IsoTypeWriter.writeUInt16(byteBuffer, getWidth()); IsoTypeWriter.writeUInt16(byteBuffer, getHeight()); IsoTypeWriter.writeFixedPoint1616(byteBuffer, getHorizresolution()); IsoTypeWriter.writeFixedPoint1616(byteBuffer, getVertresolution()); IsoTypeWriter.writeUInt32(byteBuffer, 0); IsoTypeWriter.writeUInt16(byteBuffer, getFrameCount()); IsoTypeWriter.writeUInt8(byteBuffer, Utf8.utf8StringLengthInBytes(getCompressorname())); byteBuffer.put(Utf8.convert(getCompressorname())); int a = Utf8.utf8StringLengthInBytes(getCompressorname()); while (a < 31) { a++; byteBuffer.put((byte) 0); } IsoTypeWriter.writeUInt16(byteBuffer, getDepth()); IsoTypeWriter.writeUInt16(byteBuffer, 0xFFFF); writableByteChannel.write((ByteBuffer) byteBuffer.rewind()); writeContainer(writableByteChannel); }
String codecName = vse.getType(); AvcConfigurationBox avc1 = vse.getBoxes(AvcConfigurationBox.class).get(0); avcLevel = avc1.getAvcLevelIndication(); log.debug("AVC level: {}", avcLevel); if (vse.getBoxes(ESDescriptorBox.class).size() > 0) { ESDescriptorBox esds = vse.getBoxes(ESDescriptorBox.class).get(0); if (esds != null) { ESDescriptor descriptor = esds.getEsDescriptor(); log.debug("Unrecognized video codec: {} compressor name: {}", codecName, vse.getCompressorname());
mp4v = new VisualSampleEntry("mp4v"); ESDescriptorBox esds = new ESDescriptorBox(); esds.setData(ByteBuffer.wrap(Hex.decodeHex("038080801B000100048080800D6C11000000000A1CB4000A1CB4068080800102"))); esds.setEsDescriptor((ESDescriptor) ObjectDescriptorFactory.createFrom(-1, ByteBuffer.wrap(Hex.decodeHex("038080801B000100048080800D6C11000000000A1CB4000A1CB4068080800102")))); mp4v.addBox(esds); this.syncSamples = new long[jpegs.length]; for (int i = 0; i < this.syncSamples.length; i++) {
private VisualSampleEntry mergeVisualSampleEntry(VisualSampleEntry vse1, VisualSampleEntry vse2) { VisualSampleEntry vse = new VisualSampleEntry(); if (vse1.getHorizresolution() == vse2.getHorizresolution()) { vse.setHorizresolution(vse1.getHorizresolution()); } else { LOG.error("Horizontal Resolution differs"); return null; vse.setCompressorname(vse1.getCompressorname()); // ignore if they differ if (vse1.getDepth() == vse2.getDepth()) { vse.setDepth(vse1.getDepth()); } else { LOG.error("Depth differs"); if (vse1.getFrameCount() == vse2.getFrameCount()) { vse.setFrameCount(vse1.getFrameCount()); } else { LOG.error("frame count differs"); if (vse1.getHeight() == vse2.getHeight()) { vse.setHeight(vse1.getHeight()); } else { LOG.error("height differs"); return null; if (vse1.getWidth() == vse2.getWidth()) { vse.setWidth(vse1.getWidth()); } else { LOG.error("width differs");
VisualSampleEntry visualSampleEntry = new VisualSampleEntry("avc1"); visualSampleEntry.setDataReferenceIndex(1); visualSampleEntry.setDepth(24); visualSampleEntry.setFrameCount(1); visualSampleEntry.setHorizresolution(72); visualSampleEntry.setVertresolution(72); DimensionTrackExtension dte = this.getTrackExtension(DimensionTrackExtension.class); if (dte == null) { this.addTrackExtension(new DimensionTrackExtension(width, height)); visualSampleEntry.setWidth(width); visualSampleEntry.setHeight(height); visualSampleEntry.setCompressorname("AVC Coding"); ); visualSampleEntry.addBox(avcConfigurationBox); stsd = new SampleDescriptionBox(); stsd.addBox(visualSampleEntry);
int visual_object_verid = 0; mp4v = new VisualSampleEntry("mp4v"); mp4v.addBox(esds);
private VisualSampleEntry createSampleEntry() { VisualSampleEntry visualSampleEntry = new VisualSampleEntry("hvc1"); visualSampleEntry.setDataReferenceIndex(1); visualSampleEntry.setDepth(24); visualSampleEntry.setFrameCount(1); visualSampleEntry.setHorizresolution(72); visualSampleEntry.setVertresolution(72); visualSampleEntry.setWidth(640); visualSampleEntry.setHeight(480); visualSampleEntry.setCompressorname("HEVC Coding"); visualSampleEntry.addBox(hevcConfigurationBox); return visualSampleEntry;
mp4v = new VisualSampleEntry("mp4v"); ESDescriptorBox esds = new ESDescriptorBox(); esds.setData(ByteBuffer.wrap(Hex.decodeHex("038080801B000100048080800D6C11000000000A1CB4000A1CB4068080800102"))); esds.setEsDescriptor((ESDescriptor) ObjectDescriptorFactory.createFrom(-1, ByteBuffer.wrap(Hex.decodeHex("038080801B000100048080800D6C11000000000A1CB4000A1CB4068080800102")))); mp4v.addBox(esds); this.syncSamples = new long[jpegs.length]; for (int i = 0; i < this.syncSamples.length; i++) {
private void parse(LookAhead la) throws IOException { visualSampleEntry = new VisualSampleEntry("avc1"); visualSampleEntry.setDataReferenceIndex(1); visualSampleEntry.setDepth(24); visualSampleEntry.setFrameCount(1); visualSampleEntry.setHorizresolution(72); visualSampleEntry.setVertresolution(72); visualSampleEntry.setWidth(width); visualSampleEntry.setHeight(height); visualSampleEntry.setCompressorname("AVC Coding"); ); visualSampleEntry.addBox(avcConfigurationBox);