protected Box createStbl(StreamingTrack streamingTrack) { SampleTableBox stbl = new SampleTableBox(); stbl.addBox(streamingTrack.getSampleDescriptionBox()); stbl.addBox(new TimeToSampleBox()); stbl.addBox(new SampleToChunkBox()); stbl.addBox(new SampleSizeBox()); stbl.addBox(new StaticChunkOffsetBox()); return stbl; }
long _currentChunk = currentChunks.get(trackBox); long _currentSample = currentSamples.get(trackBox); long[] chunkOffsets = trackBox.getSampleTableBox().getChunkOffsetBox().getChunkOffsets(); SampleToChunkBox stsc = firstInLine.getSampleTableBox().getSampleToChunkBox(); for (SampleToChunkBox.Entry _entry : stsc.getEntries()) { if (currentChunk >= _entry.getFirstChunk()) { SampleTableBox stbl = firstInLine.getSampleTableBox(); List<TimeToSampleBox.Entry> times = stbl.getTimeToSampleBox().getEntries(); List<CompositionTimeToSample.Entry> compositionOffsets = stbl.getCompositionTimeToSample() != null ? stbl.getCompositionTimeToSample().getEntries() : null; SampleSizeBox stsz = stbl.getSampleSizeBox(); sfse.setSampleHasRedundancy(e.getSampleHasRedundancy()); if (stbl.getSyncSampleBox() != null) { if (Arrays.binarySearch(stbl.getSyncSampleBox().getSampleNumber(), index) >= 0) { sfse.setSampleIsNonSyncSample(false); } else {
private static void correctChunkOffsets(IsoFile tempIsoFile, long correction) { List<SampleTableBox> sampleTableBoxes = Path.getPaths(tempIsoFile, "/moov[0]/trak/mdia[0]/minf[0]/stbl[0]"); for (SampleTableBox sampleTableBox : sampleTableBoxes) { List<Box> stblChildren = new ArrayList<Box>(sampleTableBox.getBoxes()); ChunkOffsetBox chunkOffsetBox = Path.getPath(sampleTableBox, "stco"); if (chunkOffsetBox == null) { stblChildren.remove(Path.getPath(sampleTableBox, "co64")); } stblChildren.remove(chunkOffsetBox); assert chunkOffsetBox != null; long[] cOffsets = chunkOffsetBox.getChunkOffsets(); for (int i = 0; i < cOffsets.length; i++) { cOffsets[i] += correction; } StaticChunkOffsetBox cob = new StaticChunkOffsetBox(); cob.setChunkOffsets(cOffsets); stblChildren.add(cob); sampleTableBox.setBoxes(stblChildren); } }
private void processAudioStbl(SampleTableBox stbl, long scale) { SampleToChunkBox stsc = stbl.getSampleToChunkBox(); // stsc if (stsc != null) { log.debug("Sample to chunk atom found"); SampleSizeBox stsz = stbl.getSampleSizeBox(); // stsz if (stsz != null) { log.debug("Sample size atom found"); ChunkOffsetBox stco = stbl.getChunkOffsetBox(); // stco / co64 if (stco != null) { log.debug("Chunk offset atom found"); } else { ChunkOffset64BitBox co64 = stbl.getBoxes(ChunkOffset64BitBox.class).get(0); if (co64 != null) { log.debug("Chunk offset (64) atom found"); TimeToSampleBox stts = stbl.getTimeToSampleBox(); // stts if (stts != null) { log.debug("Time to sample atom found"); SampleDependencyTypeBox sdtp = stbl.getSampleDependencyTypeBox(); // sdtp if (sdtp != null) { log.debug("Independent and disposable samples atom found");
SampleToChunkBox stsc = stbl.getSampleToChunkBox(); // stsc if (stsc != null) { log.debug("Sample to chunk atom found"); SampleSizeBox stsz = stbl.getSampleSizeBox(); // stsz if (stsz != null) { log.debug("Sample size atom found"); ChunkOffsetBox stco = stbl.getChunkOffsetBox(); // stco / co64 if (stco != null) { log.debug("Chunk offset atom found"); List<ChunkOffset64BitBox> stblBoxes = stbl.getBoxes(ChunkOffset64BitBox.class); if (stblBoxes != null && !stblBoxes.isEmpty()) { ChunkOffset64BitBox co64 = stblBoxes.get(0); SyncSampleBox stss = stbl.getSyncSampleBox(); // stss if (stss != null) { log.debug("Sync sample atom found"); TimeToSampleBox stts = stbl.getTimeToSampleBox(); // stts if (stts != null) { log.debug("Time to sample atom found"); CompositionTimeToSample ctts = stbl.getCompositionTimeToSample(); // ctts if (ctts != null) { log.debug("Composition time to sample atom found"); SampleDependencyTypeBox sdtp = stbl.getSampleDependencyTypeBox(); // sdtp
decodingTimeEntries.addAll(stbl.getTimeToSampleBox().getEntries()); if (stbl.getCompositionTimeToSample() != null) { compositionTimeEntries.addAll(stbl.getCompositionTimeToSample().getEntries()); if (stbl.getSampleDependencyTypeBox() != null) { sampleDependencies.addAll(stbl.getSampleDependencyTypeBox().getEntries()); if (stbl.getSyncSampleBox() != null) { syncSamples = stbl.getSyncSampleBox().getSampleNumber(); sampleDescriptionBox = stbl.getSampleDescriptionBox(); int lastSubsSample = 0; final List<MovieExtendsBox> movieExtendsBoxes = Path.getPaths(isofile, "moov/mvex"); if (traf.getTrackFragmentHeaderBox().getTrackId() == trackId) { sampleGroups = getSampleGroups( stbl.getBoxes(SampleGroupDescriptionBox.class), // global descriptions Path.<SampleGroupDescriptionBox>getPaths((Container) traf, "sgpd"), // local description Path.<SampleToGroupBox>getPaths((Container) traf, "sbgp"), if (traf.getTrackFragmentHeaderBox().getTrackId() == trackId) { sampleGroups = getSampleGroups( stbl.getBoxes(SampleGroupDescriptionBox.class), Path.<SampleGroupDescriptionBox>getPaths((Container) traf, "sgpd"), Path.<SampleToGroupBox>getPaths((Container) traf, "sbgp"), sampleGroups, 0); sampleGroups = getSampleGroups(stbl.getBoxes(SampleGroupDescriptionBox.class), null, stbl.getBoxes(SampleToGroupBox.class), sampleGroups, 0);
throw new RuntimeException("This MP4 does not contain track " + track); sampleEntries = new ArrayList<>(trackBox.getSampleTableBox().getSampleDescriptionBox().getBoxes(SampleEntry.class)); if (sampleEntries.size() != trackBox.getSampleTableBox().getSampleDescriptionBox().getBoxes().size()) throw new AssertionError("stsd contains not only sample entries. Something's wrong here! Bailing out"); chunkOffsets = trackBox.getSampleTableBox().getChunkOffsetBox().getChunkOffsets(); long[] chunkSizes = new long[chunkOffsets.length]; ssb = trackBox.getSampleTableBox().getSampleSizeBox(); List<SampleToChunkBox.Entry> s2chunkEntries = trackBox.getSampleTableBox().getSampleToChunkBox().getEntries(); SampleToChunkBox.Entry[] entries = s2chunkEntries.toArray(new SampleToChunkBox.Entry[s2chunkEntries.size()]);
log.debug("stbl children: {}", stbl.getBoxes().size()); MP4Reader.dumpBox(stbl); SampleDescriptionBox stsd = stbl.getSampleDescriptionBox(); // stsd if (stsd != null) {
protected void createStsz(Track track, SampleTableBox stbl) { SampleSizeBox stsz = new SampleSizeBox(); stsz.setSampleSizes(track2SampleSizes.get(track)); stbl.addBox(stsz); }
assert schm != null && (schm.getSchemeType().equals("cenc") || schm.getSchemeType().equals("cbc1")) : "Track must be CENC (cenc or cbc1) encrypted"; List<SampleEntry> sampleEntries = trackBox.getMediaBox().getMediaInformationBox().getSampleTableBox().getSampleDescriptionBox().getBoxes(SampleEntry.class); assert trackBox.getMediaBox().getMediaInformationBox().getSampleTableBox().getSampleDescriptionBox().getBoxes().size() == sampleEntries.size(); long[] chunkSizes = trackBox.getSampleTableBox().getSampleToChunkBox().blowup(chunkOffsetBox.getChunkOffsets().length);
public ChunkOffsetBox getChunkOffsetBox() { for (Box box : getBoxes()) { if (box instanceof ChunkOffsetBox) { return (ChunkOffsetBox) box; } } return null; }
public SampleDescriptionBox getSampleDescriptionBox() { return trackBox.getSampleTableBox().getSampleDescriptionBox(); }
@Override public int size() { return l2i(trackBox.getSampleTableBox().getSampleSizeBox().getSampleCount()); }
public ClassicMp4ContainerSource(InputStream is) throws IOException { readableByteChannel = Channels.newChannel(new TeeInputStream(is, baos)); BasicContainer container = new BasicContainer(); BoxParser boxParser = new PropertyBoxParserImpl(); Box current = null; while (current == null || !"moov".equals(current.getType())) { current = boxParser.parseBox(readableByteChannel, null); container.addBox(current); } // Either mdat was already read (yeahh sucks but what can you do if it's in the beginning) // or it's still coming for (TrackBox trackBox : Path.<TrackBox>getPaths(container, "moov[0]/trak")) { Mp4StreamingTrack mp4StreamingTrack = new Mp4StreamingTrack(trackBox); tracks.put(trackBox, mp4StreamingTrack); if (trackBox.getSampleTableBox().getCompositionTimeToSample() != null) { mp4StreamingTrack.addTrackExtension(new CompositionTimeTrackExtension()); } mp4StreamingTrack.addTrackExtension(new TrackIdTrackExtension(trackBox.getTrackHeaderBox().getTrackId())); currentChunks.put(trackBox, 1L); currentSamples.put(trackBox, 1L); } }
private void processAudioStbl(SampleTableBox stbl, long scale) { SampleToChunkBox stsc = stbl.getSampleToChunkBox(); // stsc if (stsc != null) { log.debug("Sample to chunk atom found"); SampleSizeBox stsz = stbl.getSampleSizeBox(); // stsz if (stsz != null) { log.debug("Sample size atom found"); ChunkOffsetBox stco = stbl.getChunkOffsetBox(); // stco / co64 if (stco != null) { log.debug("Chunk offset atom found"); } else { ChunkOffset64BitBox co64 = stbl.getBoxes(ChunkOffset64BitBox.class).get(0); if (co64 != null) { log.debug("Chunk offset (64) atom found"); TimeToSampleBox stts = stbl.getTimeToSampleBox(); // stts if (stts != null) { log.debug("Time to sample atom found"); SampleDependencyTypeBox sdtp = stbl.getSampleDependencyTypeBox(); // sdtp if (sdtp != null) { log.debug("Independent and disposable samples atom found");
SampleToChunkBox stsc = stbl.getSampleToChunkBox(); // stsc if (stsc != null) { log.debug("Sample to chunk atom found"); SampleSizeBox stsz = stbl.getSampleSizeBox(); // stsz if (stsz != null) { log.debug("Sample size atom found"); ChunkOffsetBox stco = stbl.getChunkOffsetBox(); // stco / co64 if (stco != null) { log.debug("Chunk offset atom found"); List<ChunkOffset64BitBox> stblBoxes = stbl.getBoxes(ChunkOffset64BitBox.class); if (stblBoxes != null && !stblBoxes.isEmpty()) { ChunkOffset64BitBox co64 = stblBoxes.get(0); SyncSampleBox stss = stbl.getSyncSampleBox(); // stss if (stss != null) { log.debug("Sync sample atom found"); TimeToSampleBox stts = stbl.getTimeToSampleBox(); // stts if (stts != null) { log.debug("Time to sample atom found"); CompositionTimeToSample ctts = stbl.getCompositionTimeToSample(); // ctts if (ctts != null) { log.debug("Composition time to sample atom found"); SampleDependencyTypeBox sdtp = stbl.getSampleDependencyTypeBox(); // sdtp
decodingTimeEntries.addAll(stbl.getTimeToSampleBox().getEntries()); if (stbl.getCompositionTimeToSample() != null) { compositionTimeEntries.addAll(stbl.getCompositionTimeToSample().getEntries()); if (stbl.getSampleDependencyTypeBox() != null) { sampleDependencies.addAll(stbl.getSampleDependencyTypeBox().getEntries()); if (stbl.getSyncSampleBox() != null) { syncSamples = stbl.getSyncSampleBox().getSampleNumber(); sampleDescriptionBox = stbl.getSampleDescriptionBox(); int lastSubsSample = 0; final List<MovieExtendsBox> movieExtendsBoxes = Path.getPaths(isofile, "moov/mvex"); if (traf.getTrackFragmentHeaderBox().getTrackId() == trackId) { sampleGroups = getSampleGroups( stbl.getBoxes(SampleGroupDescriptionBox.class), // global descriptions Path.<SampleGroupDescriptionBox>getPaths((Container) traf, "sgpd"), // local description Path.<SampleToGroupBox>getPaths((Container) traf, "sbgp"), if (traf.getTrackFragmentHeaderBox().getTrackId() == trackId) { sampleGroups = getSampleGroups( stbl.getBoxes(SampleGroupDescriptionBox.class), Path.<SampleGroupDescriptionBox>getPaths((Container) traf, "sgpd"), Path.<SampleToGroupBox>getPaths((Container) traf, "sbgp"), sampleGroups, 0); sampleGroups = getSampleGroups(stbl.getBoxes(SampleGroupDescriptionBox.class), null, stbl.getBoxes(SampleToGroupBox.class), sampleGroups, 0);
throw new RuntimeException("This MP4 does not contain track " + track); sampleEntries = new ArrayList<>(trackBox.getSampleTableBox().getSampleDescriptionBox().getBoxes(SampleEntry.class)); if (sampleEntries.size() != trackBox.getSampleTableBox().getSampleDescriptionBox().getBoxes().size()) throw new AssertionError("stsd contains not only sample entries. Something's wrong here! Bailing out"); chunkOffsets = trackBox.getSampleTableBox().getChunkOffsetBox().getChunkOffsets(); long[] chunkSizes = new long[chunkOffsets.length]; ssb = trackBox.getSampleTableBox().getSampleSizeBox(); List<SampleToChunkBox.Entry> s2chunkEntries = trackBox.getSampleTableBox().getSampleToChunkBox().getEntries(); SampleToChunkBox.Entry[] entries = s2chunkEntries.toArray(new SampleToChunkBox.Entry[s2chunkEntries.size()]);
log.debug("stbl children: {}", stbl.getBoxes().size()); MP4Reader.dumpBox(stbl); SampleDescriptionBox stsd = stbl.getSampleDescriptionBox(); // stsd if (stsd != null) {