本文整理汇总了Java中org.mp4parser.boxes.iso14496.part12.TrackBox类的典型用法代码示例。如果您正苦于以下问题:Java TrackBox类的具体用法?Java TrackBox怎么用?Java TrackBox使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TrackBox类属于org.mp4parser.boxes.iso14496.part12包,在下文中一共展示了TrackBox类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: build
import org.mp4parser.boxes.iso14496.part12.TrackBox; //导入依赖的package包/类
/**
* Creates <code>Movie</code> object from a <code>ReadableByteChannel</code>.
*
* @param name track name to identify later
* @param readableByteChannel the box structure is read from this channel
* @param randomAccessSource the samples or read from this randomAccessSource
* @return a representation of the movie
* @throws IOException in case of I/O error during IsoFile creation
*/
public static Movie build(ReadableByteChannel readableByteChannel, RandomAccessSource randomAccessSource, String name) throws IOException {
IsoFile isoFile = new IsoFile(readableByteChannel);
Movie m = new Movie();
List<TrackBox> trackBoxes = isoFile.getMovieBox().getBoxes(TrackBox.class);
for (TrackBox trackBox : trackBoxes) {
SchemeTypeBox schm = Path.getPath(trackBox, "mdia[0]/minf[0]/stbl[0]/stsd[0]/enc.[0]/sinf[0]/schm[0]");
if (schm != null && (schm.getSchemeType().equals("cenc") || schm.getSchemeType().equals("cbc1"))) {
m.addTrack(new CencMp4TrackImplImpl(
trackBox.getTrackHeaderBox().getTrackId(), isoFile,
randomAccessSource, name + "[" + trackBox.getTrackHeaderBox().getTrackId() + "]"));
} else if (schm != null && (schm.getSchemeType().equals("piff"))) {
m.addTrack(new PiffMp4TrackImpl(
trackBox.getTrackHeaderBox().getTrackId(), isoFile,
randomAccessSource, name + "[" + trackBox.getTrackHeaderBox().getTrackId() + "]"));
} else {
m.addTrack(new Mp4TrackImpl(
trackBox.getTrackHeaderBox().getTrackId(), isoFile,
randomAccessSource, name + "[" + trackBox.getTrackHeaderBox().getTrackId() + "]"));
}
}
m.setMatrix(isoFile.getMovieBox().getMovieHeaderBox().getMatrix());
return m;
}
示例2: main
import org.mp4parser.boxes.iso14496.part12.TrackBox; //导入依赖的package包/类
public static void main(String[] args) throws IOException {
IsoFile isoFile = new IsoFile("D:\\downloads\\cracked.s01e01.hdtv.x264-2hd.mp4");
List<TrackBox> trackBoxes = Path.getPath(isoFile, "moov/trak/");
long trackId = -1;
TrackBox trackBox = null;
for (TrackBox _trackBox : trackBoxes) {
if (Path.getPath(_trackBox, "mdia/minf/stbl/stsd/avc1") != null) {
trackId = _trackBox.getTrackHeaderBox().getTrackId();
trackBox = _trackBox;
}
}
Mp4SampleList sl = new Mp4SampleList(trackId, isoFile, new FileRandomAccessSourceImpl(
new RandomAccessFile("D:\\downloads\\cracked.s01e01.hdtv.x264-2hd.mp4", "r")));
FileChannel fc = new FileOutputStream("out.h264").getChannel();
ByteBuffer separator = ByteBuffer.wrap(new byte[]{0, 0, 0, 1});
fc.write((ByteBuffer) separator.rewind());
// Write SPS
fc.write((
((AvcConfigurationBox) Path.getPath(trackBox, "mdia/minf/stbl/stsd/avc1/avcC")
).getSequenceParameterSets().get(0)));
// Warning:
// There might be more than one SPS (I've never seen that but it is possible)
fc.write((ByteBuffer) separator.rewind());
// Write PPS
fc.write((
((AvcConfigurationBox) Path.getPath(trackBox, "mdia/minf/stbl/stsd/avc1/avcC")
).getPictureParameterSets().get(0)));
// Warning:
// There might be more than one PPS (I've never seen that but it is possible)
int lengthSize = ((AvcConfigurationBox) Path.getPath(trackBox, "mdia/minf/stbl/stsd/avc1/avcC")).getLengthSizeMinusOne() + 1;
for (Sample sample : sl) {
ByteBuffer bb = sample.asByteBuffer();
while (bb.remaining() > 0) {
int length = (int) IsoTypeReaderVariable.read(bb, lengthSize);
fc.write((ByteBuffer) separator.rewind());
fc.write((ByteBuffer) bb.slice().limit(length));
bb.position(bb.position() + length);
}
}
fc.close();
}