protected void createStco(Track track, SampleTableBox stbl) { ArrayList<Long> chunksOffsets = new ArrayList<>(); long lastOffset = -1; for (Sample sample : track.getSamples()) { long offset = sample.getOffset(); if (lastOffset != -1 && lastOffset != offset) { lastOffset = -1; } if (lastOffset == -1) { chunksOffsets.add(offset); } lastOffset = offset + sample.getSize(); } long[] chunkOffsetsLong = new long[chunksOffsets.size()]; for (int a = 0; a < chunksOffsets.size(); a++) { chunkOffsetsLong[a] = chunksOffsets.get(a); } StaticChunkOffsetBox stco = new StaticChunkOffsetBox(); stco.setChunkOffsets(chunkOffsetsLong); stbl.addBox(stco); } }
protected void createStco(Track track, SampleTableBox stbl) { ArrayList<Long> chunksOffsets = new ArrayList<>(); long lastOffset = -1; for (Sample sample : track.getSamples()) { long offset = sample.getOffset(); if (lastOffset != -1 && lastOffset != offset) { lastOffset = -1; } if (lastOffset == -1) { chunksOffsets.add(offset); } lastOffset = offset + sample.getSize(); } long[] chunkOffsetsLong = new long[chunksOffsets.size()]; for (int a = 0; a < chunksOffsets.size(); a++) { chunkOffsetsLong[a] = chunksOffsets.get(a); } StaticChunkOffsetBox stco = new StaticChunkOffsetBox(); stco.setChunkOffsets(chunkOffsetsLong); stbl.addBox(stco); } }
protected void createStco(Track track, SampleTableBox stbl) { ArrayList<Long> chunksOffsets = new ArrayList<>(); long lastOffset = -1; for (Sample sample : track.getSamples()) { long offset = sample.getOffset(); if (lastOffset != -1 && lastOffset != offset) { lastOffset = -1; } if (lastOffset == -1) { chunksOffsets.add(offset); } lastOffset = offset + sample.getSize(); } long[] chunkOffsetsLong = new long[chunksOffsets.size()]; for (int a = 0; a < chunksOffsets.size(); a++) { chunkOffsetsLong[a] = chunksOffsets.get(a); } StaticChunkOffsetBox stco = new StaticChunkOffsetBox(); stco.setChunkOffsets(chunkOffsetsLong); stbl.addBox(stco); } }
private void correctChunkOffsets(Container container, long correction) { List<Box> chunkOffsetBoxes = Path.getPaths(container, "/moov[0]/trak/mdia[0]/minf[0]/stbl[0]/stco[0]"); for (Box chunkOffsetBox : chunkOffsetBoxes) { LinkedList<Box> stblChildren = new LinkedList<>(chunkOffsetBox.getParent().getBoxes()); stblChildren.remove(chunkOffsetBox); long[] cOffsets = ((ChunkOffsetBox) chunkOffsetBox).getChunkOffsets(); for (int i = 0; i < cOffsets.length; i++) { cOffsets[i] += correction; } StaticChunkOffsetBox cob = new StaticChunkOffsetBox(); cob.setChunkOffsets(cOffsets); stblChildren.add(cob); chunkOffsetBox.getParent().setBoxes(stblChildren); } }
stco.setChunkOffsets(chunkOffset); stbl.addBox(stco); minf.addBox(stbl);
stco.setChunkOffsets(chunkOffset); stbl.addBox(stco); minf.addBox(stbl);