本文整理汇总了Java中com.coremedia.iso.boxes.MovieBox类的典型用法代码示例。如果您正苦于以下问题:Java MovieBox类的具体用法?Java MovieBox怎么用?Java MovieBox使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MovieBox类属于com.coremedia.iso.boxes包,在下文中一共展示了MovieBox类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getTrackExtendsBox
import com.coremedia.iso.boxes.MovieBox; //导入依赖的package包/类
public TrackExtendsBox getTrackExtendsBox() {
final TrackFragmentHeaderBox tfhd = ((TrackFragmentBox) getParent()).getTrackFragmentHeaderBox();
final List<MovieBox> movieBoxes = tfhd.getIsoFile().getBoxes(MovieBox.class);
if (movieBoxes.size() == 0) {
return null;
}
final List<TrackExtendsBox> trexBoxes = movieBoxes.get(0).getBoxes(TrackExtendsBox.class, true);
TrackExtendsBox trex = null;
for (TrackExtendsBox aTrex : trexBoxes) {
if (aTrex.getTrackId() == tfhd.getTrackId()) {
trex = aTrex;
}
}
return trex;
}
示例2: getMovieBox
import com.coremedia.iso.boxes.MovieBox; //导入依赖的package包/类
/**
* Shortcut to get the MovieBox since it is often needed and present in
* nearly all ISO 14496 files (at least if they are derived from MP4 ).
*
* @return the MovieBox or <code>null</code>
*/
@DoNotParseDetail
public MovieBox getMovieBox() {
for (Box box : boxes) {
if (box instanceof MovieBox) {
return (MovieBox) box;
}
}
return null;
}
示例3: createMoov
import com.coremedia.iso.boxes.MovieBox; //导入依赖的package包/类
/**
* Creates a fully populated 'moov' box with all child boxes. Child boxes are:
* <ul>
* <li>{@link #createMvhd(com.googlecode.mp4parser.authoring.Movie) mvhd}</li>
* <li>{@link #createMvex(com.googlecode.mp4parser.authoring.Movie) mvex}</li>
* <li>a {@link #createTrak(com.googlecode.mp4parser.authoring.Track, com.googlecode.mp4parser.authoring.Movie) trak} for every track</li>
* </ul>
*
* @param movie the concerned movie
* @return fully populated 'moov'
*/
protected Box createMoov(Movie movie) {
MovieBox movieBox = new MovieBox();
movieBox.addBox(createMvhd(movie));
movieBox.addBox(createMvex(movie));
for (Track track : movie.getTracks()) {
movieBox.addBox(createTrak(track, movie));
}
// metadata here
return movieBox;
}
示例4: getVideoDate
import com.coremedia.iso.boxes.MovieBox; //导入依赖的package包/类
private Date getVideoDate(File videoFile) throws Exception {
TimeZone.setDefault(TimeZone.getTimeZone("CET"));
try {
IsoFile isoFile = new IsoFile(videoFile.getAbsolutePath());
MovieBox movieBox = isoFile.getMovieBox();
MovieHeaderBox movieHeaderBox = movieBox.getMovieHeaderBox();
return movieHeaderBox.getCreationTime();
}
catch (IOException | NullPointerException e) {
//LOGGER.error("File is not a parcelable mp4");
throw new CouldNotParseDateException();
}
}
示例5: sendMeasurement
import com.coremedia.iso.boxes.MovieBox; //导入依赖的package包/类
private void sendMeasurement()
{
// read next video frame
try
{
videoFrameBuffer.reset();
WritableByteChannel byteChannel = Channels.newChannel(videoFrameBuffer);
// init or loop
if (mp4Boxes == null || !mp4Boxes.hasNext())
mp4Boxes = mp4File.getBoxes().iterator();
// copy all box until actual frame data is found
while (mp4Boxes.hasNext())
{
Box currentBox = mp4Boxes.next();
if (currentBox instanceof MovieBox)
{
log.trace(((MovieBox) currentBox).getMovieHeaderBox().toString());
}
if (currentBox instanceof MovieFragmentBox)
{
// always increment seq number
sampleCounter++;
((MovieFragmentBox) currentBox).getBoxes(MovieFragmentHeaderBox.class).get(0).setSequenceNumber(sampleCounter);;
// need to rewrite base offset so it's not relative to begining of file
//((MovieFragmentBox) currentBox).getTrackFragmentHeaderBoxes().get(0).setDefaultBaseIsMoof(true);
((MovieFragmentBox) currentBox).getTrackFragmentHeaderBoxes().get(0).setBaseDataOffset(-1L);
((MovieFragmentBox) currentBox).getTrackFragmentHeaderBoxes().get(0).setDefaultSampleDuration(4000);
((MovieFragmentBox) currentBox).getTrackRunBoxes().get(0).setDataOffset(224-8);
log.trace(((MovieFragmentBox) currentBox).getBoxes(MovieFragmentHeaderBox.class).get(0).toString());
log.trace(((MovieFragmentBox) currentBox).getTrackFragmentHeaderBoxes().get(0).toString());
log.trace(((MovieFragmentBox) currentBox).getTrackRunBoxes().get(0).toString());
//for (Entry sample: ((MovieFragmentBox) currentBox).getTrackRunBoxes().get(0).getEntries())
// System.out.println(sample);
}
if (currentBox.getType().equals("moof"))
{
// TODO add time tag box (tfdt?)
log.trace("Copying box " + currentBox.getType());
currentBox.getBox(byteChannel);
}
else if (currentBox.getType().equals("mdat"))
{
log.trace("Copying box " + currentBox.getType());
currentBox.getBox(byteChannel);
break;
}
else if (currentBox.getType().equals("mfra"))
{
mp4Boxes = mp4File.getBoxes().iterator();
}
}
}
catch (IOException e)
{
throw new RuntimeException(e);
}
// build and publish datablock
DataBlockCompressed dataBlock = new DataBlockCompressed();
dataBlock.setUnderlyingObject(videoFrameBuffer.toByteArray());
// update latest record and send event
latestRecord = dataBlock;
latestRecordTime = System.currentTimeMillis();
eventHandler.publishEvent(new SensorDataEvent(latestRecordTime, FakeCamOutput.this, dataBlock));
}
示例6: LoadSpecificBox
import com.coremedia.iso.boxes.MovieBox; //导入依赖的package包/类
private void LoadSpecificBox( MovieBox box ) {
addViewForValue( "Track Count:", box.getTrackCount() );
addViewForValue( "Track Numbers:", box.getTrackNumbers() );
}
示例7: parse
import com.coremedia.iso.boxes.MovieBox; //导入依赖的package包/类
@Override
public MetaData parse(Object object) {
Assert.isTrue(object instanceof MovieBox, "Support MovieBox class only.");
MovieBox moov = (MovieBox)object;
// Get metadata from the User Data Box
UserDataBox userData = getOrNull(moov, UserDataBox.class);
if (userData == null) {
return null;
}
MetaBox meta = getOrNull(userData, MetaBox.class);
// Check for iTunes Metadata
// See http://atomicparsley.sourceforge.net/mpeg-4files.html and
// http://code.google.com/p/mp4v2/wiki/iTunesMetadata for more on these
AppleItemListBox apple = getOrNull(meta, AppleItemListBox.class);
if (apple == null) {
return null;
}
MetaData metaData = new MetaData();
// Title
AppleNameBox title = getOrNull(apple, AppleNameBox.class);
addMetadata(metaData, Audio.MetaName.Title, title);
// Artist
AppleArtistBox artist = getOrNull(apple, AppleArtistBox.class);
addMetadata(metaData, Audio.MetaName.Artist, artist);
// Album
AppleAlbumBox album = getOrNull(apple, AppleAlbumBox.class);
addMetadata(metaData, Audio.MetaName.Album, album);
// Composer
//AppleTrackAuthorBox composer = getOrNull(apple, AppleTrackAuthorBox.class);
// Genre
AppleGenreBox genre = getOrNull(apple, AppleGenreBox.class);
addMetadata(metaData, Audio.MetaName.Genre, genre);
// AppleCustomGenreBox cGenre = getOrNull(apple, AppleCustomGenreBox.class);
// addMetadata(metaData, Audio.MetaName.Genre, cGenre);
// Year
// AppleRecordingYearBox year = getOrNull(apple, AppleRecordingYearBox.class);
// Track number
// AppleTrackNumberBox trackNum = getOrNull(apple, AppleTrackNumberBox.class);
// if (trackNum != null) {
// metadata.set(XMPDM.TRACK_NUMBER, trackNum.getTrackNumber());
// //metadata.set(XMPDM.NUMBER_OF_TRACKS, trackNum.getNumberOfTracks()); // TODO
// }
// Comment
// AppleCommentBox comment = getOrNull(apple, AppleCommentBox.class);
// Encoder
// AppleEncoderBox encoder = getOrNull(apple, AppleEncoderBox.class);
return metaData;
}
示例8: loadIsoFile
import com.coremedia.iso.boxes.MovieBox; //导入依赖的package包/类
private Media loadIsoFile(IsoFile isoFile, FileBaseResourceInfo fileBaseResourceInfo) {
// Grab the file type box
FileTypeBox fileType = getOrNull(isoFile, FileTypeBox.class);
if (fileType == null) {
return null;
}
// String brand = fileType.getMajorBrand();
// String type = null;
//
// for(String t : mp4_audio_brands) {
// if (brand.equals(t)){
// type = t;
// break;
// }
// }
//
// for(String t : mp4_video_brands) {
// if (brand.equals(t)){
// type = t;
// break;
// }
// }
//
// if (type == null){
// return null;
// }
// Audio.Format format = null;
// String encoding = null;
// if ("mp3".equals(audioHeader.getEncodingType())){
// format = Audio.Format.mp3;
// encoding = "mp3";
// }else if ("AAC".equals(audioHeader.getEncodingType())){
// format = Audio.Format.m4a;
// encoding = "aac";
// }
//
// mp4 file format, see:
// http://1.richitec.sinaapp.com/?p=46
// 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();
// see: http://en.wikipedia.org/wiki/Bit_rate
int bitrate = (int)(fileBaseResourceInfo.getContentLength() * 8 / duration / 1000);
Audio audio = new DefaultAudio(
fileBaseResourceInfo,
Audio.Format.m4a, "aac",
duration,
bitrate,
Audio.BitrateMode.variable);
M4aMetaDataParser metaDataParser = new M4aMetaDataParser();
audio.setMetaData(metaDataParser.parse(moov));
return audio;
}
示例9: loadIsoFile
import com.coremedia.iso.boxes.MovieBox; //导入依赖的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);
}