本文整理汇总了Java中com.coremedia.iso.boxes.MovieHeaderBox类的典型用法代码示例。如果您正苦于以下问题:Java MovieHeaderBox类的具体用法?Java MovieHeaderBox怎么用?Java MovieHeaderBox使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MovieHeaderBox类属于com.coremedia.iso.boxes包,在下文中一共展示了MovieHeaderBox类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: muxerFileDebug
import com.coremedia.iso.boxes.MovieHeaderBox; //导入依赖的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);
}
}
开发者ID:xunboo,项目名称:JJCamera,代码行数:26,代码来源:MP4Muxer.java
示例2: LoadSpecificBox
import com.coremedia.iso.boxes.MovieHeaderBox; //导入依赖的package包/类
private void LoadSpecificBox( MovieHeaderBox box ) {
addViewForValue( "Timescale:", box.getTimescale() );
addViewForValue( "Duration:", box.getDuration() );
addViewForValue( "Rate:", box.getRate() );
addViewForValue( "Volume:", box.getVolume() );
addViewForValue( "Creation Time:", box.getCreationTime() );
addViewForValue( "Modification Time:", box.getModificationTime() );
addViewForValue( "Poster Time:", box.getPosterTime() );
addViewForValue( "Current Time:", box.getCurrentTime() );
addViewForValue( "Preview Duration:", box.getPreviewDuration() );
addViewForValue( "Preview Time:", box.getPreviewTime() );
addViewForValue( "Selection Duration:", box.getSelectionDuration() );
addViewForValue( "Selection Time:", box.getSelectionTime() );
addViewForValue( "Next Track Id:", box.getNextTrackId() );
addMatrixView( "Matrix:", box.getMatrix() );
}
开发者ID:hoolrory,项目名称:VideoInfoViewer,代码行数:19,代码来源:BoxInfoView.java
示例3: startTrim
import com.coremedia.iso.boxes.MovieHeaderBox; //导入依赖的package包/类
public static void startTrim(File src, File dst, double startTime, double endTime) throws IOException {
FileDataSourceImpl file = new FileDataSourceImpl(src);
Movie movie = MovieCreator.build(file);
List<Track> tracks = movie.getTracks();
movie.setTracks(new LinkedList<Track>());
Log.d(TAG, "startTrim: " + startTime + " " + endTime);
for (Track track : tracks) {
long currentSample = 0;
double currentTime = 0;
long startSample = -1;
long endSample = -1;
for (int i = 0; i < track.getSampleDurations().length; i++) {
if (currentTime <= startTime) {
// current sample is still before the new starttime
startSample = currentSample;
}
if (currentTime <= endTime) {
// current sample is after the new start time and still before the new endtime
endSample = currentSample;
} else {
// current sample is after the end of the cropped video
break;
}
currentTime += (double) track.getSampleDurations()[i] / (double) track.getTrackMetaData().getTimescale();
currentSample++;
}
movie.addTrack(new CroppedTrack(track, startSample, endSample));
}
Container out = new DefaultMp4Builder().build(movie);
MovieHeaderBox mvhd = Path.getPath(out, "moov/mvhd");
mvhd.setMatrix(Matrix.ROTATE_180);
if (!dst.exists()) {
dst.createNewFile();
}
FileOutputStream fos = new FileOutputStream(dst);
WritableByteChannel fc = fos.getChannel();
try {
out.writeContainer(fc);
}catch (Exception e){
e.printStackTrace();
} finally {
fc.close();
fos.close();
file.close();
}
}
开发者ID:stfalcon-studio,项目名称:patrol-android,代码行数:49,代码来源:ProcessVideoUtils.java
示例4: getVideoDate
import com.coremedia.iso.boxes.MovieHeaderBox; //导入依赖的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();
}
}
开发者ID:kotlinski,项目名称:image-sort-master,代码行数:14,代码来源:FileDateInterpreter.java
示例5: concatTwoVideos
import com.coremedia.iso.boxes.MovieHeaderBox; //导入依赖的package包/类
public static boolean concatTwoVideos(File src1, File src2, File dst) {
try {
FileDataSourceImpl file1 = new FileDataSourceImpl(src1);
FileDataSourceImpl file2 = new FileDataSourceImpl(src2);
Movie result = new Movie();
Movie movie1 = MovieCreator.build(file1);
Movie movie2 = MovieCreator.build(file2);
Movie[] inMovies = new Movie[]{
movie1, movie2
};
List<Track> videoTracks = new LinkedList<Track>();
List<Track> audioTracks = new LinkedList<Track>();
for (Movie m : inMovies) {
for (Track t : m.getTracks()) {
if (t.getHandler().equals("soun")) {
audioTracks.add(t);
}
if (t.getHandler().equals("vide")) {
videoTracks.add(t);
}
}
}
if (audioTracks.size() > 0) {
result.addTrack(new AppendTrack(audioTracks.toArray(new Track[audioTracks.size()])));
}
if (videoTracks.size() > 0) {
result.addTrack(new AppendTrack(videoTracks.toArray(new Track[videoTracks.size()])));
}
Container out = new DefaultMp4Builder().build(result);
MovieHeaderBox mvhd = Path.getPath(out, "moov/mvhd");
mvhd.setMatrix(Matrix.ROTATE_180);
if (!dst.exists()) {
dst.createNewFile();
}
FileOutputStream fos = new FileOutputStream(dst);
WritableByteChannel fc = fos.getChannel();
try {
out.writeContainer(fc);
} finally {
fc.close();
fos.close();
file1.close();
file2.close();
}
return true;
} catch (IOException e) {
e.printStackTrace();
return false;
}
}
开发者ID:stfalcon-studio,项目名称:patrol-android,代码行数:60,代码来源:ProcessVideoUtils.java
示例6: loadIsoFile
import com.coremedia.iso.boxes.MovieHeaderBox; //导入依赖的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;
}
开发者ID:ivarptr,项目名称:clobaframe,代码行数:75,代码来源:M4aLoader.java
示例7: loadIsoFile
import com.coremedia.iso.boxes.MovieHeaderBox; //导入依赖的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);
}
开发者ID:ivarptr,项目名称:clobaframe,代码行数:72,代码来源:VideoLoader.java
注:本文中的com.coremedia.iso.boxes.MovieHeaderBox类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论