当前位置: 首页>>代码示例>>Java>>正文


Java Movie.addTrack方法代码示例

本文整理汇总了Java中com.googlecode.mp4parser.authoring.Movie.addTrack方法的典型用法代码示例。如果您正苦于以下问题:Java Movie.addTrack方法的具体用法?Java Movie.addTrack怎么用?Java Movie.addTrack使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.googlecode.mp4parser.authoring.Movie的用法示例。


在下文中一共展示了Movie.addTrack方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: mergeMp4

import com.googlecode.mp4parser.authoring.Movie; //导入方法依赖的package包/类
private void mergeMp4(String inFilePathAudio, String inFilePathVideo)
{
    String path = inFilePathVideo.substring(0, inFilePathVideo.lastIndexOf("/"));
    try {
        Movie video = MovieCreator.build(inFilePathVideo);
        Movie audio = MovieCreator.build(inFilePathAudio);
        video.addTrack(audio.getTracks().get(0));
        Container out = new DefaultMp4Builder().build(video);
        long currentMillis = System.currentTimeMillis();
        FileOutputStream fos = new FileOutputStream(new File(path + TEMP_FILE_NAME + currentMillis + ".mp4"));
        out.writeContainer(fos.getChannel());
        fos.close();
        File inAudioFile = new File(inFilePathAudio);
        inAudioFile.delete();
        File inVideoFile = new File(inFilePathVideo);
        if (inVideoFile.delete()) {
            File tempOutFile = new File(path + TEMP_FILE_NAME + currentMillis + ".mp4");
            tempOutFile.renameTo(inVideoFile);
        }
    } catch (IOException e) {
        e.printStackTrace();
    }
}
 
开发者ID:teocci,项目名称:YouTube-In-Background,代码行数:24,代码来源:DownloadFinishedReceiver.java

示例2: 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();
}
 
开发者ID:asm-products,项目名称:nexus-gallery,代码行数:20,代码来源:VideoUtils.java

示例3: 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()));
}
 
开发者ID:andreaslorentzen,项目名称:Dansk-Datahistorisk-Forening,代码行数:27,代码来源:AudioRecorder.java

示例4: makeMP4

import com.googlecode.mp4parser.authoring.Movie; //导入方法依赖的package包/类
/**
 * Creates an MP4 file out of encoded h.264 bytes.
 * 
 * @throws IOException
 */
public static void makeMP4() throws IOException {
	H264TrackImpl h264Track = new H264TrackImpl(new FileDataSourceImpl("dump.h264"));
	//AACTrackImpl aacTrack = new AACTrackImpl(new FileInputStream("/home/sannies2/Downloads/lv.aac").getChannel());
	Movie m = new Movie();
	m.addTrack(h264Track);
	//m.addTrack(aacTrack);
	Container out = new DefaultMp4Builder().build(m);
	FileOutputStream fos = new FileOutputStream(new File("h264_output.mp4"));
	FileChannel fc = fos.getChannel();
	out.writeContainer(fc);
	fos.close();
}
 
开发者ID:mondain,项目名称:h264app,代码行数:18,代码来源:H264Main.java

示例5: muxerFileDebug

import com.googlecode.mp4parser.authoring.Movie; //导入方法依赖的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

示例6: mergeMp4

import com.googlecode.mp4parser.authoring.Movie; //导入方法依赖的package包/类
private void mergeMp4(String inFilePathAudio, String inFilePathVideo) {
    String path = inFilePathVideo.substring(0, inFilePathVideo.lastIndexOf("/"));
    try {
        Movie video = MovieCreator.build(inFilePathVideo);
        Movie audio = MovieCreator.build(inFilePathAudio);
        video.addTrack(audio.getTracks().get(0));
        Container out = new DefaultMp4Builder().build(video);
        long currentMillis = System.currentTimeMillis();
        FileOutputStream fos = new FileOutputStream(new File(path + TEMP_FILE_NAME + currentMillis + ".mp4"));
        out.writeContainer(fos.getChannel());
        fos.close();
        File inAudioFile = new File(inFilePathAudio);
        inAudioFile.delete();
        File inVideoFile = new File(inFilePathVideo);
        if (inVideoFile.delete()) {
            File tempOutFile = new File(path + TEMP_FILE_NAME + currentMillis + ".mp4");
            tempOutFile.renameTo(inVideoFile);
        }
    } catch (IOException e) {
        e.printStackTrace();
    }
}
 
开发者ID:vyasgiridhar,项目名称:Youtube-Downloader,代码行数:23,代码来源:DownloadFinishedReceiver.java

示例7: crop

import com.googlecode.mp4parser.authoring.Movie; //导入方法依赖的package包/类
private boolean crop() {
  try {
    // オリジナル動画を読み込み
    String filePath = Environment.getExternalStorageDirectory() + "/sample1.mp4";
    Movie originalMovie = MovieCreator.build(filePath);

    // 分割
    Track track = originalMovie.getTracks().get(0);
    Movie movie = new Movie();
    movie.addTrack(new AppendTrack(new CroppedTrack(track, 200, 400)));

    // 出力
    Container out = new DefaultMp4Builder().build(movie);
    String outputFilePath = Environment.getExternalStorageDirectory() + "/output_crop.mp4";
    FileOutputStream fos = new FileOutputStream(new File(outputFilePath));
    out.writeContainer(fos.getChannel());
    fos.close();
  } catch (Exception e) {
    e.printStackTrace();
    return false;
  }
  return true;
}
 
开发者ID:suwa-yuki,项目名称:Mp4ParserSample,代码行数:24,代码来源:MainActivity.java

示例8: 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();
}
 
开发者ID:EnteriseToolkit,项目名称:paperchains,代码行数:24,代码来源:Mp4ParserWrapper.java

示例9: saveTracks

import com.googlecode.mp4parser.authoring.Movie; //导入方法依赖的package包/类
private static void saveTracks(String filePath, Track... tracks) throws IOException {
    Movie movie = new Movie();
    for (Track track: tracks) {
        movie.addTrack(track);
    }
    saveMovie(movie, filePath);
}
 
开发者ID:AndyZhu1991,项目名称:grafika,代码行数:8,代码来源:Mp4Util.java

示例10: 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;
}
 
开发者ID:begeekmyfriend,项目名称:mp4parser_android,代码行数:12,代码来源:FlatPackageWriterImpl.java

示例11: 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;

}
 
开发者ID:begeekmyfriend,项目名称:mp4parser_android,代码行数:16,代码来源:FlatPackageWriterImpl.java

示例12: build

import com.googlecode.mp4parser.authoring.Movie; //导入方法依赖的package包/类
public static Movie build(ReadableByteChannel channel) throws IOException {
    IsoFile isoFile = new IsoFile(channel);
    Movie m = new Movie();
    List<TrackBox> trackBoxes = isoFile.getMovieBox().getBoxes(TrackBox.class);
    for (TrackBox trackBox : trackBoxes) {
        m.addTrack(new Mp4TrackImpl(trackBox));
    }
    return m;
}
 
开发者ID:begeekmyfriend,项目名称:mp4parser_android,代码行数:10,代码来源:MovieCreator.java

示例13: 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();
    }
}
 
开发者ID:stfalcon-studio,项目名称:patrol-android,代码行数:49,代码来源:ProcessVideoUtils.java

示例14: muxMp4WithVideoAndAudio

import com.googlecode.mp4parser.authoring.Movie; //导入方法依赖的package包/类
private void muxMp4WithVideoAndAudio() {
    String audio = audioFile.getAbsolutePath();
    String video = videoFile.getAbsolutePath();

    try {
        Movie countVideo = MovieCreator.build(video);
        Movie countAudio = MovieCreator.build(audio);

        Track audioTrack = countAudio.getTracks().get(0);
        countVideo.addTrack(audioTrack);

        {
            Container out = new DefaultMp4Builder().build(countVideo);
            FileOutputStream fos = new FileOutputStream(new File(
                    FileUtil.getCacheDirectory(VideoRecordActivity.this, true),
                    "output.mp4"));
            out.writeContainer(fos.getChannel());
            fos.close();
        }
        //{
        //    FragmentedMp4Builder fragmentedMp4Builder = new FragmentedMp4Builder();
        //    fragmentedMp4Builder.setIntersectionFinder(new SyncSampleIntersectFinderImpl(countVideo, null, -1));
        //    Container out = fragmentedMp4Builder.build(countVideo);
        //    FileOutputStream fos = new FileOutputStream(new File("output-frag.mp4"));
        //    out.writeContainer(fos.getChannel());
        //    fos.close();
        //}

    } catch (IOException e) {
        e.printStackTrace();
    }



}
 
开发者ID:xu6148152,项目名称:binea_project_for_android,代码行数:36,代码来源:VideoRecordActivity.java

示例15: subTitle

import com.googlecode.mp4parser.authoring.Movie; //导入方法依赖的package包/类
private boolean subTitle() {
  try {
    // オリジナル動画を読み込み
    String filePath = Environment.getExternalStorageDirectory() + "/sample1.mp4";
    Movie countVideo = MovieCreator.build(filePath);

    // SubTitleを追加
    TextTrackImpl subTitleEng = new TextTrackImpl();
    subTitleEng.getTrackMetaData().setLanguage("eng");

    subTitleEng.getSubs().add(new TextTrackImpl.Line(0, 1000, "Five"));
    subTitleEng.getSubs().add(new TextTrackImpl.Line(1000, 2000, "Four"));
    subTitleEng.getSubs().add(new TextTrackImpl.Line(2000, 3000, "Three"));
    subTitleEng.getSubs().add(new TextTrackImpl.Line(3000, 4000, "Two"));
    subTitleEng.getSubs().add(new TextTrackImpl.Line(4000, 5000, "one"));
    countVideo.addTrack(subTitleEng);

    // 出力
    Container container = new DefaultMp4Builder().build(countVideo);
    String outputFilePath = Environment.getExternalStorageDirectory() + "/output_subtitle.mp4";
    FileOutputStream fos = new FileOutputStream(outputFilePath);
    FileChannel channel = fos.getChannel();
    container.writeContainer(channel);
    fos.close();
  } catch (Exception e) {
    e.printStackTrace();
    return false;
  }
  return true;
}
 
开发者ID:suwa-yuki,项目名称:Mp4ParserSample,代码行数:31,代码来源:MainActivity.java


注:本文中的com.googlecode.mp4parser.authoring.Movie.addTrack方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。