本文整理汇总了Java中com.googlecode.mp4parser.authoring.Movie.getTracks方法的典型用法代码示例。如果您正苦于以下问题:Java Movie.getTracks方法的具体用法?Java Movie.getTracks怎么用?Java Movie.getTracks使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.googlecode.mp4parser.authoring.Movie
的用法示例。
在下文中一共展示了Movie.getTracks方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: mergeAudioFile
import com.googlecode.mp4parser.authoring.Movie; //导入方法依赖的package包/类
private void mergeAudioFile(File recordedFile, File recordedFileTemp) throws IOException {
if (!recordedFile.exists()) {
recordedFileTemp.renameTo(new File(LocalMediaStorage.getOutputMediaFileUri(null, LocalMediaStorage.MEDIA_TYPE_AUDIO_RECORD).getPath()));
return;
}
final Movie movieA = MovieCreator.build(new FileDataSourceImpl(recordedFileTemp));
final Movie movieB = MovieCreator.build(new FileDataSourceImpl(recordedFile));
final Movie finalMovie = new Movie();
final List<Track> movieOneTracks = movieA.getTracks();
final List<Track> movieTwoTracks = movieB.getTracks();
//for (int i = 0; i < movieOneTracks.size() || i < movieTwoTracks.size(); ++i) {
finalMovie.addTrack(new AppendTrack(movieTwoTracks.get(0), movieOneTracks.get(0)));
//}
final Container container = new DefaultMp4Builder().build(finalMovie);
File recordedFileMerged = new File(LocalMediaStorage.getOutputMediaFileUri(null, LocalMediaStorage.MEDIA_TYPE_AUDIO_RECORD_MERGED).getPath());
if (recordedFileMerged.exists()) {
recordedFileMerged.delete();
}
final FileOutputStream fos = new FileOutputStream(new File(String.format(recordedFileMerged.getPath())));
final WritableByteChannel bb = Channels.newChannel(fos);
container.writeContainer(bb);
fos.close();
recordedFile.delete();
recordedFileTemp.delete();
recordedFileMerged.renameTo(new File(LocalMediaStorage.getOutputMediaFileUri(null, LocalMediaStorage.MEDIA_TYPE_AUDIO_RECORD).getPath()));
}
示例3: append
import com.googlecode.mp4parser.authoring.Movie; //导入方法依赖的package包/类
public static void append(
final String firstFile,
final String secondFile,
final String newFile) throws IOException {
final Movie movieA = MovieCreator.build(new FileDataSourceImpl(secondFile));
final Movie movieB = MovieCreator.build(new FileDataSourceImpl(firstFile));
final Movie finalMovie = new Movie();
final List<Track> movieOneTracks = movieA.getTracks();
final List<Track> movieTwoTracks = movieB.getTracks();
for (int i = 0; i < movieOneTracks.size() || i < movieTwoTracks.size(); ++i) {
finalMovie.addTrack(new AppendTrack(movieTwoTracks.get(i), movieOneTracks.get(i)));
}
final Container container = new DefaultMp4Builder().build(finalMovie);
final FileOutputStream fos = new FileOutputStream(new File(String.format(newFile)));
final WritableByteChannel bb = Channels.newChannel(fos);
container.writeContainer(bb);
fos.close();
}
示例4: removeUnknownTracks
import com.googlecode.mp4parser.authoring.Movie; //导入方法依赖的package包/类
private Movie removeUnknownTracks(Movie source) {
Movie nuMovie = new Movie();
for (Track track : source.getTracks()) {
if ("vide".equals(track.getHandler()) || "soun".equals(track.getHandler())) {
nuMovie.addTrack(track);
} else {
LOG.fine("Removed track " + track);
}
}
return nuMovie;
}
示例5: 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
* @return a movie with timescales suitable for smooth streaming manifests
*/
public Movie correctTimescale(Movie movie) {
Movie nuMovie = new Movie();
for (Track track : movie.getTracks()) {
nuMovie.addTrack(new ChangeTimeScaleTrack(track, timeScale, ismvBuilder.getFragmentIntersectionFinder().sampleNumbers(track, movie)));
}
return nuMovie;
}
示例6: getSyncSamplesTimestamps
import com.googlecode.mp4parser.authoring.Movie; //导入方法依赖的package包/类
/**
* Calculates the timestamp of all tracks' sync samples.
*
* @param movie
* @param track
* @return
*/
public static List<long[]> getSyncSamplesTimestamps(Movie movie, Track track) {
List<long[]> times = new LinkedList<long[]>();
for (Track currentTrack : movie.getTracks()) {
if (currentTrack.getHandler().equals(track.getHandler())) {
long[] currentTrackSyncSamples = currentTrack.getSyncSamples();
if (currentTrackSyncSamples != null && currentTrackSyncSamples.length > 0) {
final long[] currentTrackTimes = getTimes(currentTrack, movie);
times.add(currentTrackTimes);
}
}
}
return times;
}
示例7: calculateTracktimesScalingFactor
import com.googlecode.mp4parser.authoring.Movie; //导入方法依赖的package包/类
private static long calculateTracktimesScalingFactor(Movie m, Track track) {
long timeScale = 1;
for (Track track1 : m.getTracks()) {
if (track1.getHandler().equals(track.getHandler())) {
if (track1.getTrackMetaData().getTimescale() != track.getTrackMetaData().getTimescale()) {
timeScale = lcm(timeScale, track1.getTrackMetaData().getTimescale());
}
}
}
return timeScale;
}
示例8: getTimescale
import com.googlecode.mp4parser.authoring.Movie; //导入方法依赖的package包/类
public long getTimescale(Movie movie) {
long timescale = movie.getTracks().iterator().next().getTrackMetaData().getTimescale();
for (Track track : movie.getTracks()) {
timescale = gcd(track.getTrackMetaData().getTimescale(), timescale);
}
return timescale;
}
示例9: createMoov
import com.googlecode.mp4parser.authoring.Movie; //导入方法依赖的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;
}
示例10: createMfra
import com.googlecode.mp4parser.authoring.Movie; //导入方法依赖的package包/类
/**
* Creates a 'mfra' - movie fragment random access box for the given movie in the given
* isofile. Uses {@link #createTfra(com.googlecode.mp4parser.authoring.Track, com.coremedia.iso.IsoFile)}
* to generate the child boxes.
*
* @param movie concerned movie
* @param isoFile concerned isofile
* @return a complete 'mfra' box
*/
protected Box createMfra(Movie movie, IsoFile isoFile) {
MovieFragmentRandomAccessBox mfra = new MovieFragmentRandomAccessBox();
for (Track track : movie.getTracks()) {
mfra.addBox(createTfra(track, isoFile));
}
MovieFragmentRandomAccessOffsetBox mfro = new MovieFragmentRandomAccessOffsetBox();
mfra.addBox(mfro);
mfro.setMfraSize(mfra.getSize());
return mfra;
}
示例11: getVideoSamplesSize
import com.googlecode.mp4parser.authoring.Movie; //导入方法依赖的package包/类
public static int getVideoSamplesSize(String videoPath) {
int videoSamplesSize = 0;
try {
Movie inMovie = MovieCreator.build(videoPath);
for (Track t : inMovie.getTracks()) {
if (t.getHandler().equals("vide")) {
videoSamplesSize += t.getSamples().size();
}
}
} catch (Exception e) {
e.printStackTrace();
}
return videoSamplesSize;
}
示例12: 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();
}
}
示例13: 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;
}
示例14: 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;
}
示例15: run
import com.googlecode.mp4parser.authoring.Movie; //导入方法依赖的package包/类
public void run() throws IOException {
FlatPackageWriterImpl flatPackageWriter = new FlatPackageWriterImpl(0);
flatPackageWriter.setDebugOutput(debug);
flatPackageWriter.setOutputDirectory(outputDir);
Movie movie = new Movie();
for (File input : inputFiles) {
System.err.println(input.getAbsolutePath());
Movie m = MovieCreator.build(input.getAbsolutePath());
for (Track track : m.getTracks()) {
movie.addTrack(track);
}
}
flatPackageWriter.write(movie);
}