Java Code Examples for com.coremedia.iso.boxes.SampleTableBox#addBox()

The following examples show how to use com.coremedia.iso.boxes.SampleTableBox#addBox() . 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 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 2
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 3
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 4
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 5
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 6
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 7
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 8
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 9
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 10
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 11
Source File: MP4Builder.java    From SiliCompressor with Apache License 2.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 12
Source File: MP4Builder.java    From Telegram-FOSS 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 13
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 14
Source File: MP4Builder.java    From VideoCompressor with Apache License 2.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 15
Source File: MP4Builder.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
protected void createStsd(Track track, SampleTableBox stbl) {
    stbl.addBox(track.getSampleDescriptionBox());
}
 
Example 16
Source File: MP4Builder.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
protected void createStsd(Track track, SampleTableBox stbl) {
    stbl.addBox(track.getSampleDescriptionBox());
}
 
Example 17
Source File: MP4Builder.java    From VideoCompressor with Apache License 2.0 4 votes vote down vote up
protected void createStsd(Track track, SampleTableBox stbl) {
    stbl.addBox(track.getSampleDescriptionBox());
}
 
Example 18
Source File: MP4Builder.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
protected void createStsz(Track track, SampleTableBox stbl) {
    SampleSizeBox stsz = new SampleSizeBox();
    stsz.setSampleSizes(track2SampleSizes.get(track));
    stbl.addBox(stsz);
}
 
Example 19
Source File: MP4Builder.java    From talk-android with MIT License 4 votes vote down vote up
protected void createStsd(Track track, SampleTableBox stbl) {
    stbl.addBox(track.getSampleDescriptionBox());
}
 
Example 20
Source File: MP4Builder.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
protected void createStsd(Track track, SampleTableBox stbl) {
    stbl.addBox(track.getSampleDescriptionBox());
}