public static <T extends Box> List<T> getPaths(Container container, String path) { return getPaths(container, path, false); }
public static <T extends Box> List<T> getPaths(Box box, String path) { return getPaths(box, path, false); }
public List<TrackFragmentHeaderBox> getTrackFragmentHeaderBoxes() { return Path.getPaths((Container) this, "tfhd"); }
private static <T extends Box> List<T> getPaths(AbstractContainerBox container, String path, boolean singleResult) { return getPaths((Object) container, path, singleResult); }
private static <T extends Box> List<T> getPaths(Container container, String path, boolean singleResult) { return getPaths((Object) container, path, singleResult); }
private static <T extends Box> List<T> getPaths(ParsableBox parsableBox, String path, boolean singleResult) { return getPaths((Object) parsableBox, path, singleResult); }
public static boolean isContained(Container ref, Box box, String path) { return getPaths(ref, path).contains(box); } }
public static <T extends Box> T getPath(Box parsableBox, String path) { List<T> all = getPaths(parsableBox, path, true); return all.isEmpty() ? null : all.get(0); }
public static <T extends Box> T getPath(Container container, String path) { List<T> all = getPaths(container, path, true); return all.isEmpty() ? null : all.get(0); }
public static <T extends Box> T getPath(AbstractContainerBox containerBox, String path) { List<T> all = getPaths(containerBox, path, true); return all.isEmpty() ? null : all.get(0); }
private void correctChunkOffsets(MovieBox movieBox, long correction) { List<ChunkOffsetBox> chunkOffsetBoxes = Path.getPaths((Box) movieBox, "trak/mdia[0]/minf[0]/stbl[0]/stco[0]"); if (chunkOffsetBoxes.isEmpty()) { chunkOffsetBoxes = Path.getPaths((Box) movieBox, "trak/mdia[0]/minf[0]/stbl[0]/st64[0]"); } for (ChunkOffsetBox chunkOffsetBox : chunkOffsetBoxes) { long[] cOffsets = chunkOffsetBox.getChunkOffsets(); for (int i = 0; i < cOffsets.length; i++) { cOffsets[i] += correction; } } }
public Mp4SampleList(long trackId, Container isofile, RandomAccessSource source) { if (Path.getPaths(isofile, "moov/mvex/trex").isEmpty()) { samples = new DefaultMp4SampleList(trackId, isofile, source); } else { samples = new FragmentedMp4SampleList(trackId, isofile, source); } }
public static boolean needsOffsetCorrection(IsoFile isoFile) { if (Path.getPaths(isoFile, "mdat").size() > 1) { throw new RuntimeException("There might be the weird case that a file has two mdats. One before" + " moov and one after moov. That would need special handling therefore I just throw an " + "exception here. "); } if (Path.getPaths(isoFile, "moof").size() > 0) { throw new RuntimeException("Fragmented MP4 files need correction, too. (But I would need to look where)"); } for (Box box : isoFile.getBoxes()) { if ("mdat".equals(box.getType())) { return false; } if ("moov".equals(box.getType())) { return true; } } throw new RuntimeException("Hmmm - shouldn't happen"); }
public static void main(String[] args) throws IOException { IsoFile isoFile = new IsoFile("/Users/sannies/dev/common_transcoding-packager-encrypter/dashencrypter/15000_dv5.mp4"); List<TrackBox> trackBoxes = Path.getPaths(isoFile, "moov/trak/");
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); } }
public FragmentedMp4SampleList(long track, Container isofile, RandomAccessSource randomAccess) { this.isofile = isofile; this.randomAccess = randomAccess; List<TrackBox> tbs = Path.getPaths(isofile, "moov[0]/trak"); for (TrackBox tb : tbs) { if (tb.getTrackHeaderBox().getTrackId() == track) { trackBox = tb; } } if (trackBox == null) { throw new RuntimeException("This MP4 does not contain track " + track); } List<TrackExtendsBox> trexs = Path.getPaths(isofile, "moov[0]/mvex[0]/trex"); for (TrackExtendsBox box : trexs) { if (box.getTrackId() == trackBox.getTrackHeaderBox().getTrackId()) { trex = box; } } 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"); sampleCache = (SoftReference<Sample>[]) Array.newInstance(SoftReference.class, size()); initAllFragments(); }
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); } }
super(trackId, isofile, randomAccess, name); TrackBox trackBox = null; for (TrackBox box : Path.<TrackBox>getPaths(isofile, "moov/trak")) { if (box.getTrackHeaderBox().getTrackId() == trackId) { trackBox = box; final List<MovieExtendsBox> movieExtendsBoxes = Path.getPaths(isofile, "moov/mvex"); if (!movieExtendsBoxes.isEmpty()) {
List<TrackExtendsBox> trexs = Path.getPaths(isoFile, "moov/mvex/trex"); for (TrackExtendsBox innerTrex : trexs) { if (innerTrex.getTrackId() == track.getTrackMetaData().getTrackId()) {
List<SampleSizeBox> stszs = Path.getPaths(moov, "trak/mdia/minf/stbl/stsz");