本文整理汇总了Java中com.coremedia.iso.boxes.TrackHeaderBox类的典型用法代码示例。如果您正苦于以下问题:Java TrackHeaderBox类的具体用法?Java TrackHeaderBox怎么用?Java TrackHeaderBox使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TrackHeaderBox类属于com.coremedia.iso.boxes包,在下文中一共展示了TrackHeaderBox类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: muxerFileDebug
import com.coremedia.iso.boxes.TrackHeaderBox; //导入依赖的package包/类
public static void muxerFileDebug(){
try
{
File input = new File(SDCardUtils.getExternalSdCardPath() + "/a.h264");
File output = new File(SDCardUtils.getExternalSdCardPath() + "/b.mp4");
H264TrackImpl h264Track = new H264TrackImpl(new FileDataSourceImpl(input), "eng", UriParser.videoQuality.framerate, 1);
Movie m = new Movie();
m.addTrack(h264Track);
m.setMatrix(Matrix.ROTATE_90);
Container out = new DefaultMp4Builder().build(m);
MovieHeaderBox mvhd = Path.getPath(out, "moov/mvhd");
mvhd.setMatrix(Matrix.ROTATE_90);
TrackBox trackBox = Path.getPath(out, "moov/trak");
TrackHeaderBox tkhd = trackBox.getTrackHeaderBox();
tkhd.setMatrix(Matrix.ROTATE_90);
FileChannel fc = new FileOutputStream(output.getAbsolutePath()).getChannel();
out.writeContainer(fc);
fc.close();
}
catch (IOException e) {
Log.e("test", "some exception", e);
}
}
示例2: _parseDetails
import com.coremedia.iso.boxes.TrackHeaderBox; //导入依赖的package包/类
@Override
public void _parseDetails(ByteBuffer content) {
parseVersionAndFlags(content);
int useThisIvSize = -1;
if ((getFlags() & 0x1) > 0) {
algorithmId = IsoTypeReader.readUInt24(content);
ivSize = IsoTypeReader.readUInt8(content);
useThisIvSize = ivSize;
kid = new byte[16];
content.get(kid);
} else {
List<Box> tkhds = Path.getPaths(this, "/moov[0]/trak/tkhd");
for (Box tkhd : tkhds) {
if (((TrackHeaderBox) tkhd).getTrackId() == this.getParent().getBoxes(TrackFragmentHeaderBox.class).get(0).getTrackId()) {
AbstractTrackEncryptionBox tenc = (AbstractTrackEncryptionBox) Path.getPath(tkhd, "../mdia[0]/minf[0]/stbl[0]/stsd[0]/enc.[0]/sinf[0]/schi[0]/tenc[0]");
if (tenc == null) {
tenc = (AbstractTrackEncryptionBox) Path.getPath(tkhd, "../mdia[0]/minf[0]/stbl[0]/stsd[0]/enc.[0]/sinf[0]/schi[0]/uuid[0]");
}
useThisIvSize = tenc.getDefaultIvSize();
}
}
}
long numOfEntries = IsoTypeReader.readUInt32(content);
while (numOfEntries-- > 0) {
Entry e = new Entry();
e.iv = new byte[useThisIvSize < 0 ? 8 : useThisIvSize]; // default to 8
content.get(e.iv);
if ((getFlags() & 0x2) > 0) {
int numOfPairs = IsoTypeReader.readUInt16(content);
e.pairs = new LinkedList<Entry.Pair>();
while (numOfPairs-- > 0) {
e.pairs.add(e.createPair(IsoTypeReader.readUInt16(content), IsoTypeReader.readUInt32(content)));
}
}
entries.add(e);
}
}
示例3: createTkhd
import com.coremedia.iso.boxes.TrackHeaderBox; //导入依赖的package包/类
protected Box createTkhd(Movie movie, Track track) {
TrackHeaderBox tkhd = new TrackHeaderBox();
tkhd.setVersion(1);
int flags = 0;
if (track.isEnabled()) {
flags += 1;
}
if (track.isInMovie()) {
flags += 2;
}
if (track.isInPreview()) {
flags += 4;
}
if (track.isInPoster()) {
flags += 8;
}
tkhd.setFlags(flags);
tkhd.setAlternateGroup(track.getTrackMetaData().getGroup());
tkhd.setCreationTime(track.getTrackMetaData().getCreationTime());
// We need to take edit list box into account in trackheader duration
// but as long as I don't support edit list boxes it is sufficient to
// just translate media duration to movie timescale
tkhd.setDuration(getTrackDuration(movie, track));
tkhd.setHeight(track.getTrackMetaData().getHeight());
tkhd.setWidth(track.getTrackMetaData().getWidth());
tkhd.setLayer(track.getTrackMetaData().getLayer());
tkhd.setModificationTime(new Date());
tkhd.setTrackId(track.getTrackMetaData().getTrackId());
tkhd.setVolume(track.getTrackMetaData().getVolume());
return tkhd;
}
示例4: LoadSpecificBox
import com.coremedia.iso.boxes.TrackHeaderBox; //导入依赖的package包/类
private void LoadSpecificBox( TrackHeaderBox box ) {
addViewForValue( "Creation Time:", box.getCreationTime() );
addViewForValue( "Duration:", box.getDuration() );
addViewForValue( "Layer:", box.getLayer() );
addViewForValue( "Modification Time:", box.getModificationTime() );
addViewForValue( "Track ID:", box.getTrackId() );
addViewForValue( "Volume:", box.getVolume() );
addViewForValue( "Width:", box.getWidth() );
addViewForValue( "Height:", box.getHeight() );
addViewForValue( "Alternate Group:", box.getAlternateGroup() );
addMatrixView( "Matrix:", box.getMatrix() );
}
示例5: createTrackBox
import com.coremedia.iso.boxes.TrackHeaderBox; //导入依赖的package包/类
protected TrackBox createTrackBox(Track track, Mp4Movie movie) {
TrackBox trackBox = new TrackBox();
TrackHeaderBox tkhd = new TrackHeaderBox();
tkhd.setEnabled(true);
tkhd.setInMovie(true);
tkhd.setInPreview(true);
if (track.isAudio()) {
tkhd.setMatrix(Matrix.ROTATE_0);
} else {
tkhd.setMatrix(movie.getMatrix());
}
tkhd.setAlternateGroup(0);
tkhd.setCreationTime(track.getCreationTime());
tkhd.setDuration(track.getDuration() * getTimescale(movie) / track.getTimeScale());
tkhd.setHeight(track.getHeight());
tkhd.setWidth(track.getWidth());
tkhd.setLayer(0);
tkhd.setModificationTime(new Date());
tkhd.setTrackId(track.getTrackId() + 1);
tkhd.setVolume(track.getVolume());
trackBox.addBox(tkhd);
MediaBox mdia = new MediaBox();
trackBox.addBox(mdia);
MediaHeaderBox mdhd = new MediaHeaderBox();
mdhd.setCreationTime(track.getCreationTime());
mdhd.setDuration(track.getDuration());
mdhd.setTimescale(track.getTimeScale());
mdhd.setLanguage("eng");
mdia.addBox(mdhd);
HandlerBox hdlr = new HandlerBox();
hdlr.setName(track.isAudio() ? "SoundHandle" : "VideoHandle");
hdlr.setHandlerType(track.getHandler());
mdia.addBox(hdlr);
MediaInformationBox minf = new MediaInformationBox();
minf.addBox(track.getMediaHeaderBox());
DataInformationBox dinf = new DataInformationBox();
DataReferenceBox dref = new DataReferenceBox();
dinf.addBox(dref);
DataEntryUrlBox url = new DataEntryUrlBox();
url.setFlags(1);
dref.addBox(url);
minf.addBox(dinf);
Box stbl = createStbl(track);
minf.addBox(stbl);
mdia.addBox(minf);
return trackBox;
}
示例6: createTrackBox
import com.coremedia.iso.boxes.TrackHeaderBox; //导入依赖的package包/类
private TrackBox createTrackBox(Track track, Mp4Movie movie) {
TrackBox trackBox = new TrackBox();
TrackHeaderBox tkhd = new TrackHeaderBox();
tkhd.setEnabled(true);
tkhd.setInMovie(true);
tkhd.setInPreview(true);
if (track.isAudio()) {
tkhd.setMatrix(Matrix.ROTATE_0);
} else {
tkhd.setMatrix(movie.getMatrix());
}
tkhd.setAlternateGroup(0);
tkhd.setCreationTime(track.getCreationTime());
tkhd.setModificationTime(track.getCreationTime());
tkhd.setDuration(track.getDuration() * getTimescale(movie) / track.getTimeScale());
tkhd.setHeight(track.getHeight());
tkhd.setWidth(track.getWidth());
tkhd.setLayer(0);
tkhd.setModificationTime(new Date());
tkhd.setTrackId(track.getTrackId() + 1);
tkhd.setVolume(track.getVolume());
trackBox.addBox(tkhd);
MediaBox mdia = new MediaBox();
trackBox.addBox(mdia);
MediaHeaderBox mdhd = new MediaHeaderBox();
mdhd.setCreationTime(track.getCreationTime());
mdhd.setModificationTime(track.getCreationTime());
mdhd.setDuration(track.getDuration());
mdhd.setTimescale(track.getTimeScale());
mdhd.setLanguage("eng");
mdia.addBox(mdhd);
HandlerBox hdlr = new HandlerBox();
hdlr.setName(track.isAudio() ? "SoundHandle" : "VideoHandle");
hdlr.setHandlerType(track.getHandler());
mdia.addBox(hdlr);
MediaInformationBox minf = new MediaInformationBox();
minf.addBox(track.getMediaHeaderBox());
DataInformationBox dinf = new DataInformationBox();
DataReferenceBox dref = new DataReferenceBox();
dinf.addBox(dref);
DataEntryUrlBox url = new DataEntryUrlBox();
url.setFlags(1);
dref.addBox(url);
minf.addBox(dinf);
Box stbl = createStbl(track);
minf.addBox(stbl);
mdia.addBox(minf);
return trackBox;
}
示例7: RotateVideo
import com.coremedia.iso.boxes.TrackHeaderBox; //导入依赖的package包/类
public static Uri RotateVideo( Uri uri, int rotation ) {
Uri rotatedVideoUri = null;
try {
IsoFile file = new IsoFile( uri.toString() );
List<Box> boxes = file.getMovieBox().getBoxes();
for ( Box box : boxes ) {
if ( box instanceof TrackBox ) {
TrackBox trackBox = (TrackBox) box;
HandlerBox handlerBox = trackBox.getMediaBox().getHandlerBox();
if ( handlerBox.getHandlerType().toLowerCase( Locale.US ).equals( "vide" ) ) {
TrackHeaderBox trackHeaderBox = trackBox.getTrackHeaderBox();
trackHeaderBox.setMatrix( GetMatrixFromRotation( rotation ) );
}
}
}
String pathWithoutExtension = uri.toString().replace( ".mp4", "" );
String rotatedFileName = String.format( Locale.US, "%s_rotated_to_%d.mp4", pathWithoutExtension, rotation );
FileOutputStream videoFileOutputStream = new FileOutputStream( rotatedFileName );
file.getBox( videoFileOutputStream.getChannel() );
file.close();
videoFileOutputStream.close();
rotatedVideoUri = Uri.parse( rotatedFileName );
} catch ( IOException e ) {
e.printStackTrace();
return null;
}
return rotatedVideoUri;
}
示例8: loadIsoFile
import com.coremedia.iso.boxes.TrackHeaderBox; //导入依赖的package包/类
private Media loadIsoFile(IsoFile isoFile, FileBaseResourceInfo fileBaseResourceInfo) {
// Grab the file type box
FileTypeBox fileType = getOrNull(isoFile, FileTypeBox.class);
if (fileType == null) {
return null;
}
// Get the main MOOV box
MovieBox moov = getOrNull(isoFile, MovieBox.class);
if (moov == null) {
// Bail out
return null;
}
double duration = 0;
// Pull out some information from the header box
MovieHeaderBox mHeader = getOrNull(moov, MovieHeaderBox.class);
if (mHeader == null) {
return null;
}
// Get the duration. Seconds
duration = (double)mHeader.getDuration() / mHeader.getTimescale();
if (duration == 0){
duration = 1;
}
// Get some more information from the track header
List<TrackBox> tb = moov.getBoxes(TrackBox.class);
if (tb.isEmpty()) {
return null;
}
// Get the video with and height
int width = 0;
int height = 0;
for(int idx=0; idx<tb.size(); idx++){
TrackBox track = tb.get(idx);
TrackHeaderBox header = track.getTrackHeaderBox();
int w = (int)header.getWidth();
int h = (int)header.getHeight();
if (w==0 && h==0){
// skip the none-video track
continue;
}
// Get the video with and height
width = w;
height = h;
break;
}
if (width == 0 && height == 0) {
// no video track found.
return null;
}
Video.Format format = (
MIME_TYPE_VIDEO_MP4.equals(fileBaseResourceInfo.getMimeType())?
Video.Format.mp4:
Video.Format.mov);
return new DefaultVideo(
fileBaseResourceInfo, format,
width, height, duration);
}