com.coremedia.iso.boxes.SampleTableBox Java Examples

The following examples show how to use com.coremedia.iso.boxes.SampleTableBox. 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 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 #2
Source File: MP4Builder.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
protected void createStts(Track track, SampleTableBox stbl) {
    TimeToSampleBox.Entry lastEntry = null;
    List<TimeToSampleBox.Entry> entries = new ArrayList<>();
    long[] deltas = track.getSampleDurations();

    for (int a = 0; a < deltas.length; a++) {
        long delta = deltas[a];
        if (lastEntry != null && lastEntry.getDelta() == delta) {
            lastEntry.setCount(lastEntry.getCount() + 1);
        } else {
            lastEntry = new TimeToSampleBox.Entry(1, delta);
            entries.add(lastEntry);
        }
    }
    TimeToSampleBox stts = new TimeToSampleBox();
    stts.setEntries(entries);
    stbl.addBox(stts);
}
 
Example #3
Source File: MP4Builder.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
protected void createCtts(Track track, SampleTableBox stbl) {
    int[] sampleCompositions = track.getSampleCompositions();
    if (sampleCompositions == null) {
        return;
    }
    CompositionTimeToSample.Entry lastEntry = null;
    List<CompositionTimeToSample.Entry> entries = new ArrayList<>();

    for (int a = 0; a < sampleCompositions.length; a++) {
        int offset = sampleCompositions[a];
        if (lastEntry != null && lastEntry.getOffset() == offset) {
            lastEntry.setCount(lastEntry.getCount() + 1);
        } else {
            lastEntry = new CompositionTimeToSample.Entry(1, offset);
            entries.add(lastEntry);
        }
    }
    CompositionTimeToSample ctts = new CompositionTimeToSample();
    ctts.setEntries(entries);
    stbl.addBox(ctts);
}
 
Example #4
Source File: MP4Builder.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
protected void createCtts(Track track, SampleTableBox stbl) {
    int[] sampleCompositions = track.getSampleCompositions();
    if (sampleCompositions == null) {
        return;
    }
    CompositionTimeToSample.Entry lastEntry = null;
    List<CompositionTimeToSample.Entry> entries = new ArrayList<>();

    for (int a = 0; a < sampleCompositions.length; a++) {
        int offset = sampleCompositions[a];
        if (lastEntry != null && lastEntry.getOffset() == offset) {
            lastEntry.setCount(lastEntry.getCount() + 1);
        } else {
            lastEntry = new CompositionTimeToSample.Entry(1, offset);
            entries.add(lastEntry);
        }
    }
    CompositionTimeToSample ctts = new CompositionTimeToSample();
    ctts.setEntries(entries);
    stbl.addBox(ctts);
}
 
Example #5
Source File: MP4Builder.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
protected void createStts(Track track, SampleTableBox stbl) {
    TimeToSampleBox.Entry lastEntry = null;
    List<TimeToSampleBox.Entry> entries = new ArrayList<>();
    long[] deltas = track.getSampleDurations();

    for (int a = 0; a < deltas.length; a++) {
        long delta = deltas[a];
        if (lastEntry != null && lastEntry.getDelta() == delta) {
            lastEntry.setCount(lastEntry.getCount() + 1);
        } else {
            lastEntry = new TimeToSampleBox.Entry(1, delta);
            entries.add(lastEntry);
        }
    }
    TimeToSampleBox stts = new TimeToSampleBox();
    stts.setEntries(entries);
    stbl.addBox(stts);
}
 
Example #6
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 #7
Source File: MP4Builder.java    From VideoCompressor with Apache License 2.0 6 votes vote down vote up
protected void createStts(Track track, SampleTableBox stbl) {
    TimeToSampleBox.Entry lastEntry = null;
    List<TimeToSampleBox.Entry> entries = new ArrayList<>();

    for (long delta : track.getSampleDurations()) {
        if (lastEntry != null && lastEntry.getDelta() == delta) {
            lastEntry.setCount(lastEntry.getCount() + 1);
        } else {
            lastEntry = new TimeToSampleBox.Entry(1, delta);
            entries.add(lastEntry);
        }
    }
    TimeToSampleBox stts = new TimeToSampleBox();
    stts.setEntries(entries);
    stbl.addBox(stts);
}
 
Example #8
Source File: MP4Builder.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
protected void createStts(Track track, SampleTableBox stbl) {
    TimeToSampleBox.Entry lastEntry = null;
    List<TimeToSampleBox.Entry> entries = new ArrayList<>();
    long[] deltas = track.getSampleDurations();

    for (int a = 0; a < deltas.length; a++) {
        long delta = deltas[a];
        if (lastEntry != null && lastEntry.getDelta() == delta) {
            lastEntry.setCount(lastEntry.getCount() + 1);
        } else {
            lastEntry = new TimeToSampleBox.Entry(1, delta);
            entries.add(lastEntry);
        }
    }
    TimeToSampleBox stts = new TimeToSampleBox();
    stts.setEntries(entries);
    stbl.addBox(stts);
}
 
Example #9
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 #10
Source File: MP4Builder.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
protected void createCtts(Track track, SampleTableBox stbl) {
    int[] sampleCompositions = track.getSampleCompositions();
    if (sampleCompositions == null) {
        return;
    }
    CompositionTimeToSample.Entry lastEntry = null;
    List<CompositionTimeToSample.Entry> entries = new ArrayList<>();

    for (int a = 0; a < sampleCompositions.length; a++) {
        int offset = sampleCompositions[a];
        if (lastEntry != null && lastEntry.getOffset() == offset) {
            lastEntry.setCount(lastEntry.getCount() + 1);
        } else {
            lastEntry = new CompositionTimeToSample.Entry(1, offset);
            entries.add(lastEntry);
        }
    }
    CompositionTimeToSample ctts = new CompositionTimeToSample();
    ctts.setEntries(entries);
    stbl.addBox(ctts);
}
 
Example #11
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 #12
Source File: MP4Builder.java    From react-native-video-helper with MIT License 6 votes vote down vote up
protected void createStts(Track track, SampleTableBox stbl) {
    TimeToSampleBox.Entry lastEntry = null;
    List<TimeToSampleBox.Entry> entries = new ArrayList<>();

    for (long delta : track.getSampleDurations()) {
        if (lastEntry != null && lastEntry.getDelta() == delta) {
            lastEntry.setCount(lastEntry.getCount() + 1);
        } else {
            lastEntry = new TimeToSampleBox.Entry(1, delta);
            entries.add(lastEntry);
        }
    }
    TimeToSampleBox stts = new TimeToSampleBox();
    stts.setEntries(entries);
    stbl.addBox(stts);
}
 
Example #13
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 #14
Source File: MP4Builder.java    From VideoCompressor with Apache License 2.0 6 votes vote down vote up
protected void createStts(Track track, SampleTableBox stbl) {
    TimeToSampleBox.Entry lastEntry = null;
    List<TimeToSampleBox.Entry> entries = new ArrayList<>();

    for (long delta : track.getSampleDurations()) {
        if (lastEntry != null && lastEntry.getDelta() == delta) {
            lastEntry.setCount(lastEntry.getCount() + 1);
        } else {
            lastEntry = new TimeToSampleBox.Entry(1, delta);
            entries.add(lastEntry);
        }
    }
    TimeToSampleBox stts = new TimeToSampleBox();
    stts.setEntries(entries);
    stbl.addBox(stts);
}
 
Example #15
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 #16
Source File: MP4Builder.java    From talk-android with MIT License 6 votes vote down vote up
protected void createStts(Track track, SampleTableBox stbl) {
    TimeToSampleBox.Entry lastEntry = null;
    List<TimeToSampleBox.Entry> entries = new ArrayList<>();

    for (long delta : track.getSampleDurations()) {
        if (lastEntry != null && lastEntry.getDelta() == delta) {
            lastEntry.setCount(lastEntry.getCount() + 1);
        } else {
            lastEntry = new TimeToSampleBox.Entry(1, delta);
            entries.add(lastEntry);
        }
    }
    TimeToSampleBox stts = new TimeToSampleBox();
    stts.setEntries(entries);
    stbl.addBox(stts);
}
 
Example #17
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 #18
Source File: MP4Builder.java    From SiliCompressor with Apache License 2.0 6 votes vote down vote up
protected void createStts(Track track, SampleTableBox stbl) {
    TimeToSampleBox.Entry lastEntry = null;
    List<TimeToSampleBox.Entry> entries = new ArrayList<>();

    for (long delta : track.getSampleDurations()) {
        if (lastEntry != null && lastEntry.getDelta() == delta) {
            lastEntry.setCount(lastEntry.getCount() + 1);
        } else {
            lastEntry = new TimeToSampleBox.Entry(1, delta);
            entries.add(lastEntry);
        }
    }
    TimeToSampleBox stts = new TimeToSampleBox();
    stts.setEntries(entries);
    stbl.addBox(stts);
}
 
Example #19
Source File: MP4Builder.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
protected void createStts(Track track, SampleTableBox stbl) {
    TimeToSampleBox.Entry lastEntry = null;
    List<TimeToSampleBox.Entry> entries = new ArrayList<>();
    long[] deltas = track.getSampleDurations();

    for (int a = 0; a < deltas.length; a++) {
        long delta = deltas[a];
        if (lastEntry != null && lastEntry.getDelta() == delta) {
            lastEntry.setCount(lastEntry.getCount() + 1);
        } else {
            lastEntry = new TimeToSampleBox.Entry(1, delta);
            entries.add(lastEntry);
        }
    }
    TimeToSampleBox stts = new TimeToSampleBox();
    stts.setEntries(entries);
    stbl.addBox(stts);
}
 
Example #20
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 #21
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 #22
Source File: MP4Builder.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
protected void createCtts(Track track, SampleTableBox stbl) {
    int[] sampleCompositions = track.getSampleCompositions();
    if (sampleCompositions == null) {
        return;
    }
    CompositionTimeToSample.Entry lastEntry = null;
    List<CompositionTimeToSample.Entry> entries = new ArrayList<>();

    for (int a = 0; a < sampleCompositions.length; a++) {
        int offset = sampleCompositions[a];
        if (lastEntry != null && lastEntry.getOffset() == offset) {
            lastEntry.setCount(lastEntry.getCount() + 1);
        } else {
            lastEntry = new CompositionTimeToSample.Entry(1, offset);
            entries.add(lastEntry);
        }
    }
    CompositionTimeToSample ctts = new CompositionTimeToSample();
    ctts.setEntries(entries);
    stbl.addBox(ctts);
}
 
Example #23
Source File: MP4Builder.java    From deltachat-android with GNU General Public License v3.0 6 votes vote down vote up
protected void createStts(Track track, SampleTableBox stbl) {
    TimeToSampleBox.Entry lastEntry = null;
    List<TimeToSampleBox.Entry> entries = new ArrayList<>();

    for (long delta : track.getSampleDurations()) {
        if (lastEntry != null && lastEntry.getDelta() == delta) {
            lastEntry.setCount(lastEntry.getCount() + 1);
        } else {
            lastEntry = new TimeToSampleBox.Entry(1, delta);
            entries.add(lastEntry);
        }
    }
    TimeToSampleBox stts = new TimeToSampleBox();
    stts.setEntries(entries);
    stbl.addBox(stts);
}
 
Example #24
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);
}
 
Example #25
Source File: MP4Builder.java    From deltachat-android with GNU General Public License v3.0 5 votes vote down vote up
protected void createStss(Track track, SampleTableBox stbl) {
    long[] syncSamples = track.getSyncSamples();
    if (syncSamples != null && syncSamples.length > 0) {
        SyncSampleBox stss = new SyncSampleBox();
        stss.setSampleNumber(syncSamples);
        stbl.addBox(stss);
    }
}
 
Example #26
Source File: MP4Builder.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
protected void createStss(Track track, SampleTableBox stbl) {
    long[] syncSamples = track.getSyncSamples();
    if (syncSamples != null && syncSamples.length > 0) {
        SyncSampleBox stss = new SyncSampleBox();
        stss.setSampleNumber(syncSamples);
        stbl.addBox(stss);
    }
}
 
Example #27
Source File: MP4Builder.java    From SiliCompressor with Apache License 2.0 5 votes vote down vote up
protected Box createStbl(Track track) {
    SampleTableBox stbl = new SampleTableBox();

    createStsd(track, stbl);
    createStts(track, stbl);
    createStss(track, stbl);
    createStsc(track, stbl);
    createStsz(track, stbl);
    createStco(track, stbl);

    return stbl;
}
 
Example #28
Source File: MP4Builder.java    From VideoCompressor with Apache License 2.0 5 votes vote down vote up
protected Box createStbl(Track track) {
    SampleTableBox stbl = new SampleTableBox();

    createStsd(track, stbl);
    createStts(track, stbl);
    createStss(track, stbl);
    createStsc(track, stbl);
    createStsz(track, stbl);
    createStco(track, stbl);

    return stbl;
}
 
Example #29
Source File: MP4Builder.java    From talk-android with MIT License 5 votes vote down vote up
protected void createStss(Track track, SampleTableBox stbl) {
    long[] syncSamples = track.getSyncSamples();
    if (syncSamples != null && syncSamples.length > 0) {
        SyncSampleBox stss = new SyncSampleBox();
        stss.setSampleNumber(syncSamples);
        stbl.addBox(stss);
    }
}
 
Example #30
Source File: MP4Builder.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
protected Box createStbl(Track track) {
    SampleTableBox stbl = new SampleTableBox();

    createStsd(track, stbl);
    createStts(track, stbl);
    createCtts(track, stbl);
    createStss(track, stbl);
    createStsc(track, stbl);
    createStsz(track, stbl);
    createStco(track, stbl);

    return stbl;
}