本文整理汇总了Java中com.googlecode.mp4parser.authoring.Movie.setTracks方法的典型用法代码示例。如果您正苦于以下问题:Java Movie.setTracks方法的具体用法?Java Movie.setTracks怎么用?Java Movie.setTracks使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.googlecode.mp4parser.authoring.Movie
的用法示例。
在下文中一共展示了Movie.setTracks方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: startMuteUsingMp4Parser
import com.googlecode.mp4parser.authoring.Movie; //导入方法依赖的package包/类
private static void startMuteUsingMp4Parser(String filePath,
SaveVideoFileInfo dstFileInfo) throws FileNotFoundException, IOException {
File dst = dstFileInfo.mFile;
File src = new File(filePath);
RandomAccessFile randomAccessFile = new RandomAccessFile(src, "r");
Movie movie = MovieCreator.build(randomAccessFile.getChannel());
// remove all tracks we will create new tracks from the old
List<Track> tracks = movie.getTracks();
movie.setTracks(new LinkedList<Track>());
for (Track track : tracks) {
if (track.getHandler().equals("vide")) {
movie.addTrack(track);
}
}
writeMovieIntoFile(dst, movie);
randomAccessFile.close();
}
示例2: startTrim
import com.googlecode.mp4parser.authoring.Movie; //导入方法依赖的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();
}
}
示例3: removeUnknownTracks
import com.googlecode.mp4parser.authoring.Movie; //导入方法依赖的package包/类
private Movie removeUnknownTracks(Movie source) {
List<Track> tracks = new LinkedList<Track>();
for (Track track : source.getTracks()) {
if ("vide".equals(track.getHandler()) || "soun".equals(track.getHandler())) {
tracks.add(track);
} else {
LOG.fine("Removed track " + track);
}
}
source.setTracks(tracks);
return source;
}
示例4: correctTimescale
import com.googlecode.mp4parser.authoring.Movie; //导入方法依赖的package包/类
/**
* Returns a new <code>Movie</code> in that all tracks have the timescale 10000000. CTS & DTS are modified
* in a way that even with more than one framerate the fragments exactly begin at the same time.
*
* @param movie original movie
* @return a movie with timescales suitable for smooth streaming manifests
*/
public Movie correctTimescale(Movie movie) {
List<Track> tracks = new LinkedList<Track>();
for (Track track : movie.getTracks()) {
tracks.add(new ChangeTimeScaleTrack(track, timeScale, ismvBuilder.getFragmentIntersectionFinder().sampleNumbers(track)));
}
movie.setTracks(tracks);
return movie;
}