com.coremedia.iso.boxes.StaticChunkOffsetBox Java Examples

The following examples show how to use com.coremedia.iso.boxes.StaticChunkOffsetBox. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MP4Builder.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
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);
}
 
Example #2
Source File: MP4Builder.java    From VideoCompressor with Apache License 2.0 6 votes vote down vote up
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);
}
 
Example #3
Source File: MP4Builder.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
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);
}
 
Example #4
Source File: MP4Builder.java    From react-native-video-helper with MIT License 6 votes vote down vote up
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);
}
 
Example #5
Source File: MP4Builder.java    From VideoCompressor with Apache License 2.0 6 votes vote down vote up
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);
}
 
Example #6
Source File: MP4Builder.java    From talk-android with MIT License 6 votes vote down vote up
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);
}
 
Example #7
Source File: DownloadFinishedReceiver.java    From YouTube-In-Background with MIT License 6 votes vote down vote up
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);
    }
}
 
Example #8
Source File: MP4Builder.java    From SiliCompressor with Apache License 2.0 6 votes vote down vote up
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);
}
 
Example #9
Source File: MP4Builder.java    From deltachat-android with GNU General Public License v3.0 6 votes vote down vote up
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);
}
 
Example #10
Source File: MP4Builder.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
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);
}
 
Example #11
Source File: MP4Builder.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
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);
}