org.mp4parser.tools.Offsets Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of isoparser Show documentation
Show all versions of isoparser Show documentation
A generic parser and writer for all ISO 14496 based files (MP4, Quicktime, DCF, PDCF, ...)
The newest version!
package org.mp4parser.tools;
import org.mp4parser.Box;
import org.mp4parser.Container;
import org.mp4parser.ParsableBox;
public class Offsets {
public static long find(Container container, ParsableBox target, long offset) {
long nuOffset = offset;
for (Box lightBox : container.getBoxes()) {
if (lightBox == target) {
return nuOffset;
}
if (lightBox instanceof Container) {
long r = find((Container) lightBox, target, 0);
if (r > 0) {
return r + nuOffset;
} else {
nuOffset += lightBox.getSize();
}
} else {
nuOffset += lightBox.getSize();
}
}
return -1;
}
}